Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 public static function onAfterCommentUpdateAfter($entityType, $eventID, $arData, $logID = false)
 {
     if ($entityType != "TK") {
         return;
     }
     if (intval($logID) <= 0) {
         return;
     }
     if (!is_array($arData) || !array_key_exists("ACTION", $arData) || $arData["ACTION"] != "EDIT") {
         return;
     }
     CCalendarLiveFeed::SetCommentFileRights($arData, $logID);
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
                     if (strlen($vv) > 0) {
                         $arAccessCodes[] = $vv;
                     }
                 }
             }
         }
     }
     $arFields = array("ID" => intVal($_POST['EVENT_ID']), "DT_FROM_TS" => $_POST['EVENT_FROM_TS'], "DT_TO_TS" => $_POST['EVENT_TO_TS'], "DATE_FROM" => $_POST['DATE_FROM'], "DATE_TO" => $_POST['DATE_FROM'], "TIME_FROM" => $_POST['TIME_FROM'], "TIME_TO" => $_POST['TIME_TO'], "TZ_FROM" => $_POST['TZ_FROM'], "TZ_TO" => $_POST['TZ_TO'], "DEFAULT_TZ" => $_POST['DEFAULT_TZ'], "SKIP_TIME" => $_POST['EVENT_FULL_DAY'] == 'Y', 'NAME' => trim($_POST['EVENT_NAME']), 'DESCRIPTION' => trim($_POST['EVENT_DESCRIPTION']), 'SECTION' => intVal($_POST['EVENT_SECTION']), 'ACCESSIBILITY' => $_POST['EVENT_ACCESSIBILITY'], 'IMPORTANCE' => $_POST['EVENT_IMPORTANCE'], 'RRULE' => $_POST['EVENT_RRULE'], 'LOCATION' => $_POST['EVENT_LOCATION'], "REMIND" => isset($_POST['EVENT_REMIND']) ? array(0 => array('count' => $_POST['EVENT_REMIND_COUNT'], 'type' => $_POST['EVENT_REMIND_TYPE'])) : null);
     // Userfields for event
     $arUFFields = array();
     foreach ($_POST as $field => $value) {
         if (substr($field, 0, 3) == "UF_") {
             $arUFFields[$field] = $value;
         }
     }
     CCalendarLiveFeed::EditCalendarEventEntry($arFields, $arUFFields, $arAccessCodes, array('type' => 'user', 'userId' => $arBlog["OWNER_ID"]));
     $redirectUrl = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG"], array("user_id" => $arBlog["OWNER_ID"]));
     LocalRedirect($redirectUrl);
 }
 if ($_POST["save"] == "Y" && $_POST["changePostFormTab"] == "lists" && (check_bitrix_sessid() || $arParams["IS_REST"] == "Y")) {
     $redirectUrl = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG"], array("user_id" => $arBlog["OWNER_ID"]));
     LocalRedirect($redirectUrl);
 }
 if (($_POST["apply"] || $_POST["save"] || $_POST["draft"]) && empty($_POST["reset"])) {
     if (check_bitrix_sessid() || $arParams["IS_REST"] == "Y") {
         if (strlen($arResult["ERROR_MESSAGE"]) <= 0) {
             $GLOBALS["DB"]->StartTransaction();
             $CATEGORYtmp = array();
             if (!empty($_POST["TAGS"])) {
                 $dbCategory = CBlogCategory::GetList(array(), array("BLOG_ID" => $arBlog["ID"]));
                 while ($arCategory = $dbCategory->Fetch()) {
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
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;