Ejemplo n.º 1
0
 $today = CCalendar::Date(time(), false);
 $tomorrow = CCalendar::Date(time() + 86400, false);
 $bToday = false;
 $bTomorrow = false;
 $bLater = false;
 $use_sections = "YES";
 $iconEvent = '/bitrix/templates/mobile_app/images/calendar/event.png';
 $iconMeeting = '/bitrix/templates/mobile_app/images/calendar/meeting.png';
 $iconInviting = '/bitrix/templates/mobile_app/images/calendar/meeting-q.png';
 $dateFormat = GetMessage('MB_CAL_EVENT_DATE_FORMAT');
 $timeFormat = IsAmPmMode() ? GetMessage('MB_CAL_EVENT_TIME_FORMAT_AMPM') : GetMessage('MB_CAL_EVENT_TIME_FORMAT');
 $count = count($arEvents);
 for ($i = 0; $i < $count; $i++) {
     $event = $arEvents[$i];
     $event['DT_FROM_TS'] = CCalendar::_fixTimestamp($event['DT_FROM_TS']);
     $event['DT_TO_TS'] = CCalendar::_fixTimestamp($event['DT_TO_TS']);
     $item = array("ID" => $event['ID'], "NAME" => CMobile::PrepareStrToJson($event['NAME']), "URL" => $url . "?event_id=" . $event['ID']);
     if ($event['IS_MEETING'] && $event['USER_MEETING']['STATUS'] == 'N') {
         continue;
     }
     if ($event['IS_MEETING']) {
         $item["IMAGE"] = $event['USER_MEETING']['STATUS'] == 'Q' ? $iconInviting : $iconMeeting;
     } else {
         $item["IMAGE"] = $iconEvent;
     }
     $bOneDay = $event['DT_LENGTH'] == 86400;
     // One full day
     $bDuringOneDay = !$bOneDay && FormatDate('d.m.Y', $event['DT_FROM_TS']) === FormatDate('d.m.Y', $event['DT_TO_TS']);
     $fromToMess = '';
     // It's event for today
     if ($event['DT_FROM_TS'] <= $todayEndTs && $event['DT_TO_TS'] >= $todayStartTs) {
Ejemplo n.º 2
0
 public static function SendMessage($Params)
 {
     if (!CModule::IncludeModule("im")) {
         return false;
     }
     $mode = $Params['mode'];
     // invite|change|cancel|accept|decline
     $Params["meetingText"] = isset($Params["meetingText"]) && is_string($Params["meetingText"]) ? trim($Params["meetingText"]) : '';
     $fromUser = intVal($Params["userId"]);
     $toUser = intVal($Params["guestId"]);
     if (!$fromUser || !$toUser || $toUser == $fromUser) {
         return false;
     }
     $fromTs = CCalendar::Timestamp($Params["from"]);
     $toTs = CCalendar::Timestamp($Params["to"]);
     $fromTs = CCalendar::_fixTimestamp($fromTs);
     $toTs = CCalendar::_fixTimestamp($toTs);
     $arNotifyFields = array('EMAIL_TEMPLATE' => "CALENDAR_INVITATION", 'NOTIFY_MODULE' => "calendar");
     if ($mode == 'accept' || $mode == 'decline') {
         $arNotifyFields['FROM_USER_ID'] = $toUser;
         $arNotifyFields['TO_USER_ID'] = $fromUser;
         if (date('H:i', $fromTs) != '00:00' || date('H:i', $toTs) != '00:00') {
             $Params["from"] = CCalendar::Date($fromTs + CCalendar::GetOffset($fromUser), true, true, true);
             $Params["to"] = CCalendar::Date($toTs + CCalendar::GetOffset($fromUser), true, true, true);
         }
     } else {
         $arNotifyFields['FROM_USER_ID'] = $fromUser;
         $arNotifyFields['TO_USER_ID'] = $toUser;
         if (date('H:i', $fromTs) != '00:00' || date('H:i', $toTs) != '00:00') {
             $Params["from"] = CCalendar::Date($fromTs + CCalendar::GetOffset($toUser), true, true, true);
             $Params["to"] = CCalendar::Date($toTs + CCalendar::GetOffset($toUser), true, true, true);
         }
     }
     $Params["from"] = CCalendar::CutZeroTime($Params["from"]);
     $Params["to"] = CCalendar::CutZeroTime($Params["to"]);
     // If it's event for all day - add one day to timestamp
     if (date("His", $toTs) == '000000') {
         $toTs += self::GetDayLen();
     }
     // Don't send messages for events in the past
     if ($toTs < time()) {
         return false;
     }
     $rs = CUser::GetList($by = "id", $order = "asc", array("ID_EQUAL_EXACT" => $toUser, "ACTIVE" => "Y"));
     if (!$rs->Fetch()) {
         return false;
     }
     $eventId = intVal($Params["eventId"]);
     $calendarUrl = self::GetPathForCalendarEx($arNotifyFields['TO_USER_ID']);
     $calendarUrlEV = $calendarUrl . (strpos($calendarUrl, "?") === false ? '?' : '&') . 'EVENT_ID=' . $eventId;
     $curPath = CCalendar::GetPath();
     $titleWithLink = $Params["name"];
     if ($curPath && $eventId) {
         $curPath = CHTTP::urlDeleteParams($curPath, array("action", "sessid", "bx_event_calendar_request", "EVENT_ID"));
         $curPath = CHTTP::urlAddParams($curPath, array('EVENT_ID' => $eventId));
         $titleWithLink = "[url=" . $curPath . "]" . $Params["name"] . "[/url]";
     }
     $arNotifyFields = array('FROM_USER_ID' => $fromUser, 'TO_USER_ID' => $toUser, 'EMAIL_TEMPLATE' => "CALENDAR_INVITATION", 'NOTIFY_MODULE' => "calendar");
     switch ($mode) {
         case 'invite':
             $arNotifyFields['NOTIFY_EVENT'] = "invite";
             $arNotifyFields['NOTIFY_TYPE'] = IM_NOTIFY_CONFIRM;
             $arNotifyFields['NOTIFY_TAG'] = "CALENDAR|INVITE|" . $eventId . "|" . $toUser;
             $arNotifyFields['NOTIFY_SUB_TAG'] = "CALENDAR|INVITE|" . $eventId;
             $arNotifyFields['MESSAGE'] = GetMessage('EC_MESS_INVITE_SITE', array('#TITLE#' => $Params["name"], '#ACTIVE_FROM#' => $Params["from"]));
             $arNotifyFields['MESSAGE_OUT'] = GetMessage('EC_MESS_INVITE', array('#OWNER_NAME#' => CCalendar::GetUserName($Params['userId']), '#TITLE#' => $Params["name"], '#ACTIVE_FROM#' => $Params["from"]));
             if ($Params['location'] != "") {
                 $arNotifyFields['MESSAGE'] .= "\n\n" . GetMessage('EC_LOCATION') . ': ' . $Params['location'];
                 $arNotifyFields['MESSAGE_OUT'] .= "\n\n" . GetMessage('EC_LOCATION') . ': ' . $Params['location'];
             }
             if ($Params["meetingText"] != "") {
                 $arNotifyFields['MESSAGE'] .= "\n\n" . GetMessage('EC_MESS_MEETING_TEXT', array('#MEETING_TEXT#' => $Params["meetingText"]));
                 $arNotifyFields['MESSAGE_OUT'] .= "\n\n" . GetMessage('EC_MESS_MEETING_TEXT', array('#MEETING_TEXT#' => $Params["meetingText"]));
             }
             $arNotifyFields['MESSAGE'] .= "\n\n" . GetMessage('EC_MESS_INVITE_DETAILS_SITE', array('#LINK#' => $calendarUrlEV));
             $arNotifyFields['NOTIFY_BUTTONS'] = array(array('TITLE' => GetMessage('EC_MESS_INVITE_CONF_Y_SITE'), 'VALUE' => 'Y', 'TYPE' => 'accept'), array('TITLE' => GetMessage('EC_MESS_INVITE_CONF_N_SITE'), 'VALUE' => 'N', 'TYPE' => 'cancel'));
             $arNotifyFields['MESSAGE_OUT'] .= "\n\n" . GetMessage('EC_MESS_INVITE_CONF_Y', array('#LINK#' => $calendarUrlEV . '&CONFIRM=Y'));
             $arNotifyFields['MESSAGE_OUT'] .= "\n" . GetMessage('EC_MESS_INVITE_CONF_N', array('#LINK#' => $calendarUrlEV . '&CONFIRM=N'));
             $arNotifyFields['MESSAGE_OUT'] .= "\n\n" . GetMessage('EC_MESS_INVITE_DETAILS', array('#LINK#' => $calendarUrlEV));
             $arNotifyFields['TITLE'] = GetMessage('EC_MESS_INVITE_TITLE', array('#OWNER_NAME#' => CCalendar::GetUserName($Params['userId']), '#TITLE#' => $Params["name"]));
             break;
         case 'change':
             $arNotifyFields['NOTIFY_EVENT'] = "change";
             $arNotifyFields['NOTIFY_TYPE'] = IM_NOTIFY_CONFIRM;
             $arNotifyFields['NOTIFY_TAG'] = "CALENDAR|INVITE|" . $eventId . "|" . $toUser;
             $arNotifyFields['NOTIFY_SUB_TAG'] = "CALENDAR|INVITE|" . $eventId;
             $arNotifyFields['MESSAGE'] = GetMessage('EC_MESS_INVITE_CHANGED_SITE', array('#TITLE#' => $Params["name"], '#ACTIVE_FROM#' => $Params["from"]));
             $arNotifyFields['MESSAGE_OUT'] = GetMessage('EC_MESS_INVITE_CHANGED', array('#OWNER_NAME#' => CCalendar::GetUserName($Params['userId']), '#TITLE#' => $Params["name"], '#ACTIVE_FROM#' => $Params["from"]));
             if ($Params["meetingText"] != "") {
                 $arNotifyFields['MESSAGE'] .= "\n\n" . GetMessage('EC_MESS_MEETING_TEXT', array('#MEETING_TEXT#' => $Params["meetingText"]));
                 $arNotifyFields['MESSAGE_OUT'] .= "\n\n" . GetMessage('EC_MESS_MEETING_TEXT', array('#MEETING_TEXT#' => $Params["meetingText"]));
             }
             $arNotifyFields['MESSAGE'] .= "\n\n" . GetMessage('EC_MESS_INVITE_DETAILS_SITE', array('#LINK#' => $calendarUrlEV));
             $arNotifyFields['NOTIFY_BUTTONS'] = array(array('TITLE' => GetMessage('EC_MESS_INVITE_CONF_Y_SITE'), 'VALUE' => 'Y', 'TYPE' => 'accept'), array('TITLE' => GetMessage('EC_MESS_INVITE_CONF_N_SITE'), 'VALUE' => 'N', 'TYPE' => 'cancel'));
             $arNotifyFields['MESSAGE_OUT'] .= "\n\n" . GetMessage('EC_MESS_INVITE_CONF_Y', array('#LINK#' => $calendarUrlEV . '&CONFIRM=Y'));
             $arNotifyFields['MESSAGE_OUT'] .= "\n" . GetMessage('EC_MESS_INVITE_CONF_N', array('#LINK#' => $calendarUrlEV . '&CONFIRM=N'));
             $arNotifyFields['MESSAGE_OUT'] .= "\n\n" . GetMessage('EC_MESS_INVITE_DETAILS', array('#LINK#' => $calendarUrlEV));
             $arNotifyFields['TITLE'] = GetMessage('EC_MESS_INVITE_CHANGED_TITLE', array('#TITLE#' => $Params["name"]));
             break;
         case 'change_notify':
             $arNotifyFields['NOTIFY_EVENT'] = "change";
             $arNotifyFields['NOTIFY_TAG'] = "CALENDAR|INVITE|" . $eventId . "|" . $toUser;
             $arNotifyFields['NOTIFY_SUB_TAG'] = "CALENDAR|INVITE|" . $eventId;
             $arNotifyFields['MESSAGE'] = GetMessage('EC_MESS_INVITE_CHANGED_SITE', array('#TITLE#' => "[url=" . $calendarUrlEV . "]" . $Params["name"] . "[/url]", '#ACTIVE_FROM#' => $Params["from"]));
             $arNotifyFields['MESSAGE_OUT'] = GetMessage('EC_MESS_INVITE_CHANGED', array('#OWNER_NAME#' => CCalendar::GetUserName($Params['userId']), '#TITLE#' => $Params["name"], '#ACTIVE_FROM#' => $Params["from"]));
             if ($Params["meetingText"] != "") {
                 $arNotifyFields['MESSAGE'] .= "\n\n" . GetMessage('EC_MESS_MEETING_TEXT', array('#MEETING_TEXT#' => $Params["meetingText"]));
                 $arNotifyFields['MESSAGE_OUT'] .= "\n\n" . GetMessage('EC_MESS_MEETING_TEXT', array('#MEETING_TEXT#' => $Params["meetingText"]));
             }
             $arNotifyFields['MESSAGE'] .= "\n\n" . GetMessage('EC_MESS_INVITE_DETAILS_SITE', array('#LINK#' => $calendarUrlEV));
             $arNotifyFields['MESSAGE_OUT'] .= "\n\n" . GetMessage('EC_MESS_INVITE_DETAILS', array('#LINK#' => $calendarUrlEV));
             $arNotifyFields['TITLE'] = GetMessage('EC_MESS_INVITE_CHANGED_TITLE', array('#TITLE#' => $Params["name"]));
             break;
         case 'cancel':
             $arNotifyFields['NOTIFY_EVENT'] = "change";
             $arNotifyFields['NOTIFY_TAG'] = "CALENDAR|INVITE|" . $eventId . "|" . $toUser . "|cancel";
             $arNotifyFields['NOTIFY_SUB_TAG'] = "CALENDAR|INVITE|" . $eventId;
             $arNotifyFields['MESSAGE'] = GetMessage('EC_MESS_INVITE_CANCEL_SITE', array('#TITLE#' => $Params["name"], '#ACTIVE_FROM#' => $Params["from"]));
             $arNotifyFields['MESSAGE_OUT'] = GetMessage('EC_MESS_INVITE_CANCEL', array('#OWNER_NAME#' => CCalendar::GetUserName($Params['userId']), '#TITLE#' => $Params["name"], '#ACTIVE_FROM#' => $Params["from"]));
             $arNotifyFields['MESSAGE'] .= "\n\n" . GetMessage('EC_MESS_VIEW_OWN_CALENDAR', array('#LINK#' => $calendarUrl));
             $arNotifyFields['MESSAGE_OUT'] .= "\n\n" . GetMessage('EC_MESS_VIEW_OWN_CALENDAR_OUT', array('#LINK#' => $calendarUrl));
             $arNotifyFields['TITLE'] = GetMessage('EC_MESS_INVITE_CANCEL_TITLE', array('#TITLE#' => $Params["name"]));
             break;
         case 'accept':
         case 'decline':
             $arNotifyFields['NOTIFY_EVENT'] = "info";
             $arNotifyFields['FROM_USER_ID'] = intVal($Params["guestId"]);
             $arNotifyFields['TO_USER_ID'] = intVal($Params["userId"]);
             $arNotifyFields['NOTIFY_TAG'] = "CALENDAR|INVITE|" . $eventId . "|" . $mode;
             $arNotifyFields['NOTIFY_SUB_TAG'] = "CALENDAR|INVITE|" . $eventId;
             $arNotifyFields['MESSAGE'] = GetMessage($mode == 'accept' ? 'EC_MESS_INVITE_ACCEPTED_SITE' : 'EC_MESS_INVITE_DECLINED_SITE', array('#TITLE#' => "[url=" . $calendarUrlEV . "]" . $Params["name"] . "[/url]", '#ACTIVE_FROM#' => $Params["from"]));
             $arNotifyFields['MESSAGE_OUT'] = GetMessage($mode == 'accept' ? 'EC_MESS_INVITE_ACCEPTED' : 'EC_MESS_INVITE_DECLINED', array('#GUEST_NAME#' => CCalendar::GetUserName($Params['guestId']), '#TITLE#' => $Params["name"], '#ACTIVE_FROM#' => $Params["from"]));
             if ($Params["comment"] != "") {
                 $arNotifyFields['MESSAGE'] .= "\n\n" . GetMessage('EC_MESS_INVITE_ACC_COMMENT', array('#COMMENT#' => $Params["comment"]));
                 $arNotifyFields['MESSAGE_OUT'] .= "\n\n" . GetMessage('EC_MESS_INVITE_ACC_COMMENT', array('#COMMENT#' => $Params["comment"]));
             }
             $arNotifyFields['MESSAGE_OUT'] .= "\n\n" . GetMessage('EC_MESS_INVITE_DETAILS', array('#LINK#' => $calendarUrlEV));
             break;
     }
     CIMNotify::Add($arNotifyFields);
     foreach (GetModuleEvents("calendar", "OnSendInvitationMessage", true) as $arEvent) {
         ExecuteModuleEventEx($arEvent, array($Params));
     }
 }
Ejemplo n.º 3
0
     $this->IncludeComponentTemplate();
     return;
 }
 $APPLICATION->RestartBuffer();
 if ($_REQUEST['app_calendar_action'] == 'save_event' && check_bitrix_sessid()) {
     // Save event info
     $type = 'user';
     $ownerId = $userId;
     $id = intVal($_POST['event_id']);
     $sectId = intVal($_POST['sect_id']);
     $newMeeting = $_POST['new_meeting'] == 'Y';
     $from_ts = $_POST['from_ts'];
     $to_ts = $_POST['to_ts'];
     if (isset($_POST['skip_time']) && $_POST['skip_time'] == 'Y') {
         $from_ts = CCalendar::_fixTimestamp($from_ts);
         $to_ts = CCalendar::_fixTimestamp($to_ts);
     }
     $arFields = array("ID" => $id, "CAL_TYPE" => $_POST['cal_type'], "OWNER_ID" => $_POST['owner_id'], "DT_FROM_TS" => $from_ts, "DT_TO_TS" => $to_ts, "SKIP_TIME" => isset($_POST['skip_time']) && $_POST['skip_time'] == 'Y', 'NAME' => CMobile::ConvertFromUtf(trim($_POST['name'])), 'DESCRIPTION' => CMobile::ConvertFromUtf(trim($_POST['desc'])), 'SECTIONS' => array($sectId), 'ACCESSIBILITY' => $_POST['accessibility'], 'IMPORTANCE' => $_POST['importance'], 'PRIVATE_EVENT' => $_POST['private_event'] == "Y", "REMIND" => $_POST['remind'], 'LOCATION' => array(), "IS_MEETING" => !empty($_POST['attendees']));
     // LOCATION
     if (is_array($_POST['location']) && !empty($_POST['location'])) {
         $arFields['LOCATION'] = $_POST['location'];
         $arFields['LOCATION']['CHANGED'] = $arFields['LOCATION']['CHANGED'] == 'Y';
         $arFields['LOCATION']['NEW'] = CMobile::ConvertFromUtf($arFields['LOCATION']['NEW']);
         $arFields['LOCATION']['OLD'] = CMobile::ConvertFromUtf($arFields['LOCATION']['OLD']);
         if ($arFields['LOCATION']['CHANGED']) {
             $loc = CCalendar::UnParseTextLocation($arFields['LOCATION']['NEW']);
             $arFields['LOCATION']['NEW'] = $loc['NEW'];
         }
     }
     if (isset($_POST['rrule']) && $_POST['rrule'] == '') {
         $arFields['RRULE'] = '';