Esempio n. 1
0
    }
}
if (!CModule::IncludeModule("calendar") || !class_exists("CCalendar")) {
    return ShowError(GetMessage("EC_CALENDAR_MODULE_NOT_INSTALLED"));
}
// Limits
if (strlen($arParams["INIT_DATE"]) > 0 && strpos($arParams["INIT_DATE"], '.') !== false) {
    $ts = CCalendar::Timestamp($arParams["INIT_DATE"]);
} else {
    $ts = time();
}
$fromLimit = CCalendar::Date($ts, false);
$ts = CCalendar::Timestamp($fromLimit);
$toLimit = CCalendar::Date(mktime(0, 0, 0, date("m", $ts) + $arParams["FUTURE_MONTH_COUNT"], date("d", $ts), date("Y", $ts)), false);
$arResult['ITEMS'] = array();
$arEvents = CCalendar::GetNearestEventsList(array('bCurUserList' => $arParams['B_CUR_USER_LIST'], 'fromLimit' => $fromLimit, 'toLimit' => $toLimit, 'type' => $arParams['CALENDAR_TYPE'], 'sectionId' => $arParams['CALENDAR_SECTION_ID']));
if ($arEvents == 'access_denied') {
    $arResult['ACCESS_DENIED'] = true;
} elseif ($arEvents == 'inactive_feature') {
    $arResult['INACTIVE_FEATURE'] = true;
} elseif (is_array($arEvents)) {
    if (strpos($arParams['DETAIL_URL'], '?') !== FALSE) {
        $arParams['DETAIL_URL'] = substr($arParams['DETAIL_URL'], 0, strpos($arParams['DETAIL_URL'], '?'));
    }
    $arParams['DETAIL_URL'] = str_replace('#user_id#', $curUserId, strtolower($arParams['DETAIL_URL']));
    for ($i = 0, $l = count($arEvents); $i < $l; $i++) {
        $arEvents[$i]['_DETAIL_URL'] = $arParams['DETAIL_URL'] . '?EVENT_ID=' . $arEvents[$i]['ID'] . '&EVENT_DATE=' . $arEvents[$i]['DT_FROM'];
        if ($arEvents[$i]['IS_MEETING'] && $arEvents[$i]['USER_MEETING']['STATUS'] == 'Q') {
            $arEvents[$i]['_ADD_CLASS'] = ' calendar-not-confirmed';
            $arEvents[$i]['_Q_ICON'] = '<span class="calendar-reminder" title="' . GetMessage('EC_NOT_CONFIRMED') . '">[?]</span>';
        } else {
Esempio n. 2
0
// We check it in the mobile menu
CUserOptions::SetOption("mobile", "calendar_first_visit", "N");
// Limits
if (strlen($arParams["INIT_DATE"]) > 0 && strpos($arParams["INIT_DATE"], '.') !== false) {
    $ts = CCalendar::Timestamp($arParams["INIT_DATE"]);
} else {
    $ts = time();
}
$arParams["FUTURE_MONTH_COUNT"] = 2;
$userOffset = CCalendar::GetOffset($arParams['USER_ID']);
$fromLimit = CCalendar::Date($ts + $userOffset, false);
$ts = CCalendar::Timestamp($fromLimit);
$delta = 5184000;
// 86400 * 30 * 2 ~ two month;
$toLimit = CCalendar::Date($ts + $delta, false);
$arEvents = CCalendar::GetNearestEventsList(array('bCurUserList' => true, 'userId' => $arParams['USER_ID'], 'fromLimit' => $fromLimit, 'toLimit' => $toLimit));
if ($arEvents == 'access_denied') {
    $arResult['ACCESS_DENIED'] = true;
} elseif ($arEvents == 'inactive_feature') {
    $arResult['INACTIVE_FEATURE'] = true;
} elseif (is_array($arEvents)) {
    $arSections = array(array("ID" => 'today', "NAME" => CMobile::PrepareStrToJson(GetMessage('EVENTS_GROUP_TODAY'))), array("ID" => 'tomorrow', "NAME" => CMobile::PrepareStrToJson(GetMessage('EVENTS_GROUP_TOMORROW'))), array("ID" => 'later', "NAME" => CMobile::PrepareStrToJson(GetMessage('EVENTS_GROUP_LATE'))));
    $url = '/mobile/calendar/view_event.php';
    $arResult['EVENTS'] = array();
    $oneDay = 86400;
    $todayStartTs = CCalendar::Timestamp(CCalendar::Date(time() + $userOffset, false));
    $todayEndTs = $todayStartTs + $oneDay - 1;
    $tomorrowStartTs = $todayStartTs + $oneDay;
    $tomorrowEndTs = $tomorrowStartTs + $oneDay - 1;
    $today = CCalendar::Date(time(), false);
    $tomorrow = CCalendar::Date(time() + 86400, false);
Esempio n. 3
0
 public static function EventGetNearest($arParams = array(), $nav = null, $server = null)
 {
     $userId = CCalendar::GetCurUserId();
     $methodName = "calendar.event.get.nearest";
     if (!isset($arParams['type'], $arParams['ownerId']) || $arParams['forCurrentUser']) {
         $arParams['type'] = 'user';
         $arParams['ownerId'] = $userId;
         $arParams['forCurrentUser'] = true;
     }
     if (!isset($arParams['days'])) {
         $arParams['days'] = 60;
     }
     // Limits
     $ts = time();
     $fromLimit = CCalendar::Date($ts, false);
     $toLimit = CCalendar::Date($ts + CCalendar::DAY_LENGTH * $arParams['days'], false);
     $arEvents = CCalendar::GetNearestEventsList(array('bCurUserList' => !!$arParams['forCurrentUser'], 'fromLimit' => $fromLimit, 'toLimit' => $toLimit, 'type' => $arParams['CALENDAR_TYPE'], 'sectionId' => $arParams['CALENDAR_SECTION_ID']));
     if ($arEvents == 'access_denied' || $arEvents == 'inactive_feature') {
         throw new Exception(GetMessage('CAL_REST_ACCESS_DENIED'));
     } elseif (is_array($arEvents)) {
         if (isset($arParams['detailUrl'])) {
             if (strpos($arParams['detailUrl'], '?') !== FALSE) {
                 $arParams['detailUrl'] = substr($arParams['detailUrl'], 0, strpos($arParams['detailUrl'], '?'));
             }
             $arParams['detailUrl'] = str_replace('#user_id#', $userId, strtolower($arParams['detailUrl']));
             for ($i = 0, $l = count($arEvents); $i < $l; $i++) {
                 $arEvents[$i]['~detailUrl'] = $arParams['detailUrl'] . '?EVENT_ID=' . $arEvents[$i]['ID'] . '&EVENT_DATE=' . $arEvents[$i]['DT_FROM'];
             }
         }
         if (isset($arParams['maxEventsCount'])) {
             array_splice($arEvents, intVal($arParams['maxEventsCount']));
         }
     }
     return $arEvents;
 }