• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/item/access/task/template.php
  • Класс: BitrixTasksItemAccessTaskTemplate
  • Вызов: Template::revokeAll
static function revokeAll($templateId, array $parameters = array())
{
	$result = new Result();

	$templateId = intval($templateId);

	if(!$templateId)
	{
		$result->addError('ILLEGAL_ARGUMENT', 'Illegal argument');
	}

	$checkRights = !($parameters['CHECK_RIGHTS'] === false);
	if($checkRights)
	{
		throw new NotImplementedException('CHECK_RIGHTS === true is not supported currently');
	}

	if($result->isSuccess())
	{
		// just kill them all at low level, without any check
		$dc = TasksTemplatePermissionTable::class;
		$grants = $dc::getList(array('filter' => array('=TEMPLATE_ID' => $templateId)))->fetchAll();
		$wereErrors = false;
		$delResults = array();
		foreach($grants as $grant)
		{
			$delResult = $dc::delete($grant['ID']);
			if(!$delResult->isSuccess())
			{
				$wereErrors = true;
			}

			$delResults[] = $delResult;
		}

		if($wereErrors)
		{
			$result->addWarning('ACTION_INCOMPLETE', 'Some grants were not removed');
		}

		$result->setData($delResults);
	}

	return $result;
}