- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/access/rule/taskchangedirectorrule.php
- Класс: BitrixTasksAccessRuleTaskChangeDirectorRule
- Вызов: TaskChangeDirectorRule::execute
public function execute(AccessibleItem $task = null, $params = null): bool
{
if (!$task)
{
$this->controller->addError(static::class, 'Incorrect task');
return false;
}
if (!$this->checkParams($params))
{
$this->controller->addError(static::class, 'Incorrect params');
return false;
}
if ($this->user->isAdmin())
{
return true;
}
// user can update task
if (!$this->controller->check(ActionDictionary::ACTION_TASK_EDIT, $task, $params))
{
$this->controller->addError(static::class, 'Access to edit task denied');
return false;
}
$directors = $params->getMembers(RoleDictionary::ROLE_DIRECTOR);
if (empty($directors))
{
$this->controller->addError(static::class, 'Director is undefined');
return false;
}
if ($directors[0] === $this->user->getUserId())
{
return true;
}
$this->controller->addError(static::class, 'Access to change director denied');
return false;
}