本文整理汇总了PHP中CCalendar::SetOffset方法的典型用法代码示例。如果您正苦于以下问题:PHP CCalendar::SetOffset方法的具体用法?PHP CCalendar::SetOffset怎么用?PHP CCalendar::SetOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCalendar
的用法示例。
在下文中一共展示了CCalendar::SetOffset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: Delete
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: Delete
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;
}