• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/classes/general/calendar_sect.php
  • Класс: CCalendarSect
  • Вызов: CCalendarSect::Delete
static function Delete($id, $checkPermissions = true, $params = [])
{
	global $DB;
	$id = (int)$id;

	$sectionFields = self::GetById($id);
	$canEdit = $sectionFields['PERM']['edit'] ?? false;
	if ($checkPermissions !== false && !$canEdit)
	{
		return CCalendar::ThrowError('EC_ACCESS_DENIED');
	}

	$meetingIds = [];
	if (Util::isSectionStructureConverted())
	{
		$strSql = "select CE.ID, CE.PARENT_ID, CE.CREATED_BY
			from b_calendar_event CE
			where CE.SECTION_ID=".$id."
			and (CE.IS_MEETING='1' and CE.IS_MEETING is not null)
			and (CE.DELETED='N' and CE.DELETED is not null)";
	}
	else
	{
		// Here we don't use GetList to speed up delete process
		// mantis: 82918
		$strSql = "SELECT CE.ID, CE.PARENT_ID, CE.DELETED, CE.CREATED_BY, CES.SECT_ID, CES.EVENT_ID
			FROM b_calendar_event CE
			LEFT JOIN b_calendar_event_sect CES ON (CE.ID=CES.EVENT_ID)
			WHERE CES.SECT_ID=".$id."
			AND (CE.IS_MEETING='1' and CE.IS_MEETING is not null)
			AND (CE.DELETED='N' and CE.DELETED is not null)";
	}

	$res = $DB->Query($strSql , false, "File: ".__FILE__."
Line: ".__LINE__); while($ev = $res->Fetch()) { if ((int)$ev['ID'] === (int)$ev['PARENT_ID']) { $meetingIds[] = (int)$ev['PARENT_ID']; CCalendarLiveFeed::OnDeleteCalendarEventEntry($ev['PARENT_ID']); } $pullUserId = (int)$ev['CREATED_BY'] > 0 ? (int)$ev['CREATED_BY'] : CCalendar::GetCurUserId(); if ($pullUserId) { BitrixCalendarUtil::addPullEvent( 'delete_event', $pullUserId, [ 'fields' => $ev, ] ); } } if (!empty($meetingIds)) { $DB->Query("DELETE from b_calendar_event WHERE PARENT_ID in (".implode(',', $meetingIds).")", false, "File: ".__FILE__."
Line: ".__LINE__); } //delete section in services self::onDeleteSync($id, [ 'originalFrom' => $params['originalFrom'] ?? '', ]); // Del link from table if (!Util::isSectionStructureConverted()) { $DB->Query("DELETE FROM b_calendar_event_sect WHERE SECT_ID=".$id, false, "FILE: ".__FILE__."
LINE: ".__LINE__); } // Del from $DB->Query("DELETE FROM b_calendar_section WHERE ID=".$id, false, "FILE: ".__FILE__."
LINE: ".__LINE__); CCalendarEvent::DeleteEmpty(); self::CleanAccessTable(); CCalendar::ClearCache(array('section_list', 'event_list')); foreach(EventManager::getInstance()->findEventHandlers("calendar", "OnAfterCalendarSectionDelete") as $event) { ExecuteModuleEventEx($event, array($id)); } $pullUserId = (int)$sectionFields['CREATED_BY'] > 0 ? (int)$sectionFields['CREATED_BY'] : CCalendar::GetCurUserId(); if ($pullUserId) { Util::addPullEvent( 'delete_section', $pullUserId, [ 'fields' => $sectionFields, ] ); } return true; }