CTaskItem Class
CTaskItem — high-level API to work with separate tasks (includes business logic).
Instead of calls, CTasks::Update(), CTasks::Delete() and etc. must be used;
- allows to work with task on behalf of specified user name (not necessarily of the current authorized user);
- has an internal mechanism of transparent caching (no need to track the cache refreshing when working with the task via this class — under the condition of instantiation via getInstance());
- "lazy" block data upload is applied, which beneficially affects the performance;
To work with class, it must be instantiated for a specific task within the framework of rights for specific user.
It is not a multitone. However, it is recommended to instantiate a class instance via the getInstance() method, because, in this case, the continually updated cache will be maintained automatically.
For example,
<? $taskId = 7; $userId = $USER->getId(); $oTask = CTaskItem::getInstance($taskId, $userId); ?>
Method parameters
Parameter | Description |
---|---|
$taskId | Task ID. |
$userId | ID of the user on behalf of which the work is performed (for the option of impersonation). |
Returned value
CTaskItem class object. When the method is called repeatedly with the parameters which were already passed previously, the same object will be returned.
array public function getManifest();
Returns an array with the class description.
Attention! Format of the array can change randomly in the future, and it is not intended for automatic processing. However, it can be convenient during the development, because it contains, for example, the list of methods, available in REST, values that they receive and etc.
Class methods
Method | Description | Available from version |
---|---|---|
add | Returns an instance of CTaskItem class. | |
getData | Returns an array, containing the data for task. | |
getDescription | Returns description for task. | |
getFiles | Returns an array, containing IDs for files, attached to the task. | |
addByTemplate | Adds task by the template. | |
addChildTaskByTemplate | Adds subtasks from the template. | |
duplicateChildTasks | Copies subtasks of the selected task. | |
duplicate | Copies the task or tasks. | |
checkCanRead | The method verifies user access to tasks. | |
update | Changes the task parameters. | |
getTags | Returns an array, containing tags of the specified user in the task. | |
getDependsOn | Returns an array, containing task IDs on which the task is dependant. | |
getAllowedActions | Returns an array, describing permitted actions for the task. | |
isActionAllowed | Verifies permission for the action. | |
delete | Deletes the task. | |
delegate | Delegates the task to a user. | |
startExecution | Switches task into "in progress" status. | |
defer | Switches task into "deferred" status. | |
renew | Switches task into "pending" status. | |
complete | Switches task into "completed" or "awaiting for supervisor's control" status. | |
approve | Switches the task that awaits for control into "completed" status. | |
disapprove | Switches the awaiting control task into "unaccepted". | |
addToFavorite | Adds the task to Favorites. | |
deleteFromFavorite | Deletes task from Favorites. | |
toggleFavorite | Changes favorite state for the specified task. | |
addProjectDependence | Adds a dependency from one task to another within Gantt. | |
updateProjectDependence | Updates a dependency type between two tasks within Gantt. |
© «Bitrix24», 2001-2024