本文整理汇总了PHP中CCalendar::Date方法的典型用法代码示例。如果您正苦于以下问题:PHP CCalendar::Date方法的具体用法?PHP CCalendar::Date怎么用?PHP CCalendar::Date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCalendar
的用法示例。
在下文中一共展示了CCalendar::Date方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Execute
public function Execute()
{
if (!CModule::IncludeModule("calendar")) {
return CBPActivityExecutionStatus::Closed;
}
$rootActivity = $this->GetRootActivity();
$documentId = $rootActivity->GetDocumentId();
$documentService = $this->workflow->GetService("DocumentService");
$fromTs = CCalendar::Timestamp($this->CalendarFrom);
$toTs = $this->CalendarTo == '' ? $fromTs : CCalendar::Timestamp($this->CalendarTo);
$arFields = array("CAL_TYPE" => !$this->CalendarType ? 'user' : $this->CalendarType, "NAME" => trim($this->CalendarName) == '' ? GetMessage('EC_DEFAULT_EVENT_NAME') : $this->CalendarName, "DESCRIPTION" => $this->CalendarDesrc, "SKIP_TIME" => date('H:i', $fromTs) == '00:00' && date('H:i', $toTs) == '00:00', "IS_MEETING" => false, "RRULE" => false);
if ($fromTs == $toTs && !$arFields["SKIP_TIME"]) {
$toTs += 3600;
}
$arFields['DATE_FROM'] = CCalendar::Date($fromTs);
$arFields['DATE_TO'] = CCalendar::Date($toTs);
if ($this->CalendarSection && intVal($this->CalendarSection) > 0) {
$arFields['SECTIONS'] = array(intVal($this->CalendarSection));
}
if ($this->CalendarOwnerId || $arFields["CAL_TYPE"] != "user" && $arFields["CAL_TYPE"] != "group") {
$arFields["OWNER_ID"] = $this->CalendarOwnerId;
$eventId = CCalendar::SaveEvent(array('arFields' => $arFields, 'autoDetectSection' => true));
} else {
$arCalendarUser = CBPHelper::ExtractUsers($this->CalendarUser, $documentId);
foreach ($arCalendarUser as $calendarUser) {
$arFields["CAL_TYPE"] = "user";
$arFields["OWNER_ID"] = $calendarUser;
$eventId = CCalendar::SaveEvent(array('arFields' => $arFields, 'autoDetectSection' => true));
}
}
return CBPActivityExecutionStatus::Closed;
}
示例2: GetAbsent
public static function GetAbsent($users = false, $Params = array())
{
global $DB;
// Can be called from agent... So we have to create $USER if it is not exists
$tempUser = CCalendar::TempUser(false, true);
$curUserId = isset($Params['userId']) ? intVal($Params['userId']) : CCalendar::GetCurUserId();
$arUsers = array();
if ($users !== false && is_array($users)) {
foreach ($users as $id) {
if ($id > 0) {
$arUsers[] = intVal($id);
}
}
}
if (!count($arUsers)) {
$users = false;
}
// Part 1: select ordinary events
$arFilter = array('CAL_TYPE' => 'user', 'DELETED' => 'N', 'ACCESSIBILITY' => 'absent');
if (isset($Params['fromLimit'])) {
$arFilter['FROM_LIMIT'] = CCalendar::Date(CCalendar::Timestamp($Params['fromLimit'], false), true, false);
}
if (isset($Params['toLimit'])) {
$arFilter['TO_LIMIT'] = CCalendar::Date(CCalendar::Timestamp($Params['toLimit'], false), true, false);
}
$arEvents = CCalendarEvent::GetList(array('arFilter' => $arFilter, 'getUserfields' => false, 'parseRecursion' => true, 'fetchAttendees' => false, 'fetchMeetings' => true, 'userId' => $curUserId, 'checkPermissions' => false, 'preciseLimits' => true));
// Part 2: select attendees
CTimeZone::Disable();
if (count($arUsers) > 0) {
$userQ = ' AND CA.USER_ID in (' . implode(',', $arUsers) . ')';
} else {
$userQ = '';
}
$strSql = "\n\t\t\tSELECT\n\t\t\t\tCA.EVENT_ID as ID, CA.USER_ID, CA.STATUS, CA.ACCESSIBILITY,\n\t\t\t\tCE.CAL_TYPE,CE.OWNER_ID,CE.NAME," . $DB->DateToCharFunction("CE.DT_FROM") . " as DT_FROM," . $DB->DateToCharFunction("CE.DT_TO") . " as DT_TO, CE.DT_LENGTH, CE.PRIVATE_EVENT, CE.ACCESSIBILITY, CE.IMPORTANCE, CE.IS_MEETING, CE.MEETING_HOST, CE.MEETING, CE.LOCATION, CE.RRULE, CE.EXRULE, CE.RDATE, CE.EXDATE,\n\t\t\t\tCES.SECT_ID\n\t\t\tFROM b_calendar_attendees CA\n\t\t\tLEFT JOIN\n\t\t\t\tb_calendar_event CE ON(CA.EVENT_ID=CE.ID)\n\t\t\tLEFT JOIN\n\t\t\t\tb_calendar_event_sect CES ON (CA.EVENT_ID=CES.EVENT_ID)\n\t\t\tWHERE\n\t\t\t\t\tCE.ID IS NOT NULL\n\t\t\t\tAND\n\t\t\t\t\tCE.DELETED='N'\n\t\t\t\tAND\n\t\t\t\t\tSTATUS='Y'\n\t\t\t\tAND\n\t\t\t\t\tCA.ACCESSIBILITY='absent'\n\t\t\t\t{$userQ}\n\t\t\t";
if (isset($arFilter['FROM_LIMIT'])) {
$strSql .= "AND ";
if (strtoupper($DB->type) == "MYSQL") {
$strSql .= "CE.DT_TO>=FROM_UNIXTIME('" . MkDateTime(FmtDate($arFilter['FROM_LIMIT'], "D.M.Y"), "d.m.Y") . "')";
} elseif (strtoupper($DB->type) == "MSSQL") {
$strSql .= "CE.DT_TO>=" . $DB->CharToDateFunction($arFilter['FROM_LIMIT'], "SHORT");
} elseif (strtoupper($DB->type) == "ORACLE") {
$strSql .= "CE.DT_TO>=TO_DATE('" . FmtDate($arFilter['FROM_LIMIT'], "D.M.Y") . " 00:00:00','dd.mm.yyyy hh24:mi:ss')";
}
}
if ($arFilter['TO_LIMIT']) {
$strSql .= "AND ";
if (strtoupper($DB->type) == "MYSQL") {
$strSql .= "CE.DT_FROM<=FROM_UNIXTIME('" . MkDateTime(FmtDate($arFilter['TO_LIMIT'], "D.M.Y") . " 23:59:59", "d.m.Y H:i:s") . "')";
} elseif (strtoupper($DB->type) == "MSSQL") {
$strSql .= "CE.DT_FROM<=dateadd(day, 1, " . $DB->CharToDateFunction($arFilter['TO_LIMIT'], "SHORT") . ")";
} elseif (strtoupper($DB->type) == "ORACLE") {
$strSql .= "CE.DT_FROM<=TO_DATE('" . FmtDate($arFilter['TO_LIMIT'], "D.M.Y") . " 23:59:59','dd.mm.yyyy hh24:mi:ss')";
}
}
$res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$arEvents2 = array();
while ($event = $res->Fetch()) {
$event = self::PreHandleEvent($event);
if ($event['CAL_TYPE'] == 'user' && $event['IS_MEETING'] && $event['OWNER_ID'] == $event['USER_ID']) {
continue;
}
if (self::CheckRecurcion($event)) {
self::ParseRecursion($arEvents2, $event, array('fromLimit' => $arFilter["FROM_LIMIT"], 'toLimit' => $arFilter["TO_LIMIT"]));
} else {
self::HandleEvent($arEvents2, $event);
}
}
CTimeZone::Enable();
$arEvents = array_merge($arEvents, $arEvents2);
$bSocNet = CModule::IncludeModule("socialnetwork");
$result = array();
$settings = CCalendar::GetSettings(array('request' => false));
foreach ($arEvents as $event) {
$userId = isset($event['USER_ID']) ? $event['USER_ID'] : $event['OWNER_ID'];
if ($users !== false && !in_array($userId, $arUsers)) {
continue;
}
if ($bSocNet && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $userId, "calendar")) {
continue;
}
if ((!$event['CAL_TYPE'] != 'user' || $curUserId != $event['OWNER_ID']) && $curUserId != $event['CREATED_BY'] && !isset($arUserMeeting[$event['ID']])) {
$sectId = $event['SECT_ID'];
if (!$event['ACCESSIBILITY']) {
$event['ACCESSIBILITY'] = 'busy';
}
$private = $event['PRIVATE_EVENT'] && $event['CAL_TYPE'] == 'user';
$bManager = false;
if (!$private && CCalendar::IsIntranetEnabled() && CModule::IncludeModule('intranet') && $event['CAL_TYPE'] == 'user' && $settings['dep_manager_sub']) {
$bManager = in_array($curUserId, CCalendar::GetUserManagers($event['OWNER_ID'], true));
}
if ($private || !CCalendarSect::CanDo('calendar_view_full', $sectId) && !$bManager) {
if ($private) {
$event['NAME'] = '[' . GetMessage('EC_ACCESSIBILITY_' . strtoupper($event['ACCESSIBILITY'])) . ']';
} else {
if (!CCalendarSect::CanDo('calendar_view_title', $sectId)) {
$event['NAME'] = '[' . GetMessage('EC_ACCESSIBILITY_' . strtoupper($event['ACCESSIBILITY'])) . ']';
} else {
$event['NAME'] = $event['NAME'] . ' [' . GetMessage('EC_ACCESSIBILITY_' . strtoupper($event['ACCESSIBILITY'])) . ']';
}
}
//.........这里部分代码省略.........
示例3: GetMessage
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
}
/*if ($event['RRULE'] !== '')*/
示例4: DoSaveToDav
public static function DoSaveToDav($Params = array(), &$arFields, $oCurEvent = false)
{
$sectionId = $Params['sectionId'];
$bExchange = $Params['bExchange'];
$bCalDav = $Params['bCalDav'];
if (isset($oCurEvent['DAV_XML_ID'])) {
$arFields['DAV_XML_ID'] = $oCurEvent['DAV_XML_ID'];
}
if (isset($oCurEvent['DAV_EXCH_LABEL'])) {
$arFields['DAV_EXCH_LABEL'] = $oCurEvent['DAV_EXCH_LABEL'];
}
if (isset($oCurEvent['CAL_DAV_LABEL'])) {
$arFields['CAL_DAV_LABEL'] = $oCurEvent['CAL_DAV_LABEL'];
}
$oSect = CCalendarSect::GetById($sectionId);
if ($oCurEvent) {
if ($oCurEvent['SECT_ID'] != $sectionId) {
$bCalDav = CCalendar::IsCalDAVEnabled() && $oCurEvent['CAL_TYPE'] == 'user' && strlen($oCurEvent['CAL_DAV_LABEL']) > 0;
$bExchangeEnabled = CCalendar::IsExchangeEnabled() && $oCurEvent['CAL_TYPE'] == 'user';
if ($bExchangeEnabled || $bCalDav) {
$res = CCalendar::DoDeleteToDav(array('bCalDav' => $bCalDav, 'bExchangeEnabled' => $bExchangeEnabled, 'sectionId' => $oCurEvent['SECT_ID']), $oCurEvent);
if ($res !== true) {
return CCalendar::ThrowError($res);
}
}
}
}
$fromTs = CCalendar::Timestamp($arFields['DT_FROM']);
$toTs = CCalendar::Timestamp($arFields['DT_TO']);
if (!isset($arFields['DT_FROM_TS'])) {
$arFields['DT_FROM_TS'] = $fromTs;
}
if (!isset($arFields['DT_TO_TS'])) {
$arFields['DT_TO_TS'] = $toTs;
}
$arDavFields = $arFields;
CCalendarEvent::CheckFields($arDavFields);
if ($arDavFields['RRULE'] != '') {
$arDavFields['RRULE'] = $arFields['RRULE'];
}
$arDavFields['DETAIL_TEXT'] = $arDavFields['DESCRIPTION'];
$arDavFields['DETAIL_TEXT_TYPE'] = 'text';
$arDavFields['ACTIVE_FROM'] = $arDavFields['DT_FROM'];
$arDavFields['ACTIVE_TO'] = $arDavFields['DT_TO'];
$arDavFields['PROPERTY_LOCATION'] = $arDavFields['LOCATION']['NEW'];
if ($arDavFields['PROPERTY_LOCATION'] !== '') {
$arDavFields['PROPERTY_LOCATION'] = CCalendar::GetTextLocation($arDavFields['PROPERTY_LOCATION']);
}
$arDavFields['PROPERTY_IMPORTANCE'] = $arDavFields['IMPORTANCE'];
$arDavFields['REMIND_SETTINGS'] = '';
if ($arFields['REMIND'] && is_array($arFields['REMIND']) && is_array($arFields['REMIND'][0])) {
$arDavFields['REMIND_SETTINGS'] = floatVal($arFields['REMIND'][0]['count']) . '_' . $arFields['REMIND'][0]['type'];
}
// RRULE
$arDavFields['PROPERTY_PERIOD_TYPE'] = 'NONE';
if (is_array($arFields['RRULE']) && isset($arFields['RRULE']['FREQ']) && in_array($arFields['RRULE']['FREQ'], array('HOURLY', 'DAILY', 'MONTHLY', 'YEARLY', 'WEEKLY'))) {
$arDavFields['PROPERTY_PERIOD_TYPE'] = $arFields['RRULE']['FREQ'];
// Interval
$arDavFields['PROPERTY_PERIOD_COUNT'] = isset($arFields['RRULE']['INTERVAL']) && intVal($arFields['RRULE']['INTERVAL']) > 1 ? intVal($arFields['RRULE']['INTERVAL']) : 1;
if ($arFields['RRULE']['FREQ'] == 'WEEKLY' && isset($arFields['RRULE']['BYDAY'])) {
//PROPERTY_PERIOD_ADDITIONAL
$BYDAYS = array();
$days = array('SU' => 0, 'MO' => 1, 'TU' => 2, 'WE' => 3, 'TH' => 4, 'FR' => 5, 'SA' => 6);
$bydays = explode(',', $arFields['RRULE']['BYDAY']);
foreach ($bydays as $day) {
$BYDAYS[] = $days[$day];
}
$arDavFields['PROPERTY_PERIOD_ADDITIONAL'] = implode(',', $BYDAYS);
}
$h24 = 60 * 60 * 24;
if ($fromTs == $toTs) {
$arDavFields['PROPERTY_EVENT_LENGTH'] = $h24;
} else {
$arDavFields['PROPERTY_EVENT_LENGTH'] = intVal($toTs - $fromTs);
if ($arDavFields['PROPERTY_EVENT_LENGTH'] % $h24 == 0) {
// We have dates without times
$arDavFields['PROPERTY_EVENT_LENGTH'] += $h24;
}
}
// Until date
if (isset($arFields['RRULE']['UNTIL'])) {
$periodTs = $arFields['RRULE']['UNTIL'];
} else {
$periodTs = CCalendar::GetMaxTimestamp();
}
$arDavFields['ACTIVE_TO'] = CCalendar::Date($periodTs);
}
// **** Synchronize with CalDav ****
if ($bCalDav && $oSect['CAL_DAV_CON'] > 0) {
// New event or move existent event to DAV calendar
if ($arFields['ID'] <= 0 || $oCurEvent && !$oCurEvent['CAL_DAV_LABEL']) {
$DAVRes = CDavGroupdavClientCalendar::DoAddItem($oSect['CAL_DAV_CON'], $oSect['CAL_DAV_CAL'], $arDavFields);
} else {
// Edit existent event
$DAVRes = CDavGroupdavClientCalendar::DoUpdateItem($oSect['CAL_DAV_CON'], $oSect['CAL_DAV_CAL'], $oCurEvent['DAV_XML_ID'], $oCurEvent['CAL_DAV_LABEL'], $arDavFields);
}
if (!is_array($DAVRes) || !array_key_exists("XML_ID", $DAVRes)) {
return CCalendar::CollectCalDAVErros($DAVRes);
}
// // It's ok, we successfuly save event to caldav calendar - and save it to DB
//.........这里部分代码省略.........
示例5: GetMessage
$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
}
/* if ($event['RRULE']) */
示例6: Edit
public static function Edit($Params)
{
global $DB, $USER;
$arFields = $Params['arFields'];
if (!self::CheckFields($arFields)) {
return false;
}
$userId = intVal(isset($Params['userId']) ? $Params['userId'] : $USER->GetID());
//if (!CCalendarSect::CanDo('calendar_edit_section', $ID))
// return CCalendar::ThrowError('EC_ACCESS_DENIED');
$bNew = !isset($arFields['ID']) || $arFields['ID'] <= 0;
if (isset($arFields['COLOR']) || $bNew) {
$arFields['COLOR'] = CCalendar::Color($arFields['COLOR']);
}
$arFields['TIMESTAMP_X'] = CCalendar::Date(mktime());
if (is_array($arFields['EXPORT'])) {
$arFields['EXPORT'] = array('ALLOW' => !!$arFields['EXPORT']['ALLOW'], 'SET' => in_array($arFields['EXPORT']['set'], array('all', '3_9', '6_12')) ? $arFields['EXPORT']['set'] : 'all');
}
if (!is_array($arFields['EXPORT'])) {
$arFields['EXPORT'] = array('ALLOW' => false, 'SET' => 'all');
}
$arFields['EXPORT'] = serialize($arFields['EXPORT']);
if ($bNew) {
if (!isset($arFields['DATE_CREATE'])) {
$arFields['DATE_CREATE'] = CCalendar::Date(mktime());
}
if ((!isset($arFields['CREATED_BY']) || !$arFields['CREATED_BY']) && $USER) {
$arFields['CREATED_BY'] = $USER->IsAuthorized() ? $USER->GetID() : '';
}
unset($arFields['ID']);
$ID = CDatabase::Add("b_calendar_section", $arFields, array('DESCRIPTION'));
} else {
$ID = $arFields['ID'];
unset($arFields['ID']);
$strUpdate = $DB->PrepareUpdate("b_calendar_section", $arFields);
$strSql = "UPDATE b_calendar_section SET " . $strUpdate . " WHERE ID=" . IntVal($ID);
$DB->QueryBind($strSql, array('DESCRIPTION' => $arFields['DESCRIPTION']));
}
//SaveAccess
if ($ID > 0 && is_array($arFields['ACCESS'])) {
if ($arFields['CAL_TYPE'] == 'user' && $arFields['OWNER_ID'] == $userId || self::CanDo('calendar_edit_access', $ID)) {
self::SavePermissions($ID, $arFields['ACCESS']);
} elseif ($bNew) {
self::SavePermissions($ID, CCalendarSect::GetDefaultAccess($arFields['CAL_TYPE'], $arFields['OWNER_ID']));
}
}
if ($bNew && $ID > 0 && !isset($arFields['ACCESS'])) {
self::SavePermissions($ID, CCalendarSect::GetDefaultAccess($arFields['CAL_TYPE'], $arFields['OWNER_ID']));
}
CCalendar::ClearCache('section_list');
if ($ID > 0 && isset(self::$Permissions[$ID])) {
unset(self::$Permissions[$ID]);
self::$arOp = array();
}
return $ID;
}
示例7: ConvertICalToArray
private function ConvertICalToArray($event, $calendar)
{
static $arWeekDayMap = array("SU" => 6, "MO" => 0, "TU" => 1, "WE" => 2, "TH" => 3, "FR" => 4, "SA" => 5);
$request = $this->groupdav->GetRequest();
$tzFrom = $event->GetPropertyParameter("DTSTART", "TZID");
$tzTo = $event->GetPropertyParameter("DTEND", "TZID");
$skipTime = !is_null($event->GetPropertyParameter("DTSTART", "VALUE")) && !is_null($event->GetPropertyParameter("DTEND", "VALUE")) && is_null($tzFrom) && is_null($tzTo);
$dateFrom = CDavICalendarTimeZone::GetFormattedServerDateTime($event->GetPropertyValue("DTSTART"));
$dateTo = CDavICalendarTimeZone::GetFormattedServerDateTime($event->GetPropertyValue("DTEND"));
if ($skipTime) {
$dateTo = CCalendar::Date(MakeTimeStamp($dateTo) - 86400);
}
$arFields = array("NAME" => $event->GetPropertyValue("SUMMARY"), "PROPERTY_LOCATION" => $event->GetPropertyValue("LOCATION"), "DETAIL_TEXT" => $event->GetPropertyValue("DESCRIPTION"), "DETAIL_TEXT_TYPE" => 'html', "DATE_FROM" => $dateFrom, "DATE_TO" => $dateTo, "TZ_FROM" => $tzFrom, "TZ_TO" => $tzTo, "SKIP_TIME" => $skipTime, "MODIFIED_BY" => $request->GetPrincipal()->Id(), "DAV_XML_ID" => $event->GetPropertyValue("UID"), "DATE_CREATE" => CDavICalendarTimeZone::GetFormattedServerDateTime($event->GetPropertyValue("CREATED")), "PROPERTY_CATEGORY" => $event->GetPropertyValue("CATEGORIES"));
if ($priority = $event->GetPropertyValue("PRIORITY")) {
if ($priority <= 3) {
$arFields["PROPERTY_IMPORTANCE"] = "high";
} elseif ($priority > 3 && $priority <= 6) {
$arFields["PROPERTY_IMPORTANCE"] = "normal";
} else {
$arFields["PROPERTY_IMPORTANCE"] = "low";
}
} else {
$arFields["PROPERTY_IMPORTANCE"] = "normal";
}
if ($transp = $event->GetPropertyValue("TRANSP")) {
if ($transp == 'TRANSPARENT') {
$arFields["PROPERTY_ACCESSIBILITY"] = "free";
} else {
$arFields["PROPERTY_ACCESSIBILITY"] = "busy";
}
} else {
$arFields["PROPERTY_ACCESSIBILITY"] = "busy";
}
$arVAlarm = $event->GetComponents("VALARM");
if (count($arVAlarm) > 0 && $event->GetPropertyValue("X-MOZ-LASTACK") == null) {
$trigger = $arVAlarm[0]->GetPropertyValue("TRIGGER");
if (preg_match('/^-P(T?)([0-9]+)([HMD])$/i', $trigger, $arMatches)) {
$arPeriodMapTmp = array("M" => "min", "H" => "hour", "D" => "day");
$arFields["PROPERTY_REMIND_SETTINGS"] = $arMatches[2] . "_" . $arPeriodMapTmp[$arMatches[3]];
}
}
if ($rrule = $event->GetPropertyValueParsed("RRULE")) {
// RRULE:FREQ=WEEKLY;COUNT=5;INTERVAL=2;BYDAY=TU,SA
$arFields["PROPERTY_PERIOD_TYPE"] = $rrule["FREQ"];
$arFields["PROPERTY_PERIOD_COUNT"] = isset($rrule["INTERVAL"]) ? $rrule["INTERVAL"] : 1;
if ($arFields["PROPERTY_PERIOD_TYPE"] == "WEEKLY") {
if (isset($rrule["BYDAY"])) {
$ar = explode(",", $rrule["BYDAY"]);
$ar1 = array();
foreach ($ar as $v) {
$ar1[] = $arWeekDayMap[strtoupper($v)];
}
$arFields["PROPERTY_PERIOD_ADDITIONAL"] = implode(",", $ar1);
} else {
$arFields["PROPERTY_PERIOD_ADDITIONAL"] = date("w", MakeTimeStamp($arFields["DATE_FROM"])) - 1;
if ($arFields["PROPERTY_PERIOD_ADDITIONAL"] < 0) {
$arFields["PROPERTY_PERIOD_ADDITIONAL"] = 6;
}
}
}
$arFields["PROPERTY_EVENT_LENGTH"] = MakeTimeStamp($arFields["DATE_TO"]) - MakeTimeStamp($arFields["DATE_FROM"]);
if (isset($rrule["UNTIL"])) {
$arFields["ACTIVE_TO"] = CDavICalendarTimeZone::GetFormattedServerDateTime($rrule["UNTIL"]);
} elseif (isset($rrule["COUNT"])) {
$eventTime = $this->GetPeriodicEventTime(MakeTimeStamp($arFields["ACTIVE_TO"]), array("freq" => $arFields["PROPERTY_PERIOD_TYPE"], "interval" => $arFields["PROPERTY_PERIOD_COUNT"], "byday" => $arFields["PROPERTY_PERIOD_ADDITIONAL"]), $rrule["COUNT"]);
$arFields["ACTIVE_TO"] = date($GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATETIME), $eventTime);
} else {
$arFields["ACTIVE_TO"] = date($GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATETIME), 2145938400);
}
}
return $arFields;
}
示例8: elseif
$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);
$bToday = false;
$bTomorrow = false;
$bLater = false;
$use_sections = "YES";
$iconEvent = '/bitrix/templates/mobile_app/images/calendar/event.png';
$iconMeeting = '/bitrix/templates/mobile_app/images/calendar/meeting.png';
$iconInviting = '/bitrix/templates/mobile_app/images/calendar/meeting-q.png';
$dateFormat = GetMessage('MB_CAL_EVENT_DATE_FORMAT');
$timeFormat = IsAmPmMode() ? GetMessage('MB_CAL_EVENT_TIME_FORMAT_AMPM') : GetMessage('MB_CAL_EVENT_TIME_FORMAT');
$count = count($arEvents);
for ($i = 0; $i < $count; $i++) {
$event = $arEvents[$i];
$event['DT_FROM_TS'] = CCalendar::_fixTimestamp($event['DT_FROM_TS']);
$event['DT_TO_TS'] = CCalendar::_fixTimestamp($event['DT_TO_TS']);
$item = array("ID" => $event['ID'], "NAME" => CMobile::PrepareStrToJson($event['NAME']), "URL" => $url . "?event_id=" . $event['ID']);
示例9: ShowError
{
return CSite::GetDateFormat("FULL");
}
}
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';
示例10: EventGetNearest
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;
}
示例11: GetAbsent
public static function GetAbsent($users = false, $Params = array())
{
// Can be called from agent... So we have to create $USER if it is not exists
$tempUser = CCalendar::TempUser(false, true);
$curUserId = isset($Params['userId']) ? intVal($Params['userId']) : CCalendar::GetCurUserId();
$arUsers = array();
if ($users !== false && is_array($users)) {
foreach ($users as $id) {
if ($id > 0) {
$arUsers[] = intVal($id);
}
}
}
if (!count($arUsers)) {
$users = false;
}
$arFilter = array('DELETED' => 'N', 'ACCESSIBILITY' => 'absent');
if ($users) {
$arFilter['CREATED_BY'] = $users;
}
if (isset($Params['fromLimit'])) {
$arFilter['FROM_LIMIT'] = CCalendar::Date(CCalendar::Timestamp($Params['fromLimit'], false), true, false);
}
if (isset($Params['toLimit'])) {
$arFilter['TO_LIMIT'] = CCalendar::Date(CCalendar::Timestamp($Params['toLimit'], false), true, false);
}
$arEvents = CCalendarEvent::GetList(array('arFilter' => $arFilter, 'parseRecursion' => true, 'getUserfields' => false, 'userId' => $curUserId, 'preciseLimits' => true, 'checkPermissions' => false, 'skipDeclined' => true));
$bSocNet = CModule::IncludeModule("socialnetwork");
$result = array();
$settings = CCalendar::GetSettings(array('request' => false));
foreach ($arEvents as $event) {
$userId = isset($event['USER_ID']) ? $event['USER_ID'] : $event['CREATED_BY'];
if ($users !== false && !in_array($userId, $arUsers)) {
continue;
}
if ($bSocNet && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $userId, "calendar")) {
continue;
}
if ((!$event['CAL_TYPE'] != 'user' || $curUserId != $event['OWNER_ID']) && $curUserId != $event['CREATED_BY'] && !isset($arUserMeeting[$event['ID']])) {
$sectId = $event['SECT_ID'];
if (!$event['ACCESSIBILITY']) {
$event['ACCESSIBILITY'] = 'busy';
}
$private = $event['PRIVATE_EVENT'] && $event['CAL_TYPE'] == 'user';
$bManager = false;
if (!$private && CCalendar::IsIntranetEnabled() && CModule::IncludeModule('intranet') && $event['CAL_TYPE'] == 'user' && $settings['dep_manager_sub']) {
$bManager = in_array($curUserId, CCalendar::GetUserManagers($event['OWNER_ID'], true));
}
if ($private || !CCalendarSect::CanDo('calendar_view_full', $sectId) && !$bManager) {
$event = self::ApplyAccessRestrictions($event, $userId);
}
}
$skipTime = $event['DT_SKIP_TIME'] === 'Y';
$fromTs = CCalendar::Timestamp($event['DATE_FROM'], false, !$skipTime);
$toTs = CCalendar::Timestamp($event['DATE_TO'], false, !$skipTime);
if ($event['DT_SKIP_TIME'] !== 'Y') {
$fromTs -= $event['~USER_OFFSET_FROM'];
$toTs -= $event['~USER_OFFSET_TO'];
}
$result[] = array('ID' => $event['ID'], 'NAME' => $event['NAME'], 'DATE_FROM' => CCalendar::Date($fromTs, !$skipTime, false), 'DATE_TO' => CCalendar::Date($toTs, !$skipTime, false), 'DT_FROM_TS' => $fromTs, 'DT_TO_TS' => $toTs, 'CREATED_BY' => $userId, 'DETAIL_TEXT' => '', 'USER_ID' => $userId);
}
// Sort by DATE_FROM_TS_UTC
usort($result, array('CCalendar', '_NearestSort'));
CCalendar::TempUser($tempUser, false);
return $result;
}
示例12: UpdateListItems
function UpdateListItems($listName, $updates)
{
global $USER;
$arStatusValues = array_flip($this->arStatusValues);
$arPriorityValues = array_flip($this->arPriorityValues);
if (!($listName_original = CIntranetUtils::checkGUID($listName))) {
return new CSoapFault('Data error', 'Wrong GUID - ' . $listName);
}
$obResponse = new CXMLCreator('Results');
$listName = ToUpper(CIntranetUtils::makeGUID($listName_original));
$arSections = CCalendarSect::GetList(array('arFilter' => array('XML_ID' => $listName_original)));
if (!$arSections || !is_array($arSections[0])) {
return new CSoapFault('List not found', 'List with ' . $listName . ' GUID not found');
}
$arSection = $arSections[0];
$bGroup = $arSection['CAL_TYPE'] == 'group';
$calType = $arSection['CAL_TYPE'];
$ownerId = $arSection['OWNER_ID'];
if ($bGroup) {
CModule::IncludeModule('socialnetwork');
$arGroupTmp = CSocNetGroup::GetByID($arSection['SOCNET_GROUP_ID']);
if ($arGroupTmp["CLOSED"] == "Y") {
if (COption::GetOptionString("socialnetwork", "work_with_closed_groups", "N") != "Y") {
return new CSoapFault('Cannot modify archive group calendar', 'Cannot modify archive group calendar');
}
}
}
$obBatch = $updates->children[0];
$atrONERROR = $obBatch->getAttribute('OnError');
$atrDATEINUTC = $obBatch->getAttribute('DateInUtc');
$atrPROPERTIES = $obBatch->getAttribute('Properties');
$arChanges = $obBatch->children;
$arResultIDs = array();
$dateStart = ConvertTimeStamp(strtotime('-1 hour'), 'FULL');
$arResponseRows = array();
$arReplicationIDs = array();
$userId = is_object($USER) && $USER->GetID() ? $USER->GetID() : 1;
foreach ($arChanges as $obMethod) {
$arData = array('_command' => $obMethod->getAttribute('Cmd'));
foreach ($obMethod->children as $obField) {
$name = $obField->getAttribute('Name');
if ($name == 'MetaInfo') {
$name .= '_' . $obField->getAttribute('Property');
}
$arData[$name] = $obField->content;
}
if ($arData['_command'] == 'Delete') {
$obRes = new CXMLCreator('Result');
$obRes->setAttribute('ID', $obMethod->getAttribute('ID') . ',' . $arData['_command']);
$obRes->setAttribute('List', $listName);
$obRes->addChild($obNode = new CXMLCreator('ErrorCode'));
$res = CCalendar::DeleteEvent($arData['ID']);
if ($res === true) {
$obNode->setData('0x00000000');
} else {
$obNode->setData('0x81020014');
}
/*
0x00000000 - ok
0x81020015 - data conflict
0x81020014 - generic error such as invalid value for Field
0x81020016 - item does not exist
*/
$obResponse->addChild($obRes);
} elseif ($arData['_command'] == 'New' || $arData['_command'] == 'Update') {
$q = ToLower($arData['Description']);
if (($pos = strrpos($q, '</body>')) !== false) {
$arData['Description'] = substr($arData['Description'], 0, $pos);
}
if (($pos = strpos($q, '<body>')) !== false) {
$arData['Description'] = substr($arData['Description'], $pos + 6);
}
$arData['Description'] = str_replace('</DIV>', "\r\n</DIV>", $arData['Description']);
$arData['Description'] = str_replace(array(" ", " "), "", $arData['Description']);
$arData['Description'] = preg_replace("/<![^>]*>/", '', $arData['Description']);
//$arData['Description'] = strip_tags($arData['Description']);
$arData['Description'] = trim($arData['Description']);
$arData['Location'] = trim($arData['Location']);
if (isset($arData['EventDate'])) {
$fromTsUTC = $this->__makeTS($arData['EventDate']);
$toTsUTC = $this->__makeTS($arData['EndDate']) + ($arData['fAllDayEvent'] ? -86340 : 0);
$TZBias = intval(date('Z', $fromTsUTC));
}
$arData['EventType'] = intval($arData['EventType']);
if ($arData['EventType'] == 2) {
$arData['EventType'] = 0;
}
if ($arData['EventType'] > 2) {
return new CSoapFault('Unsupported event type', 'Event type unsupported');
}
$arData['fRecurrence'] = intval($arData['fRecurrence']);
$arData['RRULE'] = '';
$id = $arData['_command'] == 'New' ? 0 : intVal($arData['ID']);
if ($arData['RecurrenceData']) {
//$xmlstr = $arData['XMLTZone'];
//$arData['XMLTZone'] = new CDataXML();
//$arData['XMLTZone']->LoadString($xmlstr);
$xmlstr = $arData['RecurrenceData'];
$obRecurData = new CDataXML();
$obRecurData->LoadString($xmlstr);
//.........这里部分代码省略.........
示例13: define
<?php
define("PUBLIC_AJAX_MODE", true);
define("NO_KEEP_STATISTIC", "Y");
define("NO_AGENT_STATISTIC", "Y");
define("NO_AGENT_CHECK", true);
define("DisableEventsCheck", true);
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
header('Content-Type: application/x-javascript; charset=' . LANG_CHARSET);
if (check_bitrix_sessid() && CModule::IncludeModule("calendar")) {
if (isset($_REQUEST['bx_event_calendar_check_meeting_room']) && $_REQUEST['bx_event_calendar_check_meeting_room'] === 'Y') {
$check = false;
$settings = CCalendar::GetSettings();
$from = CCalendar::Date(CCalendar::Timestamp($_REQUEST['from']));
$to = CCalendar::Date(CCalendar::Timestamp($_REQUEST['to']));
$loc_new = CCalendar::ParseLocation(trim($_REQUEST['location']));
$params = array('dateFrom' => $from, 'dateTo' => $to, 'regularity' => 'NONE', 'members' => false);
if ($loc_new['mrid'] == $settings['vr_iblock_id']) {
$params['VMiblockId'] = $settings['vr_iblock_id'];
$check = CCalendar::CheckVideoRoom($params);
} else {
$params['RMiblockId'] = $settings['rm_iblock_id'];
$params['mrid'] = $loc_new['mrid'];
$params['mrevid_old'] = 0;
$check = CCalendar::CheckMeetingRoom($params);
}
?>
<script>top.BXCRES_Check = <?php
echo CUtil::PhpToJSObject($check);
?>
;</script><?php
示例14: 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']);
$arNewFields["DATE_FROM"] = $arFields['DATE_FROM'];
$arNewFields["DATE_TO"] = $arFields['DATE_TO'];
$arNewFields["TZ_FROM"] = $arFields['TZ_FROM'];
$arNewFields["TZ_TO"] = $arFields['TZ_TO'];
$arNewFields["SKIP_TIME"] = $arFields['SKIP_TIME'];
if ($arNewFields["SKIP_TIME"]) {
$arNewFields["DATE_TO"] = CCalendar::Date(CCalendar::Timestamp($arNewFields['DATE_TO']) - CCalendar::GetDayLen(), false);
}
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'];
}
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['PROPERTY_PERIOD_UNTIL'])) {
$arNewFields['RRULE']['UNTIL'] = $arFields['PROPERTY_PERIOD_UNTIL'];
} else {
$arNewFields['RRULE']['UNTIL'] = $arFields['DT_TO_TS'];
}
}
$eventId = CCalendar::SaveEvent(array('arFields' => $arNewFields, 'userId' => $userId, 'bAffectToDav' => false, 'bSilentAccessMeeting' => true));
self::$silentErrorMode = false;
return $eventId;
}