示例#1
0
 public static function HandleImCallback($module, $tag, $value, $arNotify)
 {
     $userId = CCalendar::GetCurUserId();
     if ($module == "calendar" && $userId) {
         $arTag = explode("|", $tag);
         $eventId = intVal($arTag[2]);
         if ($arTag[0] == "CALENDAR" && $arTag[1] == "INVITE" && $eventId > 0 && $userId) {
             CCalendarEvent::SetMeetingStatus($userId, $eventId, $value == 'Y' ? 'Y' : 'N');
             return $value == 'Y' ? GetMessage('EC_PROP_CONFIRMED_TEXT_Y') : GetMessage('EC_PROP_CONFIRMED_TEXT_N');
         }
     }
 }
示例#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 MeetingStatusSet($arParams = array(), $nav = null, $server = null)
 {
     $userId = CCalendar::GetCurUserId();
     $methodName = "calendar.meeting.status.set";
     $necessaryParams = array('eventId', 'status');
     foreach ($necessaryParams as $param) {
         if (!isset($arParams[$param]) || empty($arParams[$param])) {
             throw new Exception(GetMessage('CAL_REST_PARAM_EXCEPTION', array('#PARAM_NAME#' => $param, '#REST_METHOD#' => $methodName)));
         }
     }
     $arParams['status'] = strtoupper($arParams['status']);
     if (!in_array($arParams['status'], array('Y', 'N', 'Q'))) {
         throw new Exception(GetMessage('CAL_REST_PARAM_ERROR', array('#PARAM_NAME#')));
     }
     CCalendarEvent::SetMeetingStatus($userId, $arParams['eventId'], $arParams['status']);
     return true;
 }
示例#4
0
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
if (!CModule::IncludeModule('calendar') || !(isset($GLOBALS['USER']) && is_object($GLOBALS['USER']) && $GLOBALS['USER']->IsAuthorized())) {
    return;
}
$userId = $GLOBALS['USER']->GetID();
if (isset($_REQUEST['app_calendar_action']) && check_bitrix_sessid()) {
    $APPLICATION->RestartBuffer();
    if ($_REQUEST['app_calendar_action'] == 'change_meeting_status' && $userId == $_REQUEST['user_id']) {
        CCalendarEvent::SetMeetingStatus($userId, intVal($_REQUEST['event_id']), $_REQUEST['status'] == 'Y' ? 'Y' : 'N');
    }
    die;
}
$eventId = intVal($arParams['EVENT_ID']);
$Event = CCalendarEvent::GetList(array('arFilter' => array("ID" => $eventId, "OWNER_ID" => $userId, "DELETED" => "N"), 'parseRecursion' => false, 'fetchAttendees' => true, 'fetchMeetings' => true, 'checkPermissions' => true, 'setDefaultLimit' => false));
if ($Event && is_array($Event[0])) {
    $Event = $Event[0];
    if ($Event['IS_MEETING']) {
        $arAttendees = array('count' => 0, 'Y' => array(), 'N' => array(), 'Q' => array());
        if (!is_array($Event['~ATTENDEES']) || empty($Event['~ATTENDEES'])) {
            $Event['IS_MEETING'] = false;
        }
        if ($Event['IS_MEETING']) {
            foreach ($Event['~ATTENDEES'] as $attendee) {
                $attendee['DISPLAY_NAME'] = CCalendar::GetUserName($attendee);
                $arAttendees[$attendee['STATUS']][] = $attendee;
            }
            $arAttendees['count'] = count($Event['~ATTENDEES']);
示例#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;
 }
示例#6
0
	public static function HandleImCallback($module, $tag, $value, $arNotify)
	{
		global $USER;
		if ($module == "calendar" && is_object($USER) && $USER->IsAuthorized())
		{
			$arTag = explode("|", $tag);
			$eventId = intVal($arTag[2]);
			$userId = $USER->GetID();
			if ($arTag[0] == "CALENDAR" && $arTag[1] == "INVITE" && $eventId > 0 && $userId)
			{
				CCalendarEvent::SetMeetingStatus(
					$userId,
					$eventId,
					$value == 'Y' ? 'Y' : 'N'
				);

				return $value == 'Y' ? GetMessage('EC_PROP_CONFIRMED_TEXT_Y') : GetMessage('EC_PROP_CONFIRMED_TEXT_N');
			}
		}
	}
示例#7
0
 $userId = $GLOBALS["USER"]->GetId();
 $eventId = intVal($_REQUEST['event_id']);
 if ($event_feed_action == 'delete_event') {
     $res = CCalendar::DeleteEvent($eventId);
     if ($res) {
         echo '#EVENT_FEED_RESULT_OK#';
     }
 } else {
     $status = false;
     if ($event_feed_action == 'decline') {
         $status = 'N';
     } elseif ($event_feed_action == 'accept') {
         $status = 'Y';
     }
     if ($status && $eventId) {
         CCalendarEvent::SetMeetingStatus($userId, $eventId, $status);
         $Events = CCalendarEvent::GetList(array('arFilter' => array("ID" => $eventId, "DELETED" => "N"), 'parseRecursion' => false, 'fetchAttendees' => true, 'checkPermissions' => true, 'setDefaultLimit' => false));
         if ($Events && is_array($Events[0]) && $Events[0]['IS_MEETING']) {
             $ajaxParams = $_REQUEST['ajax_params'];
             if ($ajaxParams["MOBILE"] == "Y") {
                 $result = array('ACCEPTED_ATTENDEES_COUNT' => 0, 'DECLINED_ATTENDEES_COUNT' => 0);
                 foreach ($Events[0]['~ATTENDEES'] as $i => $att) {
                     if ($att['STATUS'] == "Y") {
                         $result['ACCEPTED_ATTENDEES_COUNT']++;
                     } elseif ($att['STATUS'] == "N") {
                         $result['DECLINED_ATTENDEES_COUNT']++;
                     }
                 }
                 if ($result['ACCEPTED_ATTENDEES_COUNT'] > 0) {
                     $result['ACCEPTED_ATTENDEES_MESSAGE'] = CCalendar::GetAttendeesMessage($result['ACCEPTED_ATTENDEES_COUNT']);
                 }