/** * Get a task */ public function get($id) { global $USER; $result = array(); if ($id = $this->checkTaskId($id)) { $task = new \CTaskItem($id, $USER->GetId()); $id = $task->getId(); $data = $task->getData(false); $result['DATA']['TASK'][$id] = $data; $result['CAN']['TASK'][$id]['ACTION'] = static::translateAllowedActionNames($task->getAllowedActions()); } return $result; }
/** * Duplicate subtasks of the current task. * * @param CTaskItem $cloneTaskInstance An instance of task clone that subtasks will be attached to. * * @throws TasksException - on access denied, task not found * @throws CTaskAssertException * @throws Exception - on unexpected error * * @return CTaskItem[] */ public function duplicateChildTasks($cloneTaskInstance) { CTaskAssert::assert($cloneTaskInstance instanceof CTaskItemInterface); $duplicates = array(); $data = $this->getData(false); // check rights here if ($data) { // getting tree data and checking for dead loops $queue = array(); $this->duplicateChildTasksLambda($this, $queue); $idMap = array(); foreach ($queue as $taskInstance) { $data = $taskInstance->getData(); $cloneInstances = $taskInstance->duplicate(array('PARENT_ID' => isset($idMap[$data['PARENT_ID']]) ? $idMap[$data['PARENT_ID']] : $cloneTaskInstance->getId()), array('CLONE_CHILD_TASKS' => false)); if (is_array($cloneInstances) && !empty($cloneInstances)) { $cloneInstance = array_shift($cloneInstances); $idMap[$taskInstance->getId()] = $cloneInstance->getId(); $duplicates[$taskInstance->getId()] = $cloneInstance; } } } return $duplicates; }
private static function checkAccessThrowException(\CTaskItem $task) { if (!$task->isActionAllowed(\CTaskItem::ACTION_CHANGE_DEADLINE)) { throw new \Bitrix\Tasks\ActionNotAllowedException(false, array('AUX' => array('MESSAGE' => array('TASK_ID' => $task->getId(), 'USER_ID' => $this->userId)))); } }