本文整理汇总了PHP中CCalendar::SetLocation方法的典型用法代码示例。如果您正苦于以下问题:PHP CCalendar::SetLocation方法的具体用法?PHP CCalendar::SetLocation怎么用?PHP CCalendar::SetLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCalendar
的用法示例。
在下文中一共展示了CCalendar::SetLocation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Edit
public static function Edit($Params = array())
{
global $DB, $CACHE_MANAGER;
$arFields = $Params['arFields'];
// Get current user id
$userId = isset($Params['userId']) && intVal($Params['userId']) > 0 ? intVal($Params['userId']) : CCalendar::GetCurUserId();
if (!$userId && isset($arFields['CREATED_BY'])) {
$userId = intVal($arFields['CREATED_BY']);
}
$path = !empty($Params['path']) ? $Params['path'] : CCalendar::GetPath($arFields['CAL_TYPE'], $arFields['OWNER_ID'], true);
if ($userId < 0) {
return false;
}
if (!self::CheckFields($arFields)) {
return false;
}
if ($arFields['CAL_TYPE'] == 'user') {
$CACHE_MANAGER->ClearByTag('calendar_user_' . $arFields['OWNER_ID']);
}
$bNew = !isset($arFields['ID']) || $arFields['ID'] <= 0;
$arFields['TIMESTAMP_X'] = CCalendar::Date(mktime(), true, false);
if ($bNew) {
if (!isset($arFields['CREATED_BY'])) {
$arFields['CREATED_BY'] = $userId;
}
if (!isset($arFields['DATE_CREATE'])) {
$arFields['DATE_CREATE'] = $arFields['TIMESTAMP_X'];
}
}
$attendees = is_array($arFields['ATTENDEES']) ? $arFields['ATTENDEES'] : array();
if (!isset($arFields['OWNER_ID']) || !$arFields['OWNER_ID']) {
$arFields['OWNER_ID'] = 0;
}
if (!isset($arFields['LOCATION']['OLD']) && !$bNew) {
// Select meeting info about event
if (isset($Params['currentEvent'])) {
$oldEvent = $Params['currentEvent'];
} else {
$oldEvent = CCalendarEvent::GetById($arFields['ID']);
}
if ($oldEvent) {
$arFields['LOCATION']['OLD'] = $oldEvent['LOCATION'];
}
}
$offset = CCalendar::GetOffset();
$arFields['LOCATION'] = CCalendar::SetLocation($arFields['LOCATION']['OLD'], $arFields['LOCATION']['NEW'], array('dateFrom' => CCalendar::Date($arFields['DT_FROM_TS'] + $offset), 'dateTo' => CCalendar::Date($arFields['DT_TO_TS'] + $offset), 'name' => $arFields['NAME'], 'persons' => count($attendees), 'attendees' => $attendees, 'bRecreateReserveMeetings' => $arFields['LOCATION']['RE_RESERVE'] !== 'N'));
$bSendInvitations = false;
if (!isset($arFields['IS_MEETING']) && isset($arFields['ATTENDEES']) && is_array($arFields['ATTENDEES']) && empty($arFields['ATTENDEES'])) {
$arFields['IS_MEETING'] = false;
}
$attendeesCodes = array();
if ($arFields['IS_MEETING'] && is_array($arFields['MEETING'])) {
if (!empty($arFields['ATTENDEES_CODES'])) {
$attendeesCodes = $arFields['ATTENDEES_CODES'];
$arFields['ATTENDEES_CODES'] = implode(',', $arFields['ATTENDEES_CODES']);
}
// Organizer
$bSendInvitations = $Params['bSendInvitations'] !== false;
$arFields['~MEETING'] = array('HOST_NAME' => $arFields['MEETING']['HOST_NAME'], 'TEXT' => $arFields['MEETING']['TEXT'], 'OPEN' => $arFields['MEETING']['OPEN'], 'NOTIFY' => $arFields['MEETING']['NOTIFY'], 'REINVITE' => $arFields['MEETING']['REINVITE']);
$arFields['MEETING'] = serialize($arFields['~MEETING']);
}
$arReminders = array();
if ($arFields['REMIND'] && is_array($arFields['REMIND'])) {
foreach ($arFields['REMIND'] as $remind) {
if (in_array($remind['type'], array('min', 'hour', 'day'))) {
$arReminders[] = array('type' => $remind['type'], 'count' => floatVal($remind['count']));
}
}
}
$arFields['REMIND'] = count($arReminders) > 0 ? serialize($arReminders) : '';
$AllFields = self::GetFields();
$dbFields = array();
foreach ($arFields as $field => $val) {
if (isset($AllFields[$field]) && $field != "ID") {
$dbFields[$field] = $arFields[$field];
}
}
CTimeZone::Disable();
if ($bNew) {
$ID = CDatabase::Add("b_calendar_event", $dbFields, array('DESCRIPTION', 'MEETING', 'RDATE', 'EXDATE'));
} else {
$ID = $arFields['ID'];
$strUpdate = $DB->PrepareUpdate("b_calendar_event", $dbFields);
$strSql = "UPDATE b_calendar_event SET " . $strUpdate . " WHERE ID=" . IntVal($arFields['ID']);
$DB->QueryBind($strSql, array('DESCRIPTION' => $arFields['DESCRIPTION'], 'MEETING' => $arFields['MEETING'], 'RDATE' => $arFields['RDATE'], 'EXDATE' => $arFields['EXDATE']));
}
CTimeZone::Enable();
if ($bNew && !isset($dbFields['DAV_XML_ID'])) {
$strSql = "UPDATE b_calendar_event SET " . $DB->PrepareUpdate("b_calendar_event", array('DAV_XML_ID' => $ID)) . " WHERE ID=" . IntVal($ID);
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
// Clean links
// Del link from table
if (!$bNew) {
$arAffectedSections = CCalendarEvent::GetCurrentSectionIds($ID);
$DB->Query("DELETE FROM b_calendar_event_sect WHERE EVENT_ID=" . IntVal($ID), false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__);
} else {
$arAffectedSections = array();
}
$strSections = "0";
//.........这里部分代码省略.........
示例2: Edit
public static function Edit($Params = array())
{
global $DB, $CACHE_MANAGER;
$arFields = $Params['arFields'];
$arAffectedSections = array();
$result = false;
// Get current user id
$userId = isset($Params['userId']) && intVal($Params['userId']) > 0 ? intVal($Params['userId']) : CCalendar::GetCurUserId();
if (!$userId && isset($arFields['CREATED_BY'])) {
$userId = intVal($arFields['CREATED_BY']);
}
$path = !empty($Params['path']) ? $Params['path'] : CCalendar::GetPath($arFields['CAL_TYPE'], $arFields['OWNER_ID'], true);
$bNew = !isset($arFields['ID']) || $arFields['ID'] <= 0;
$arFields['TIMESTAMP_X'] = CCalendar::Date(mktime(), true, false);
if ($bNew) {
if (!isset($arFields['CREATED_BY'])) {
$arFields['CREATED_BY'] = $arFields['IS_MEETING'] && $arFields['CAL_TYPE'] == 'user' && $arFields['OWNER_ID'] ? $arFields['OWNER_ID'] : $userId;
}
if (!isset($arFields['DATE_CREATE'])) {
$arFields['DATE_CREATE'] = $arFields['TIMESTAMP_X'];
}
}
if (!isset($arFields['OWNER_ID']) || !$arFields['OWNER_ID']) {
$arFields['OWNER_ID'] = 0;
}
// Current event
$currentEvent = array();
if (!$bNew) {
if (isset($Params['currentEvent'])) {
$currentEvent = $Params['currentEvent'];
} else {
$currentEvent = CCalendarEvent::GetById($arFields['ID']);
}
if (!isset($arFields['LOCATION']['OLD']) && $currentEvent) {
$arFields['LOCATION']['OLD'] = $currentEvent['LOCATION'];
}
if ($currentEvent['IS_MEETING'] && !isset($arFields['ATTENDEES']) && $currentEvent['PARENT_ID'] == $currentEvent['ID'] && $arFields['IS_MEETING']) {
$arFields['ATTENDEES'] = array();
$attendees = self::GetAttendees($currentEvent['PARENT_ID']);
if ($attendees[$currentEvent['PARENT_ID']]) {
for ($i = 0, $l = count($attendees[$currentEvent['PARENT_ID']]); $i < $l; $i++) {
$arFields['ATTENDEES'][] = $attendees[$currentEvent['PARENT_ID']][$i]['USER_ID'];
}
}
}
if (($currentEvent['IS_MEETING'] || $arFields['IS_MEETING']) && $currentEvent['PARENT_ID']) {
$arFields['PARENT_ID'] = $currentEvent['PARENT_ID'];
}
}
if ($userId > 0 && self::CheckFields($arFields, $currentEvent, $userId)) {
if ($arFields['CAL_TYPE'] == 'user') {
$CACHE_MANAGER->ClearByTag('calendar_user_' . $arFields['OWNER_ID']);
}
$attendees = is_array($arFields['ATTENDEES']) ? $arFields['ATTENDEES'] : array();
if (!$arFields['PARENT_ID']) {
$fromTs = $arFields['DATE_FROM_TS_UTC'];
$toTs = $arFields['DATE_TO_TS_UTC'];
if ($arFields['DT_SKIP_TIME'] == "Y") {
//$toTs += CCalendar::GetDayLen();
} else {
$fromTs += date('Z', $arFields['DATE_FROM_TS_UTC']);
$toTs += date('Z', $arFields['DATE_TO_TS_UTC']);
}
$arFields['LOCATION'] = CCalendar::SetLocation($arFields['LOCATION']['OLD'], $arFields['LOCATION']['NEW'], array('dateFrom' => CCalendar::Date($fromTs, $arFields['DT_SKIP_TIME'] !== "Y"), 'dateTo' => CCalendar::Date($toTs, $arFields['DT_SKIP_TIME'] !== "Y"), 'name' => $arFields['NAME'], 'persons' => count($attendees), 'attendees' => $attendees, 'bRecreateReserveMeetings' => $arFields['LOCATION']['RE_RESERVE'] !== 'N'));
} else {
$arFields['LOCATION'] = CCalendar::GetTextLocation($arFields['LOCATION']['NEW']);
}
$bSendInvitations = $Params['bSendInvitations'] !== false;
if (!isset($arFields['IS_MEETING']) && isset($arFields['ATTENDEES']) && is_array($arFields['ATTENDEES']) && empty($arFields['ATTENDEES'])) {
$arFields['IS_MEETING'] = false;
}
$attendeesCodes = array();
if ($arFields['IS_MEETING'] && is_array($arFields['MEETING'])) {
if (!empty($arFields['ATTENDEES_CODES'])) {
$attendeesCodes = $arFields['ATTENDEES_CODES'];
$arFields['ATTENDEES_CODES'] = implode(',', $arFields['ATTENDEES_CODES']);
}
$arFields['~MEETING'] = array('HOST_NAME' => $arFields['MEETING']['HOST_NAME'], 'TEXT' => $arFields['MEETING']['TEXT'], 'OPEN' => $arFields['MEETING']['OPEN'], 'NOTIFY' => $arFields['MEETING']['NOTIFY'], 'REINVITE' => $arFields['MEETING']['REINVITE']);
$arFields['MEETING'] = serialize($arFields['~MEETING']);
if (!isset($arFields['MEETING_STATUS'])) {
$arFields['MEETING_STATUS'] = 'H';
}
}
$arReminders = array();
if (is_array($arFields['REMIND'])) {
foreach ($arFields['REMIND'] as $remind) {
if (in_array($remind['type'], array('min', 'hour', 'day'))) {
$arReminders[] = array('type' => $remind['type'], 'count' => floatVal($remind['count']));
}
}
} elseif ($currentEvent['REMIND']) {
$arReminders = $currentEvent['REMIND'];
}
$arFields['REMIND'] = count($arReminders) > 0 ? serialize($arReminders) : '';
$AllFields = self::GetFields();
$dbFields = array();
foreach ($arFields as $field => $val) {
if (isset($AllFields[$field]) && $field != "ID") {
$dbFields[$field] = $arFields[$field];
}
//.........这里部分代码省略.........