Differential D7326 Diff 16500 src/applications/phrequent/conduit/ConduitAPI_phrequent_stop_Method.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phrequent/conduit/ConduitAPI_phrequent_stop_Method.php
- This file was added.
<?php | |||||
/** | |||||
*@group conduit | |||||
*/ | |||||
final class ConduitAPI_phrequent_stop_Method | |||||
extends ConduitAPI_phrequent_Method { | |||||
public function getMethodDescription() { | |||||
return "Stop tracking time on an object."; | |||||
} | |||||
public function getMethodStatus() { | |||||
return self::METHOD_STATUS_UNSTABLE; | |||||
} | |||||
public function defineParamTypes() { | |||||
return array( | |||||
'object' => 'required phid' | |||||
); | |||||
} | |||||
public function defineReturnType() { | |||||
return 'bool'; | |||||
} | |||||
public function defineErrorTypes() { | |||||
return array( | |||||
); | |||||
} | |||||
protected function execute(ConduitAPIRequest $request) { | |||||
$user = $request->getUser(); | |||||
$phid = $request->getValue('object'); | |||||
if (!PhrequentUserTimeQuery::isUserTrackingObject($user, $phid)) { | |||||
// Don't do anything, it's not being tracked. | |||||
return false; | |||||
} | |||||
$usertime_dao = new PhrequentUserTime(); | |||||
$conn = $usertime_dao->establishConnection('r'); | |||||
queryfx( | |||||
$conn, | |||||
'UPDATE %T usertime '. | |||||
'SET usertime.dateEnded = UNIX_TIMESTAMP() '. | |||||
'WHERE usertime.userPHID = %s '. | |||||
'AND usertime.objectPHID = %s '. | |||||
'AND usertime.dateEnded IS NULL '. | |||||
'ORDER BY usertime.dateStarted, usertime.id DESC '. | |||||
'LIMIT 1', | |||||
$usertime_dao->getTableName(), | |||||
$user->getPHID(), | |||||
$phid); | |||||
return true; | |||||
} | |||||
} |