- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/access/rule/templateeditrule.php
- Класс: BitrixTasksAccessRuleTemplateEditRule
- Вызов: TemplateEditRule::execute
public function execute(AccessibleItem $template = null, $params = null): bool
{
if (!$template)
{
$this->controller->addError(static::class, 'Incorrect template');
return false;
}
if ($this->user->isAdmin())
{
return true;
}
if (!$template->getId())
{
return $this->controller->check(ActionDictionary::ACTION_TEMPLATE_CREATE, $template, $params);
}
if (!$this->controller->check(ActionDictionary::ACTION_TEMPLATE_READ, $template, $params))
{
$this->controller->addError(static::class, 'Access to template denied');
return false;
}
if ($template->getTemplatePermission($this->user, PermissionDictionary::TEMPLATE_FULL))
{
return true;
}
$isInDepartment = $template->isInDepartment($this->user->getUserId(), false, [RoleDictionary::ROLE_DIRECTOR]);
if (
$this->user->getPermission(PermissionDictionary::TEMPLATE_DEPARTMENT_EDIT)
&& $isInDepartment
)
{
return true;
}
if (
$this->user->getPermission(PermissionDictionary::TEMPLATE_NON_DEPARTMENT_EDIT)
&& !$isInDepartment
)
{
return true;
}
$this->controller->addError(static::class, 'Access to template edit denied');
return false;
}