Documentation

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

ParameterDescription
$taskIdTask ID.
$userIdID 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
addReturns an instance of CTaskItem class.
getDataReturns an array, containing the data for task.
getDescriptionReturns description for task.
getFilesReturns an array, containing IDs for files, attached to the task.
addByTemplateAdds task by the template.
addChildTaskByTemplateAdds subtasks from the template.
duplicateChildTasksCopies subtasks of the selected task.
duplicateCopies the task or tasks.
checkCanReadThe method verifies user access to tasks.
updateChanges the task parameters.
getTagsReturns an array, containing tags of the specified user in the task.
getDependsOnReturns an array, containing task IDs on which the task is dependant.
getAllowedActionsReturns an array, describing permitted actions for the task.
isActionAllowedVerifies permission for the action.
deleteDeletes the task.
delegateDelegates the task to a user.
startExecutionSwitches task into "in progress" status.
deferSwitches task into "deferred" status.
renewSwitches task into "pending" status.
completeSwitches task into "completed" or "awaiting for supervisor's control" status.
approveSwitches the task that awaits for control into "completed" status.
disapproveSwitches the awaiting control task into "unaccepted".
addToFavoriteAdds the task to Favorites.
deleteFromFavoriteDeletes task from Favorites.
toggleFavoriteChanges favorite state for the specified task.
addProjectDependenceAdds a dependency from one task to another within Gantt.
updateProjectDependenceUpdates a dependency type between two tasks within Gantt.


© «Bitrix24», 2001-2024
Up