public static function Delete($Params) { global $DB, $CACHE_MANAGER; $ID = intVal($Params['id']); if (!$ID) { return false; } $arAffectedSections = array(); $Event = $Params['Event']; if (!isset($Event) || !is_array($Event)) { CCalendar::SetOffset(false, 0); $res = CCalendarEvent::GetList(array('arFilter' => array("ID" => $ID), 'parseRecursion' => false)); $Event = $res[0]; } if ($Event) { if ($Event['IS_MEETING']) { $userId = isset($Params['userId']) && $Params['userId'] > 0 ? $Params['userId'] : CCalendar::GetCurUserId(); if ($userId && $Event['IS_MEETING'] && $Event['MEETING_HOST'] != $userId) { CCalendarEvent::SetMeetingStatus($userId, $Event['ID'], 'N'); return; } } foreach (GetModuleEvents("calendar", "OnBeforeCalendarEventDelete", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($ID, $Event)); } CCalendarLiveFeed::OnDeleteCalendarEventEntry($ID, $Event); $arAffectedSections[] = $Event['SECT_ID']; // Check location: if reserve meeting was reserved - clean reservation if ($Event['LOCATION'] != "") { $loc = CCalendar::ParseLocation($Event['LOCATION']); if ($loc['mrid'] !== false && $loc['mrevid'] !== false) { // Release MR CCalendar::ReleaseLocation($loc); } } if ($Event['CAL_TYPE'] == 'user') { $CACHE_MANAGER->ClearByTag('calendar_user_' . $Event['OWNER_ID']); } if ($Event['IS_MEETING']) { if (CModule::IncludeModule("im")) { CIMNotify::DeleteBySubTag("CALENDAR|INVITE|" . $ID); } $userId = isset($Params['userId']) && $Params['userId'] > 0 ? $Params['userId'] : $Event['MEETING_HOST']; $CACHE_MANAGER->ClearByTag('calendar_user_' . $userId); $curAttendees = self::GetAttendees($ID); $curAttendees = $curAttendees[$ID]; foreach ($curAttendees as $user) { if ($user["USER_ID"] > 0 && $user["STATUS"] != "N") { $arAffectedSections[] = CCalendar::GetMeetingSection($user["USER_ID"]); $CACHE_MANAGER->ClearByTag('calendar_user_' . $user["USER_ID"]); CCalendar::SendMessage(array('mode' => 'cancel', 'name' => $Event['NAME'], "from" => $Event["DT_FROM"], "to" => $Event["DT_TO"], "location" => CCalendar::GetTextLocation($Event["LOCATION"]), "guestId" => $user["USER_ID"], "eventId" => $ID, "userId" => $userId)); } } } if ($Params['bMarkDeleted']) { $strSql = "UPDATE b_calendar_event SET " . $DB->PrepareUpdate("b_calendar_event", array("DELETED" => "Y")) . " WHERE ID=" . $ID; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); } else { // Real deleting $strSql = "DELETE from b_calendar_event WHERE ID=" . $ID; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); // Del link from table $strSql = "DELETE FROM b_calendar_event_sect WHERE EVENT_ID=" . $ID; $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__); } if (count($arAffectedSections) > 0) { CCalendarSect::UpdateModificationLabel($arAffectedSections); } foreach (GetModuleEvents("calendar", "OnAfterCalendarEventDelete", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($ID, $Event)); } CCalendar::ClearCache('event_list'); return true; } return false; }
public static function Delete($params) { global $DB, $CACHE_MANAGER; $id = intVal($params['id']); if ($id) { $userId = isset($params['userId']) && $params['userId'] > 0 ? $params['userId'] : CCalendar::GetCurUserId(); $arAffectedSections = array(); $event = $params['Event']; if (!isset($event) || !is_array($event)) { CCalendar::SetOffset(false, 0); $res = CCalendarEvent::GetList(array('arFilter' => array("ID" => $id), 'parseRecursion' => false)); $event = $res[0]; } if ($event) { if ($event['IS_MEETING'] && $event['PARENT_ID'] !== $event['ID']) { CCalendarEvent::SetMeetingStatus($userId, $event['ID'], 'N'); } else { foreach (GetModuleEvents("calendar", "OnBeforeCalendarEventDelete", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($id, $event)); } if ($event['PARENT_ID']) { CCalendarLiveFeed::OnDeleteCalendarEventEntry($event['PARENT_ID'], $event); } else { CCalendarLiveFeed::OnDeleteCalendarEventEntry($event['ID'], $event); } $arAffectedSections[] = $event['SECT_ID']; // Check location: if reserve meeting was reserved - clean reservation if ($event['LOCATION'] != "") { $loc = CCalendar::ParseLocation($event['LOCATION']); if ($loc['mrid'] !== false && $loc['mrevid'] !== false) { // Release MR CCalendar::ReleaseLocation($loc); } } if ($event['CAL_TYPE'] == 'user') { $CACHE_MANAGER->ClearByTag('calendar_user_' . $event['OWNER_ID']); } if ($event['IS_MEETING']) { if (CModule::IncludeModule("im")) { CIMNotify::DeleteBySubTag("CALENDAR|INVITE|" . $event['PARENT_ID']); } $CACHE_MANAGER->ClearByTag('calendar_user_' . $userId); $childEvents = CCalendarEvent::GetList(array('arFilter' => array("PARENT_ID" => $id), 'parseRecursion' => false)); $chEventIds = array(); foreach ($childEvents as $chEvent) { if ($chEvent["MEETING_STATUS"] != "N") { if ($chEvent['DATE_TO_TS_UTC'] + date("Z", $chEvent['DATE_TO_TS_UTC']) > time() - 60 * 5) { $fromTo = CCalendarEvent::GetEventFromToForUser($event, $chEvent["OWNER_ID"]); CCalendar::SendMessage(array('mode' => 'cancel', 'name' => $chEvent['NAME'], "from" => $fromTo["DATE_FROM"], "to" => $fromTo["DATE_TO"], "location" => CCalendar::GetTextLocation($chEvent["LOCATION"]), "guestId" => $chEvent["OWNER_ID"], "eventId" => $id, "userId" => $userId)); } } $chEventIds[] = $chEvent["ID"]; } // Set flag if ($params['bMarkDeleted']) { $strSql = "UPDATE b_calendar_event SET " . $DB->PrepareUpdate("b_calendar_event", array("DELETED" => "Y")) . " WHERE PARENT_ID=" . $id; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); } else { $strSql = "DELETE from b_calendar_event WHERE PARENT_ID=" . $id; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); $strChEvent = join(',', $chEventIds); if (count($chEventIds) > 0) { // Del link from table $strSql = "DELETE FROM b_calendar_event_sect WHERE EVENT_ID in (" . $strChEvent . ")"; $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__); } } } if ($params['bMarkDeleted']) { $strSql = "UPDATE b_calendar_event SET " . $DB->PrepareUpdate("b_calendar_event", array("DELETED" => "Y")) . " WHERE ID=" . $id; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); } else { // Real deleting $strSql = "DELETE from b_calendar_event WHERE ID=" . $id; $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); // Del link from table $strSql = "DELETE FROM b_calendar_event_sect WHERE EVENT_ID=" . $id; $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__); } if (count($arAffectedSections) > 0) { CCalendarSect::UpdateModificationLabel($arAffectedSections); } foreach (GetModuleEvents("calendar", "OnAfterCalendarEventDelete", true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($id, $event)); } CCalendar::ClearCache('event_list'); } return true; } } return false; }
public static function Delete($id, $checkPermissions = true) { global $DB; if ($checkPermissions !== false && !CCalendarSect::CanDo('calendar_edit_section', $id)) { return CCalendar::ThrowError('EC_ACCESS_DENIED'); } $arEvents = CCalendarEvent::GetList(array('arFilter' => array("SECTION" => array(IntVal($id))), 'setDefaultLimit' => false, 'parseRecursion' => false, 'checkPermissions' => false)); $meetingIds = array(); foreach ($arEvents as $event) { if ($event['IS_MEETING'] && $event['PARENT_ID'] === $event['ID']) { $meetingIds[] = intval($event['PARENT_ID']); CCalendarLiveFeed::OnDeleteCalendarEventEntry($event['PARENT_ID'], $event); } } if (count($meetingIds) > 0) { $meetingIds = implode(',', $meetingIds); $DB->Query("DELETE from b_calendar_event WHERE PARENT_ID in (" . $meetingIds . ")", false, "File: " . __FILE__ . "<br>Line: " . __LINE__); } // Del link from table $strSql = "DELETE FROM b_calendar_event_sect WHERE SECT_ID=" . IntVal($id); $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__); // Del from $strSql = "DELETE FROM b_calendar_section WHERE ID=" . IntVal($id); $DB->Query($strSql, false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__); CCalendarEvent::DeleteEmpty(); CCalendar::ClearCache(array('section_list', 'event_list')); return true; }
if (!CModule::IncludeModule("calendar") || !class_exists("CCalendar")) { return ShowError(GetMessage("EC_CALENDAR_MODULE_NOT_INSTALLED")); } $arParams['EVENT_ID'] = intval($arParams['EVENT_ID']); $arResult['ID'] = 'livefeed' . $arParams['EVENT_ID']; $arResult['EVENT'] = false; $arParams['CUR_USER'] = $USER->GetId(); $Events = CCalendarEvent::GetList(array('arFilter' => array("ID" => $arParams['EVENT_ID'], "DELETED" => false), 'parseRecursion' => false, 'fetchAttendees' => true, 'checkPermissions' => true, 'setDefaultLimit' => false)); if ($Events && is_array($Events[0])) { $arResult['EVENT'] = $Events[0]; } if (!$arResult['EVENT']) { $Events = CCalendarEvent::GetList(array('arFilter' => array("ID" => $arParams['EVENT_ID'], "DELETED" => false), 'parseRecursion' => false, 'checkPermissions' => false, 'setDefaultLimit' => false)); // Clean damaged event from livefeed if (!$Events || !is_array($Events[0])) { CCalendarLiveFeed::OnDeleteCalendarEventEntry($arParams['EVENT_ID']); } return false; } if ($arResult['EVENT']['LOCATION'] !== '') { $arResult['EVENT']['LOCATION'] = CCalendar::GetTextLocation($arResult['EVENT']["LOCATION"]); } global $USER_FIELD_MANAGER; $UF = CCalendarEvent::GetEventUserFields($arResult['EVENT']); $arResult['UF_CRM_CAL_EVENT'] = $UF['UF_CRM_CAL_EVENT']; if (empty($arResult['UF_CRM_CAL_EVENT']['VALUE'])) { $arResult['UF_CRM_CAL_EVENT'] = false; } $arResult['UF_WEBDAV_CAL_EVENT'] = $UF['UF_WEBDAV_CAL_EVENT']; if (empty($arResult['UF_WEBDAV_CAL_EVENT']['VALUE'])) { $arResult['UF_WEBDAV_CAL_EVENT'] = false;