- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/item/context/access/task.php
- Класс: Bitrix\Tasks\Item\Context\Access\Task
- Вызов: Task::canCreate
public function canCreate($item, $userId = 0) { $result = new Result(); $userId = $item->getUserId(); if(!User::isSuper($userId)) // no access check for admins { $rErrors = $result->getErrors(); $data = $item; $state = $item->getTransitionState(); if($state->isInProgress()) { $data = $state; } if($data['RESPONSIBLE_ID'] != $userId && $data['CREATED_BY'] != $userId) { $rErrors->add('RESPONSIBLE_AND_ORIGINATOR_NOT_ALLOWED', 'You can not add task from other person to another person'); } $groupId = intval($data['GROUP_ID']); if($groupId) { if(!Group::can($groupId, Group::ACTION_CREATE_TASKS, $userId)) { $rErrors->add('PROJECT_ACCESS_DENIED', 'You are not allowed to create tasks in the group [group: '.$groupId.', user: '.$userId.']'); } } } return $result; }