• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/controller/calendarajax.php
  • Класс: BitrixCalendarControllerCalendarAjax
  • Вызов: CalendarAjax::hideExternalCalendarSectionAction
public function hideExternalCalendarSectionAction()
{
	$request = $this->getRequest();
	$response = [];
	$id = $request->getPost('id');

	if (
		!CCalendar::IsPersonal()
		&& !SectionAccessController::can(CCalendar::GetUserId(), ActionDictionary::ACTION_SECTION_EDIT, $id)
	)
	{
		$this->addError(new Error('[sd02]' . Loc::getMessage('EC_ACCESS_DENIED'), 'access_denied'));
	}

	$section = CCalendarSect::GetById($id);
	// For exchange we change only calendar name
	if ($section && $section['CAL_DAV_CON'])
	{
		CCalendarSect::Edit([
			'arFields' => [
				'ID' => $id,
				'ACTIVE' => 'N'
			]
		]);

		// Check if it's last section from connection - remove it
		$sections = CCalendarSect::GetList([
			'arFilter' => [
				'CAL_DAV_CON' => $section['CAL_DAV_CON'],
				'ACTIVE' => 'Y'
			]
		]);

		if (empty($sections))
		{
			CCalendar::setOwnerId(CCalendar::GetUserId());
			CCalendar::RemoveConnection(['id' => (int)$section['CAL_DAV_CON'], 'del_calendars' => true]);
		}
	}

	return $response;
}