- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/access/rule/checklistsaverule.php
- Класс: BitrixTasksAccessRuleChecklistSaveRule
- Вызов: ChecklistSaveRule::execute
public function execute(AccessibleItem $task = null, $params = null): bool
{
if (!$task)
{
$this->controller->addError(static::class, 'Incorrect task');
return false;
}
if ($this->user->isAdmin())
{
return true;
}
if (!$this->controller->check(ActionDictionary::ACTION_TASK_READ, $task, $params))
{
return false;
}
// user can edit all checklist's items
if ($this->controller->check(ActionDictionary::ACTION_CHECKLIST_EDIT, $task, $params))
{
return true;
}
if ($task instanceof TemplateModel)
{
$this->controller->addError(static::class, 'Unable to works with template');
return false;
}
if (!$this->isList($params))
{
$checklist = $this->getModelFromParams($params);
$action = $checklist->getId()
? ActionDictionary::ACTION_CHECKLIST_EDIT
: ActionDictionary::ACTION_CHECKLIST_ADD;
return $this->controller->check($action, $task, $checklist);
}
// Warning! Mass check for webform format only. See TasksTaskComponent::checkRights()
$delta = $this->getDelta($task->getChecklist(), $params);
// nothing changed
if (empty($delta))
{
return true;
}
if (!array_key_exists(self::CHANGED, $delta))
{
return $this->controller->check(ActionDictionary::ACTION_CHECKLIST_ADD, $task, $params);
}
foreach ($delta[self::CHANGED] as $row)
{
if (!$this->controller->check(ActionDictionary::ACTION_CHECKLIST_EDIT, $task, $row))
{
$this->controller->addError(static::class, 'Access to checklist edit denied');
return false;
}
}
foreach ($delta[self::STATUS_CHANGED] ?? [] as $row)
{
if (!$this->controller->check(ActionDictionary::ACTION_CHECKLIST_TOGGLE, $task, $row))
{
$this->controller->addError(static::class, 'Access to checklist toggle denied');
return false;
}
}
return true;
}