コード例 #1
0
ファイル: user_group.php プロジェクト: DarneoStudio/bitrix
 function OnBeforeConfirmNotify($module, $tag, $value, $arParams)
 {
     if ($module == "socialnetwork") {
         $arTag = explode("|", $tag);
         if (count($arTag) == 4 && $arTag[1] == 'INVITE_GROUP') {
             if ($value == 'Y') {
                 self::UserConfirmRequestToBeMember($arTag[2], $arTag[3]);
                 return true;
             } else {
                 self::UserRejectRequestToBeMember($arTag[2], $arTag[3]);
                 return true;
             }
         } elseif (count($arTag) == 6 && $arTag[1] == "REQUEST_GROUP") {
             if ($value == "Y") {
                 self::ConfirmRequestToBeMember($GLOBALS["USER"]->GetID(), $arTag[3], array($arTag[4]));
             } else {
                 self::RejectRequestToBeMember($GLOBALS["USER"]->GetID(), $arTag[3], array($arTag[4]));
             }
             if (CModule::IncludeModule('im')) {
                 CIMNotify::DeleteBySubTag("SOCNET|REQUEST_GROUP|" . $arTag[2] . "|" . $arTag[3] . "|" . $arTag[4]);
             }
             return true;
         }
     }
 }
コード例 #2
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;
 }
コード例 #3
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;
 }