Exemplo n.º 1
0
 /**
  * task completion method for currently authenticated user
  *
  * @param array $p {
  *     int $id  task id
  * }
  * @return array json responce
  */
 public function complete($p)
 {
     /* check if current user can manage this task */
     if (!Security::canManageTask($p['id'])) {
         throw new \Exception(L\get('Access_denied'));
     }
     $obj = Objects::getCachedObject($p['id']);
     if ($obj->getUserStatus() != Objects\Task::$USERSTATUS_ONGOING) {
         throw new \Exception(L\get('Task_already_completed'));
     }
     $obj->setUserStatus(Objects\Task::$USERSTATUS_DONE);
     // $obj->updateSysData();
     $this->afterUpdate($p['id']);
     return array('success' => true);
 }