• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar.php
  • Класс: CCalendar
  • Вызов: CCalendar::RemoveConnection
static function RemoveConnection(array $params = [])
{
	if (Loader::includeModule('dav'))
	{
		$sections = self::getSectionsByConnectionId($params['id']);
		$connection = CDavConnection::GetList(
			["ID" => "ASC"],
			["ID" => $params['id']]
		);
	
		if (is_array($sections))
		{
			foreach ($sections as $section)
			{
				if ($params['del_calendars'] /*&& $section['IS_LOCAL'] !== 'Y'*/)
				{
					CCalendarSect::Delete($section['ID'], false);
				}
				else
				{
					self::markSectionLikeDelete($section['ID']);
				}
			}
		}

		CDavConnection::Delete($params['id']);

		if (is_array($connection))
		{
			/** @var GoogleHelper $googleHelper */
			$googleHelper = ServiceLocator::getInstance()->get('calendar.service.google.helper');
			$caldavHelper = ServiceLocator::getInstance()->get('calendar.service.caldav.helper');
			$connectionType = $caldavHelper->isYandex($connection['SERVER_HOST'])
				? BitrixCalendarSyncCaldavHelper::YANDEX_TYPE
				: BitrixCalendarSyncCaldavHelper::CALDAV_TYPE
			;
			$connectionName = $googleHelper->isGoogleConnection($connection['ACCOUNT_TYPE'])
				? 'google'
				: $connectionType . $connection['ID']
			;
			Util::addPullEvent(
				'delete_sync_connection',
				$connection['ENTITY_ID'],
				[
					'syncInfo' => [
						$connectionName => [
							'type' => $connectionType,
						],
					],
					'requestUid' => Util::getRequestUid(),
				]
			);
		}
	}
}