• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar_restservice.php
  • Класс: CCalendarRestService
  • Вызов: CCalendarRestService::ResourceAdd
static function ResourceAdd($params = [], $nav = null, $server = null)
{
	$methodName = "calendar.resource.add";
	$type = 'resource';

	if (empty($params['name']))
	{
		throw new RestException(Loc::getMessage('CAL_REST_PARAM_EXCEPTION', array('#REST_METHOD#' => $methodName, '#PARAM_NAME#' => 'name')));
	}

	if (Loader::includeModule('intranet') && !BitrixIntranetUtil::isIntranetUser())
	{
		throw new RestException(Loc::getMessage('CAL_REST_ACCESS_DENIED'));
	}

	$accessController = new TypeAccessController(CCalendar::GetUserId());
	$typeModel = TypeModel::createFromXmlId($type);

	if (!$accessController->check(ActionDictionary::ACTION_TYPE_EDIT, $typeModel))
	{
		throw new RestException(Loc::getMessage('CAL_REST_ACCESS_DENIED'));
	}

	$id = CCalendarSect::edit([
		'arFields' => [
			'CAL_TYPE' => $type,
			'NAME' => $params['name'],
			'ACCESS' => []
		]
	]);

	if (!$id)
	{
		throw new RestException(Loc::getMessage('CAL_REST_RESOURCE_NEW_ERROR'));
	}

	CCalendarSect::SetClearOperationCache(true);
	return $id;
}