本文整理汇总了PHP中CCalendar::GetOffset方法的典型用法代码示例。如果您正苦于以下问题:PHP CCalendar::GetOffset方法的具体用法?PHP CCalendar::GetOffset怎么用?PHP CCalendar::GetOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCalendar
的用法示例。
在下文中一共展示了CCalendar::GetOffset方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UpdateReminders
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' => $userId, '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['DT_FROM_TS'];
$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
$agentTime = $startTs + CCalendar::GetOffset($userId);
if ($startTs - $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::Date(2145938400, false)), 'userId' => $userId, 'parseRecursion' => true, 'maxInstanceCount' => 2, 'preciseLimits' => true, 'fetchAttendees' => true, 'checkPermissions' => false, 'setDefaultLimit' => false));
if ($arEvents && is_array($arEvents[0])) {
$nextEvent = $arEvents[0];
if ($arEvents[0]['DT_FROM_TS'] < time() - 60 * 5 && $arEvents[1]) {
$nextEvent = $arEvents[1];
}
$startTs = $nextEvent['DT_FROM_TS'];
$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
$agentTime = $startTs - CCalendar::GetOffset($userId);
if ($startTs - $delta >= time() - 60 * 5) {
// Inaccuracy - 5 min
CCalendar::AddAgent(CCalendar::Date($agentTime - $delta), $remAgentParams);
}
}
}
}
}
// reminders for attendees
if ($arFields['IS_MEETING']) {
foreach ($arFields['ATTENDEES'] as $attendeeId) {
if ($attendeeId == $userId) {
continue;
}
$viewPath = CCalendar::GetPath('user', $attendeeId, true);
$remAgentParams = array('eventId' => $eventId, 'userId' => $attendeeId, 'viewPath' => $viewPath, 'calendarType' => $arFields["CAL_TYPE"], 'ownerId' => $arFields["OWNER_ID"]);
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
if ($startTs - $delta >= time() - 60 * 5) {
// Inaccuracy - 5 min
CCalendar::AddAgent(CCalendar::Date($agentTime - $delta), $remAgentParams);
}
}
}
}
}
示例2: ModifyEvent
public static function ModifyEvent($calendarId, $arFields)
{
list($sectionId, $entityType, $entityId) = $calendarId;
$userId = $entityType == 'user' ? $entityId : 0;
self::$silentErrorMode = true;
CCalendar::SetOffset(false, CCalendar::GetOffset($userId));
$entityType = strtolower($entityType);
$eventId = isset($arFields["ID"]) && intval($arFields["ID"]) > 0 ? intval($arFields["ID"]) : 0;
$arNewFields = array("DAV_XML_ID" => $arFields['XML_ID'], "CAL_DAV_LABEL" => isset($arFields['PROPERTY_BXDAVCD_LABEL']) && strlen($arFields['PROPERTY_BXDAVCD_LABEL']) > 0 ? $arFields['PROPERTY_BXDAVCD_LABEL'] : '', "DAV_EXCH_LABEL" => isset($arFields['PROPERTY_BXDAVEX_LABEL']) && strlen($arFields['PROPERTY_BXDAVEX_LABEL']) > 0 ? $arFields['PROPERTY_BXDAVEX_LABEL'] : '', "ID" => $eventId, 'NAME' => $arFields["NAME"] ? $arFields["NAME"] : GetMessage('EC_NONAME_EVENT'), 'CAL_TYPE' => $entityType, 'OWNER_ID' => $entityId, 'DESCRIPTION' => isset($arFields['DESCRIPTION']) ? $arFields['DESCRIPTION'] : '', 'SECTIONS' => $sectionId, 'ACCESSIBILITY' => isset($arFields['ACCESSIBILITY']) ? $arFields['ACCESSIBILITY'] : 'busy', 'IMPORTANCE' => isset($arFields['IMPORTANCE']) ? $arFields['IMPORTANCE'] : 'normal', "REMIND" => is_array($arFields['REMIND']) ? $arFields['REMIND'] : array(), "RRULE" => is_array($arFields['RRULE']) ? is_array($arFields['RRULE']) : array(), "VERSION" => isset($arFields['VERSION']) ? intVal($arFields['VERSION']) : 1, "PRIVATE_EVENT" => !!$arFields['PRIVATE_EVENT']);
$bServerTime = false;
if (isset($arFields['DT_FROM_TS'], $arFields['DT_TO_TS'])) {
$arNewFields["DT_FROM_TS"] = $arFields['DT_FROM_TS'];
$arNewFields["DT_TO_TS"] = $arFields['DT_TO_TS'];
$arNewFields["SKIP_TIME"] = $arFields['SKIP_TIME'];
$bServerTime = true;
} elseif (isset($arFields['ACTIVE_FROM'], $arFields['ACTIVE_TO'])) {
$arNewFields["DT_FROM"] = $arFields['ACTIVE_FROM'];
$arNewFields["DT_TO"] = $arFields['ACTIVE_TO'];
}
if (!empty($arFields['PROPERTY_REMIND_SETTINGS'])) {
$ar = explode("_", $arFields["PROPERTY_REMIND_SETTINGS"]);
if (count($ar) == 2) {
$arNewFields["REMIND"][] = array('type' => $ar[1], 'count' => floatVal($ar[0]));
}
}
if (!empty($arFields['PROPERTY_ACCESSIBILITY'])) {
$arNewFields["ACCESSIBILITY"] = $arFields['PROPERTY_ACCESSIBILITY'];
}
if (!empty($arFields['PROPERTY_IMPORTANCE'])) {
$arNewFields["IMPORTANCE"] = $arFields['PROPERTY_IMPORTANCE'];
}
if (!empty($arFields['PROPERTY_LOCATION'])) {
$arNewFields["LOCATION"] = CCalendar::UnParseTextLocation($arFields['PROPERTY_LOCATION']);
}
if (!empty($arFields['DETAIL_TEXT'])) {
$arNewFields["DESCRIPTION"] = $arFields['DETAIL_TEXT'];
}
$arNewFields["DESCRIPTION"] = CCalendar::ClearExchangeHtml($arNewFields["DESCRIPTION"]);
if (isset($arFields["PROPERTY_PERIOD_TYPE"]) && in_array($arFields["PROPERTY_PERIOD_TYPE"], array("DAILY", "WEEKLY", "MONTHLY", "YEARLY"))) {
$arNewFields['RRULE']['FREQ'] = $arFields["PROPERTY_PERIOD_TYPE"];
$arNewFields['RRULE']['INTERVAL'] = $arFields["PROPERTY_PERIOD_COUNT"];
if (!isset($arNewFields['DT_LENGTH']) && !empty($arFields['PROPERTY_EVENT_LENGTH'])) {
$arNewFields['DT_LENGTH'] = intval($arFields['PROPERTY_EVENT_LENGTH']);
} else {
$arNewFields['DT_LENGTH'] = $arFields['DT_TO_TS'] - $arFields['DT_FROM_TS'];
//$arNewFields['DT_LENGTH'] = self::GetDayLen();
}
if ($arNewFields['RRULE']['FREQ'] == "WEEKLY" && !empty($arFields['PROPERTY_PERIOD_ADDITIONAL'])) {
$arNewFields['RRULE']['BYDAY'] = array();
$bydays = explode(',', $arFields['PROPERTY_PERIOD_ADDITIONAL']);
foreach ($bydays as $day) {
$day = CCalendar::WeekDayByInd($day, false);
if ($day !== false) {
$arNewFields['RRULE']['BYDAY'][] = $day;
}
}
$arNewFields['RRULE']['BYDAY'] = implode(',', $arNewFields['RRULE']['BYDAY']);
}
if (isset($arFields['ACTIVE_TO'])) {
$arNewFields['RRULE']['UNTIL'] = $arFields['ACTIVE_TO'];
} else {
$arNewFields['RRULE']['UNTIL'] = $arFields['DT_TO_TS'];
}
}
$eventId = CCalendar::SaveEvent(array('arFields' => $arNewFields, 'userId' => $userId, 'bAffectToDav' => false, 'bSilentAccessMeeting' => true, 'bServerTime' => $bServerTime));
self::$silentErrorMode = false;
return $eventId;
}
示例3: header
die;
}
header("Content-Type: application/x-javascript");
if (!CModule::IncludeModule('calendar') || !(isset($GLOBALS['USER']) && is_object($GLOBALS['USER']) && $GLOBALS['USER']->IsAuthorized()) || $GLOBALS['USER']->GetId() != $arParams['USER_ID']) {
return array('status' => 'failed');
}
// 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;
示例4: __getRow
public function __getRow($event, $listName, &$last_change)
{
$arStatusValues = $this->arStatusValues;
$arPriorityValues = $this->arPriorityValues;
$first_week_day = COption::GetOptionString('calendar', 'week_start', 'MO');
$first_week_day = strtolower($first_week_day);
$change = MakeTimeStamp($event['TIMESTAMP_X']);
if ($last_change < $change) {
$last_change = $change;
}
$bRecurrent = isset($event['RRULE']) && $event['RRULE'] != "" ? 1 : 0;
$rrule = CCalendarEvent::ParseRRULE($event['RRULE']);
$ts_start = $event['DT_FROM_TS'];
$ts_finish = $event['DT_TO_TS'];
$bAllDay = $event['DT_SKIP_TIME'] == 'Y' ? 1 : 0;
$TZBias = intval(date('Z'));
$offset = CCalendar::GetOffset();
$duration = $event['DT_LENGTH'];
if ($bAllDay) {
$duration -= 20;
}
if (!$bAllDay || defined('OLD_OUTLOOK_VERSION')) {
$ts_start = $ts_start - $TZBias - $offset;
// We need time in UTC
$ts_finish = $ts_finish - $TZBias - $offset;
}
$obRow = new CXMLCreator('z:row');
$obRow->setAttribute('ows_ID', $event['ID']);
$obRow->setAttribute('ows_Title', htmlspecialcharsback($event['NAME']));
// we have data htmlspecialchared yet
$version = $event['VERSION'] ? $event['VERSION'] : 1;
$obRow->setAttribute('ows_Attachments', 0);
$obRow->setAttribute('ows_owshiddenversion', $version);
$obRow->setAttribute('ows_MetaInfo_vti_versionhistory', md5($event['ID']) . ':' . $version);
/*
ows_MetaInfo_BusyStatus='2' - Editor
ows_MetaInfo_IntendedBusyStatus='-1' - Creator
values:
-1 - Unspecified busy status. Protocol clients can choose to display one of the other values if BusyStatus is -1.
0 - Free - ACCESSIBILITY => 'free'
1 - Tentative - ACCESSIBILITY => 'quest'
2 - Busy - ACCESSIBILITY => 'busy'
3 - Out of Office - ACCESSIBILITY => 'absent'
*/
$status = $arStatusValues[$event['ACCESSIBILITY']];
$obRow->setAttribute('ows_MetaInfo_BusyStatus', $status === null ? -1 : $status);
$obRow->setAttribute('ows_MetaInfo_Priority', intval($arPriorityValues[$event['IMPORTANCE']]));
$obRow->setAttribute('ows_Created', $this->__makeDateTime(MakeTimeStamp($event['DATE_CREATE']) - $TZBias));
$obRow->setAttribute('ows_Modified', $this->__makeDateTime($change - $TZBias));
$obRow->setAttribute('ows_EventType', $bRecurrent ? 1 : 0);
$obRow->setAttribute('ows_Location', CCalendar::GetTextLocation($event['LOCATION']));
$obRow->setAttribute('ows_Description', $event['~DESCRIPTION']);
// Description parsed from BB-codes to HTML
$obRow->setAttribute('ows_EventDate', $this->__makeDateTime($ts_start));
$obRow->setAttribute('ows_EndDate', $this->__makeDateTime($ts_start + $event['DT_LENGTH']));
$obRow->setAttribute('ows_fAllDayEvent', $bAllDay);
/* Recurrence */
$obRow->setAttribute('ows_fRecurrence', $bRecurrent);
if ($bRecurrent) {
$obRow->setAttribute('ows_UID', CIntranetUtils::makeGUID(md5($event['ID'] . '_' . $change)));
$tz_data = '';
$tz_data .= '<timeZoneRule>';
$tz_data .= '<standardBias>' . -intval(($TZBias - (date('I') ? 3600 : 0)) / 60) . '</standardBias>';
$tz_data .= '<additionalDaylightBias>-60</additionalDaylightBias>';
$bUseTransition = COption::GetOptionString('intranet', 'tz_transition', 'Y') == 'Y';
if ($bUseTransition) {
$transition_standard = COption::GetOptionString('intranet', 'tz_transition_standard', '');
$transition_daylight = COption::GetOptionString('intranet', 'tz_transition_daylight', '');
if (!$transition_standard) {
$transition_standard = '<transitionRule month="10" day="su" weekdayOfMonth="last" /><transitionTime>3:0:0</transitionTime>';
}
if (!$transition_daylight) {
$transition_daylight = '<transitionRule month="3" day="su" weekdayOfMonth="last" /><transitionTime>2:0:0</transitionTime>';
}
$tz_data .= '<standardDate>' . $transition_standard . '</standardDate><daylightDate>' . $transition_daylight . '</daylightDate>';
}
$tz_data .= '</timeZoneRule>';
$obRow->setAttribute('ows_XMLTZone', $tz_data);
$recurence_data = '';
$recurence_data .= '<recurrence>';
$recurence_data .= '<rule>';
$recurence_data .= '<firstDayOfWeek>' . $first_week_day . '</firstDayOfWeek>';
$recurence_data .= '<repeat>';
switch ($rrule['FREQ']) {
case 'DAILY':
$recurence_data .= '<daily dayFrequency="' . $rrule['INTERVAL'] . '" />';
break;
case 'WEEKLY':
$days = '';
foreach ($rrule['BYDAY'] as $day) {
$days .= strtolower($day) . '="TRUE" ';
}
$recurence_data .= '<weekly ' . $days . 'weekFrequency="' . $rrule['INTERVAL'] . '" />';
break;
case 'MONTHLY':
$recurence_data .= '<monthly monthFrequency="' . $rrule['INTERVAL'] . '" day="' . date('d', $ts_start) . '" />';
break;
case 'YEARLY':
$recurence_data .= '<yearly yearFrequency="' . $rrule['INTERVAL'] . '" month="' . date('m', $ts_start) . '" day="' . date('d', $ts_start) . '" />';
//.........这里部分代码省略.........
示例5: GetList
public static function GetList($Params = array())
{
global $DB, $USER_FIELD_MANAGER;
$getUF = $Params['getUserfields'] !== false;
$checkPermissions = $Params['checkPermissions'] !== false;
$bCache = CCalendar::CacheTime() > 0;
$Params['setDefaultLimit'] = $Params['setDefaultLimit'] === true;
$userId = isset($Params['userId']) ? intVal($Params['userId']) : CCalendar::GetCurUserId();
CTimeZone::Disable();
if ($bCache) {
$cache = new CPHPCache();
$cacheId = 'event_list_' . md5(serialize($Params));
if ($checkPermissions) {
$cacheId .= 'chper' . CCalendar::GetCurUserId() . '|';
}
if (CCalendar::IsSocNet() && CCalendar::IsSocnetAdmin()) {
$cacheId .= 'socnetAdmin|';
}
$cacheId .= CCalendar::GetOffset();
$cachePath = CCalendar::CachePath() . 'event_list';
if ($cache->InitCache(CCalendar::CacheTime(), $cacheId, $cachePath)) {
$res = $cache->GetVars();
$arResult = $res["arResult"];
$arAttendees = $res["arAttendees"];
}
}
if (!$bCache || !isset($arResult)) {
$arFilter = $Params['arFilter'];
if ($getUF) {
$obUserFieldsSql = new CUserTypeSQL();
$obUserFieldsSql->SetEntity("CALENDAR_EVENT", "CE.ID");
$obUserFieldsSql->SetSelect(array("UF_*"));
$obUserFieldsSql->SetFilter($arFilter);
}
$fetchMeetings = $Params['fetchMeetings'];
$Params['fetchAttendees'] = $Params['fetchAttendees'] !== false;
$skipDeclined = $Params['skipDeclined'] === true;
if ($Params['setDefaultLimit'] !== false) {
if (!isset($arFilter["FROM_LIMIT"])) {
// default 3 month back
$arFilter["FROM_LIMIT"] = CCalendar::Date(time() - 31 * 3 * 24 * 3600, false);
}
if (!isset($arFilter["TO_LIMIT"])) {
// default one year into the future
$arFilter["TO_LIMIT"] = CCalendar::Date(time() + 365 * 24 * 3600, false);
}
}
$arOrder = isset($Params['arOrder']) ? $Params['arOrder'] : array('SORT' => 'asc');
$arFields = self::GetFields();
if ($arFilter["DELETED"] === false) {
unset($arFilter["DELETED"]);
} elseif (!isset($arFilter["DELETED"])) {
$arFilter["DELETED"] = "N";
}
$ownerId = isset($arFilter['OWNER_ID']) ? $arFilter['OWNER_ID'] : CCalendar::GetOwnerId();
$arSqlSearch = array();
if (is_array($arFilter)) {
$filter_keys = array_keys($arFilter);
for ($i = 0, $l = count($filter_keys); $i < $l; $i++) {
$n = strtoupper($filter_keys[$i]);
$val = $arFilter[$filter_keys[$i]];
if (is_string($val) && strlen($val) <= 0 || strval($val) == "NOT_REF") {
continue;
}
if ($n == 'FROM_LIMIT') {
$ts = CCalendar::Timestamp($val, false);
if ($ts > 0) {
$arSqlSearch[] = "CE.DATE_TO_TS_UTC>=" . $ts;
}
} elseif ($n == 'TO_LIMIT') {
$ts = CCalendar::Timestamp($val, false);
if ($ts > 0) {
$arSqlSearch[] = "CE.DATE_FROM_TS_UTC<=" . ($ts + 86399);
}
} elseif ($n == 'OWNER_ID' && intVal($val) > 0) {
$arSqlSearch[] = "CE.OWNER_ID=" . intVal($val);
}
if ($n == 'NAME') {
$arSqlSearch[] = "CE.NAME='" . CDatabase::ForSql($val) . "'";
} elseif ($n == 'CREATED_BY') {
if (is_array($val)) {
$val = array_map(intVal, $val);
$arSqlSearch[] = 'CE.CREATED_BY IN (\'' . implode('\',\'', $val) . '\')';
} else {
if (intVal($val) > 0) {
$arSqlSearch[] = "CE.CREATED_BY=" . intVal($val);
}
}
} elseif ($n == 'SECTION') {
if (!is_array($val)) {
$val = array($val);
}
$q = "";
if (is_array($val)) {
$sval = '';
foreach ($val as $sectid) {
if (intVal($sectid) > 0) {
$sval .= intVal($sectid) . ',';
}
}
//.........这里部分代码省略.........
示例6: GetOffsetUTC
public static function GetOffsetUTC($userId = false, $dateTimestamp)
{
if (!$userId && self::$userId) {
$userId = self::$userId;
}
$tzName = self::GetUserTimezoneName($userId);
if ($tzName) {
$offset = self::GetTimezoneOffset($tzName, $dateTimestamp);
} else {
$offset = date("Z", $dateTimestamp) + CCalendar::GetOffset($userId);
}
return intVal($offset);
}