Exemplo n.º 1
0
            if ($event['RRULE']['INTERVAL'] == 1) {
                $repeatHTML = GetMessage('EC_RRULE_EVERY_MONTH');
            } else {
                $repeatHTML = GetMessage('EC_RRULE_EVERY_MONTH_1', array('#MONTH#' => $event['RRULE']['INTERVAL']));
            }
            break;
        case 'YEARLY':
            if ($event['RRULE']['INTERVAL'] == 1) {
                $repeatHTML = GetMessage('EC_RRULE_EVERY_YEAR', array('#DAY#' => $event['FROM_MONTH_DAY'], '#MONTH#' => $event['FROM_MONTH']));
            } else {
                $repeatHTML = GetMessage('EC_RRULE_EVERY_YEAR_1', array('#YEAR#' => $event['RRULE']['INTERVAL'], '#DAY#' => $event['FROM_MONTH_DAY'], '#MONTH#' => $event['FROM_MONTH']));
            }
            break;
    }
    $repeatHTML .= '<br>' . GetMessage('EC_RRULE_FROM', array('#FROM_DATE#' => CCalendar::Date(CCalendar::Timestamp($event['~DATE_FROM']), false)));
    if ($event['RRULE']['UNTIL'] != CCalendar::GetMaxDate()) {
        $repeatHTML .= ' ' . GetMessage('EC_RRULE_UNTIL', array('#UNTIL_DATE#' => CCalendar::Date(CCalendar::Timestamp($event['RRULE']['UNTIL']), false)));
    }
    ?>
			<tr>
				<td class="bx-cal-view-text-cell-l"><?php 
    echo GetMessage('EC_T_REPEAT');
    ?>
:</td>
				<td class="bx-cal-view-text-cell-r"><?php 
    echo $repeatHTML;
    ?>
</td>
			</tr>
		<?php 
}
Exemplo n.º 2
0
        case 'MONTHLY':
            if ($RRULE['INTERVAL'] == 1) {
                $repeatHTML = GetMessage('EC_RRULE_EVERY_MONTH');
            } else {
                $repeatHTML = GetMessage('EC_RRULE_EVERY_MONTH_1', array('#MONTH#' => $RRULE['INTERVAL']));
            }
            break;
        case 'YEARLY':
            if ($RRULE['INTERVAL'] == 1) {
                $repeatHTML = GetMessage('EC_RRULE_EVERY_YEAR', array('#DAY#' => 0, '#MONTH#' => 0));
            } else {
                $repeatHTML = GetMessage('EC_RRULE_EVERY_YEAR_1', array('#YEAR#' => $RRULE['INTERVAL'], '#DAY#' => 0, '#MONTH#' => 0));
            }
            break;
    }
    if ($RRULE['UNTIL'] != '' && $RRULE['UNTIL'] != CCalendar::GetMaxDate()) {
        $repeatHTML .= '<br>' . GetMessage('EC_RRULE_UNTIL', array('#UNTIL_DATE#' => CCalendar::Date(CCalendar::Timestamp($RRULE['UNTIL']))));
    }
    ?>
			<tr>
				<td class="feed-calendar-view-text-cell-l"><?php 
    echo GetMessage('EC_T_REPEAT');
    ?>
:</td>
				<td class="feed-calendar-view-text-cell-r"><?php 
    echo $repeatHTML;
    ?>
</td>
			</tr>
			<?php 
}
Exemplo n.º 3
0
 function UpdateReminders($Params = array())
 {
     $eventId = intVal($Params['id']);
     $reminders = $Params['reminders'];
     $arFields = $Params['arFields'];
     $userId = $Params['userId'];
     $bNew = $Params['bNew'];
     $path = $Params['path'];
     $path = CHTTP::urlDeleteParams($path, array("action", "sessid", "bx_event_calendar_request", "EVENT_ID"));
     $viewPath = CHTTP::urlAddParams($path, array('EVENT_ID' => $eventId));
     $remAgentParams = array('eventId' => $eventId, 'userId' => $arFields["CREATED_BY"], 'viewPath' => $viewPath, 'calendarType' => $arFields["CAL_TYPE"], 'ownerId' => $arFields["OWNER_ID"]);
     // 1. clean reminders
     if (!$bNew) {
         // if we edit event here can be "old" reminders
         CCalendar::RemoveAgent($remAgentParams);
     }
     // 2. Set new reminders
     $startTs = $arFields['DATE_FROM_TS_UTC'];
     // Start of the event in UTC
     $agentTime = 0;
     foreach ($reminders as $reminder) {
         $delta = intVal($reminder['count']) * 60;
         //Minute
         if ($reminder['type'] == 'hour') {
             $delta = $delta * 60;
         } elseif ($reminder['type'] == 'day') {
             $delta = $delta * 60 * 24;
         }
         //Day
         // $startTs - UTC timestamp;  date('Z', $startTs) - offset of the server
         $agentTime = $startTs + date('Z', $startTs);
         if ($agentTime - $delta >= time() - 60 * 5) {
             CCalendar::AddAgent(CCalendar::Date($agentTime - $delta), $remAgentParams);
         } elseif ($arFields['RRULE'] != '') {
             $arEvents = CCalendarEvent::GetList(array('arFilter' => array("ID" => $eventId, "DELETED" => "N", "FROM_LIMIT" => CCalendar::Date(time() - 3600, false), "TO_LIMIT" => CCalendar::GetMaxDate()), 'userId' => $userId, 'parseRecursion' => true, 'maxInstanceCount' => 2, 'preciseLimits' => true, 'fetchAttendees' => true, 'checkPermissions' => false, 'setDefaultLimit' => false));
             if ($arEvents && is_array($arEvents[0])) {
                 $nextEvent = $arEvents[0];
                 $startTs = CCalendar::Timestamp($nextEvent['DATE_FROM'], false, $arEvents[0]["DT_SKIP_TIME"] !== 'Y');
                 if ($nextEvent["DT_SKIP_TIME"] == 'N' && $nextEvent["TZ_FROM"]) {
                     $startTs = $startTs - CCalendar::GetTimezoneOffset($nextEvent["TZ_FROM"], $startTs);
                     // UTC timestamp
                 }
                 if ($startTs + date("Z", $startTs) < time() - 60 * 5 && $arEvents[1]) {
                     $nextEvent = $arEvents[1];
                 }
                 $startTs = CCalendar::Timestamp($nextEvent['DATE_FROM'], false, $arEvents[0]["DT_SKIP_TIME"] !== 'Y');
                 if ($nextEvent["DT_SKIP_TIME"] == 'N' && $nextEvent["TZ_FROM"]) {
                     $startTs = $startTs - CCalendar::GetTimezoneOffset($nextEvent["TZ_FROM"], $startTs);
                     // UTC timestamp
                 }
                 $reminder = $nextEvent['REMIND'][0];
                 if ($reminder) {
                     $delta = intVal($reminder['count']) * 60;
                     //Minute
                     if ($reminder['type'] == 'hour') {
                         $delta = $delta * 60;
                     } elseif ($reminder['type'] == 'day') {
                         $delta = $delta * 60 * 24;
                     }
                     //Day
                     // $startTs - UTC timestamp;  date("Z", $startTs) - offset of the server
                     $agentTime = $startTs + date("Z", $startTs);
                     if ($agentTime - $delta >= time() - 60 * 5) {
                         // Inaccuracy - 5 min
                         CCalendar::AddAgent(CCalendar::Date($agentTime - $delta), $remAgentParams);
                     }
                 }
             }
         }
     }
 }