- Модуль: calendar
- Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar_restservice.php
- Класс: CCalendarRestService
- Вызов: CCalendarRestService::SectionDelete
static function SectionDelete($params = [], $nav = null, $server = null)
{
$userId = CCalendar::GetCurUserId();
$methodName = "calendar.section.delete";
if (isset($params['type']))
{
$type = $params['type'];
}
else
{
throw new RestException(Loc::getMessage('CAL_REST_PARAM_EXCEPTION', [
'#REST_METHOD#' => $methodName,
'#PARAM_NAME#' => 'type'
]));
}
if (isset($params['ownerId']))
{
$ownerId = (int)$params['ownerId'];
}
elseif ($type === 'user')
{
$ownerId = $userId;
}
else
{
throw new RestException(Loc::getMessage('CAL_REST_PARAM_EXCEPTION', array('#REST_METHOD#' => $methodName, '#PARAM_NAME#' => 'ownerId')));
}
if (isset($params['id']) && (int)$params['id'] > 0)
{
$id = (int)$params['id'];
}
else
{
throw new RestException(Loc::getMessage('CAL_REST_SECT_ID_EXCEPTION'));
}
$accessController = new SectionAccessController($userId);
$sectionModel =
SectionModel::createFromId($id)
->setType($type)
->setOwnerId($ownerId)
;
if (!$accessController->check(ActionDictionary::ACTION_SECTION_EDIT, $sectionModel))
{
throw new RestException(Loc::getMessage('CAL_REST_ACCESS_DENIED'));
}
$res = CCalendar::DeleteSection($id);
if (!$res)
{
throw new RestException(Loc::getMessage('CAL_REST_SECTION_DELETE_ERROR'));
}
return $res;
}