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 $arFields['DAV_XML_ID'] = $DAVRes['XML_ID']; $arFields['CAL_DAV_LABEL'] = $DAVRes['MODIFICATION_LABEL']; } elseif ($bExchange && $oSect['IS_EXCHANGE'] && strlen($oSect['DAV_EXCH_CAL']) > 0 && $oSect['DAV_EXCH_CAL'] !== 0) { $ownerId = $arFields['OWNER_ID']; // New event or move existent event to Exchange calendar if ($arFields['ID'] <= 0 || $oCurEvent && !$oCurEvent['DAV_EXCH_LABEL']) { $exchRes = CDavExchangeCalendar::DoAddItem($ownerId, $oSect['DAV_EXCH_CAL'], $arDavFields); } else { $exchRes = CDavExchangeCalendar::DoUpdateItem($ownerId, $oCurEvent['DAV_XML_ID'], $oCurEvent['DAV_EXCH_LABEL'], $arDavFields); } if (!is_array($exchRes) || !array_key_exists("XML_ID", $exchRes)) { return CCalendar::CollectExchangeErrors($exchRes); } // It's ok, we successfuly save event to exchange calendar - and save it to DB $arFields['DAV_XML_ID'] = $exchRes['XML_ID']; $arFields['DAV_EXCH_LABEL'] = $exchRes['MODIFICATION_LABEL']; } return true; }
public static function GetList($Params = array()) { global $DB, $USER; $arFilter = $Params['arFilter']; $arOrder = isset($Params['arOrder']) ? $Params['arOrder'] : array('SORT' => 'asc'); $Params['joinTypeInfo'] = !!$Params['joinTypeInfo']; $checkPermissions = $Params['checkPermissions'] !== false; $bCache = CCalendar::CacheTime() > 0; if ($bCache) { $cache = new CPHPCache(); $cacheId = serialize(array('section_list', $arFilter, $arOrder, $Params['joinTypeInfo'], CCalendar::IsIntranetEnabled())); $cachePath = CCalendar::CachePath() . 'section_list'; if ($cache->InitCache(CCalendar::CacheTime(), $cacheId, $cachePath)) { $res = $cache->GetVars(); $arResult = $res["arResult"]; $arSectionIds = $res["arSectionIds"]; } } if (!$bCache || !isset($arSectionIds)) { $arFields = self::GetFields(); $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 == 'ID' || $n == 'XML_ID' || $n == 'OWNER_ID') { $arSqlSearch[] = GetFilterQuery("CS." . $n, $val, 'N'); } elseif ($n == 'CAL_TYPE' && is_array($val)) { $strType = ""; foreach ($val as $type) { $strType .= ",'" . CDatabase::ForSql($type) . "'"; } $arSqlSearch[] = "CS.CAL_TYPE in (" . trim($strType, ", ") . ")"; $arSqlSearch[] = "CT.ACTIVE='Y'"; } elseif (isset($arFields[$n])) { $arSqlSearch[] = GetFilterQuery($arFields[$n]["FIELD_NAME"], $val, isset($arFields[$n]["PROCENT"]) && $arFields[$n]["PROCENT"] == "N" ? "N" : "Y"); } } } $strOrderBy = ''; foreach ($arOrder as $by => $order) { if (isset($arFields[strtoupper($by)])) { $strOrderBy .= $arFields[strtoupper($by)]["FIELD_NAME"] . ' ' . (strtolower($order) == 'desc' ? 'desc' . (strtoupper($DB->type) == "ORACLE" ? " NULLS LAST" : "") : 'asc' . (strtoupper($DB->type) == "ORACLE" ? " NULLS FIRST" : "")) . ','; } } if (strlen($strOrderBy) > 0) { $strOrderBy = "ORDER BY " . rtrim($strOrderBy, ","); } $strSqlSearch = GetFilterSqlSearch($arSqlSearch); if (isset($arFilter['ADDITIONAL_IDS']) && is_array($arFilter['ADDITIONAL_IDS']) && count($arFilter['ADDITIONAL_IDS']) > 0) { $strTypes = ""; foreach ($arFilter['ADDITIONAL_IDS'] as $adid) { $strTypes .= "," . IntVal($adid); } $strSqlSearch = '(' . $strSqlSearch . ') OR ID in(' . trim($strTypes, ', ') . ')'; } $select = 'CS.*'; $from = 'b_calendar_section CS'; // Fetch types info into selection if ($Params['joinTypeInfo']) { $select .= ", CT.NAME AS TYPE_NAME, CT.DESCRIPTION AS TYPE_DESC"; $from .= "\n INNER JOIN b_calendar_type CT ON (CS.CAL_TYPE=CT.XML_ID)"; } $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\t{$select}\n\t\t\t\tFROM\n\t\t\t\t\t{$from}\n\t\t\t\tWHERE\n\t\t\t\t\t{$strSqlSearch}\n\t\t\t\t{$strOrderBy}"; $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); $arResult = array(); $arSectionIds = array(); $isExchangeEnabled = CCalendar::IsExchangeEnabled(); $isCalDAVEnabled = CCalendar::IsCalDAVEnabled(); while ($arRes = $res->Fetch()) { $arRes['COLOR'] = CCalendar::Color($arRes['COLOR'], true); $arSectionIds[] = $arRes['ID']; if (isset($arRes['EXPORT']) && $arRes['EXPORT'] != "") { $arRes['EXPORT'] = unserialize($arRes['EXPORT']); if (is_array($arRes['EXPORT']) && $arRes['EXPORT']['ALLOW']) { $arRes['EXPORT']['LINK'] = self::GetExportLink($arRes['ID'], $arRes['CAL_TYPE'], $arRes['OWNER_ID']); } } if (!is_array($arRes['EXPORT'])) { $arRes['EXPORT'] = array('ALLOW' => false, 'SET' => false, 'LINK' => false); } // Outlook js if (CCalendar::IsIntranetEnabled()) { $arRes['OUTLOOK_JS'] = CCalendarSect::GetOutlookLink(array('ID' => intVal($arRes['ID']), 'XML_ID' => $arRes['XML_ID'], 'TYPE' => $arRes['CAL_TYPE'], 'NAME' => $arRes['NAME'], 'PREFIX' => CCalendar::GetOwnerName($arRes['CAL_TYPE'], $arRes['OWNER_ID']), 'LINK_URL' => CCalendar::GetOuterUrl())); } if ($arRes['CAL_TYPE'] == 'user') { $arRes['IS_EXCHANGE'] = strlen($arRes["DAV_EXCH_CAL"]) > 0 && $isExchangeEnabled; if ($arRes["CAL_DAV_CON"] && $isCalDAVEnabled) { $arRes["CAL_DAV_CON"] = intVal($arRes["CAL_DAV_CON"]); $resCon = CDavConnection::GetList(array("ID" => "ASC"), array("ID" => $arRes["CAL_DAV_CON"])); if ($con = $resCon->Fetch()) { $arRes['CAL_DAV_CON'] = $arRes["CAL_DAV_CON"]; } else { $arRes['CAL_DAV_CON'] = false; } } } else { $arRes['IS_EXCHANGE'] = false; $arRes['CAL_DAV_CON'] = false; } $arResult[] = $arRes; } if ($bCache) { $cache->StartDataCache(CCalendar::CacheTime(), $cacheId, $cachePath); $cache->EndDataCache(array("arResult" => $arResult, "arSectionIds" => $arSectionIds)); } } if ($checkPermissions && count($arSectionIds) > 0) { $userId = $Params['userId'] ? intVal($Params['userId']) : $USER->GetID(); $arPerm = CCalendarSect::GetArrayPermissions($arSectionIds); $res = array(); $arAccessCodes = array(); $settings = CCalendar::GetSettings(array('request' => false)); foreach ($arResult as $sect) { $sectId = $sect['ID']; $bOwner = $sect['CAL_TYPE'] == 'user' && $sect['OWNER_ID'] == $userId; $bManager = false; if (CModule::IncludeModule('intranet') && $sect['CAL_TYPE'] == 'user' && $settings['dep_manager_sub']) { if (!$userId) { $userId = CCalendar::GetUserId(); } $bManager = in_array($userId, CCalendar::GetUserManagers($sect['OWNER_ID'], true)); } if ($bOwner || $bManager || self::CanDo('calendar_view_time', $sectId)) { $sect['PERM'] = array('view_time' => $bManager || $bOwner || self::CanDo('calendar_view_time', $sectId, $userId), 'view_title' => $bManager || $bOwner || self::CanDo('calendar_view_title', $sectId, $userId), 'view_full' => $bManager || $bOwner || self::CanDo('calendar_view_full', $sectId, $userId), 'add' => $bOwner || self::CanDo('calendar_add', $sectId, $userId), 'edit' => $bOwner || self::CanDo('calendar_edit', $sectId, $userId), 'edit_section' => $bOwner || self::CanDo('calendar_edit_section', $sectId, $userId), 'access' => $bOwner || self::CanDo('calendar_edit_access', $sectId, $userId)); if ($bOwner || self::CanDo('calendar_edit_access', $sectId, $userId)) { $sect['ACCESS'] = array(); if (count($arPerm[$sectId]) > 0) { // Add codes to get they full names for interface $arAccessCodes = array_merge($arAccessCodes, array_keys($arPerm[$sectId])); $sect['ACCESS'] = $arPerm[$sectId]; } } $res[] = $sect; } } CCalendar::PushAccessNames($arAccessCodes); $arResult = $res; } return $arResult; }
public static function DialogEditSection($Params) { $id = $Params['id']; $arTabs = array(array('name' => GetMessage('EC_SECT_BASE_TAB'), 'id' => $id . "sect-tab-0", 'active' => true), array('name' => GetMessage('EC_SECT_ACCESS_TAB'), 'id' => $id . "sect-tab-1")); ?> <div id="bxec_sect_d_<?php echo $id; ?> " class="bxec-popup"> <div style="width: 500px; height: 1px;"></div> <div class="bxec-d-tabs" id="<?php echo $id; ?> _editsect_tabs"> <?php foreach ($arTabs as $tab) { ?> <div class="bxec-d-tab <?php if ($tab['active']) { echo 'bxec-d-tab-act'; } ?> " title="<?php echo isset($tab['title']) ? $tab['title'] : $tab['name']; ?> " id="<?php echo $tab['id']; ?> " <?php if ($tab['show'] === false) { echo 'style="display:none;"'; } ?> > <b></b><div><span><?php echo $tab['name']; ?> </span></div><i></i> </div> <?php } ?> </div> <div class="bxec-d-cont"> <?php /* ####### TAB 0 : MAIN ####### */ ?> <div id="<?php echo $id; ?> sect-tab-0-cont" class="bxec-d-cont-div" style="display: block;"> <!-- Title --> <div class="bxec-popup-row"> <span class="bxec-field-label-2"><label for="<?php echo $id; ?> _edcal_name"><?php echo GetMessage('EC_T_NAME'); ?> :</label></span> <span class="bxec-field-val-2"><input type="text" id="<?php echo $id; ?> _edcal_name" style="width: 290px;"/></span> </div> <!-- Description --> <div class="bxec-popup-row"> <span class="bxec-field-label-2"><label for="<?php echo $id; ?> _edcal_desc"><?php echo GetMessage('EC_T_DESC'); ?> :</label></span> <span class="bxec-field-val-2"><textarea cols="32" id="<?php echo $id; ?> _edcal_desc" rows="2" style="width: 290px; resize: none;"></textarea></span> </div> <!-- Color --> <div class="bxec-popup-row"> <span class="bxec-field-label-2"><label for="<?php echo $id; ?> -sect-color-inp"><?php echo GetMessage('EC_T_COLOR'); ?> :</label></span> <span class="bxec-field-val-2" style="width: 300px;"> <?php CCalendarSceleton::DisplayColorSelector($id, 'sect', $Params['colors']); ?> </span> </div> <?php /*if($Params['type'] == 'user' && $Params['inPersonalCalendar']):?> <div class="bxec-popup-row" style="width: 480px;"> <input id="<?=$id?>_bxec_meeting_calendar" type="checkbox" value="Y"><label for="<?=$id?>_bxec_meeting_calendar"><?=GetMessage('EC_MEETING_CALENDAR')?></label> </div> <?endif;*/ ?> <div class="bxec-popup-row"> <input id="<?php echo $id; ?> _bxec_cal_exp_allow" type="checkbox" value="Y"><label for="<?php echo $id; ?> _bxec_cal_exp_allow"><?php echo GetMessage('EC_T_ALLOW_CALEN_EXP'); ?> </label> <div id="<?php echo $id; ?> _bxec_calen_exp_div" style="margin-top: 4px;"> <?php echo GetMessage('EC_T_CALEN_EXP_SET'); ?> : <select id="<?php echo $id; ?> _bxec_calen_exp_set"> <option value="all"><?php echo GetMessage('EC_T_CALEN_EXP_SET_ALL'); ?> </option> <option value="3_9"><?php echo GetMessage('EC_T_CALEN_EXP_SET_3_9'); ?> </option> <option value="6_12"><?php echo GetMessage('EC_T_CALEN_EXP_SET_6_12'); ?> </option> </select> </div> </div> <?php if ($Params['bExchangeConnected'] && CCalendar::IsExchangeEnabled() && $Params['type'] == 'user' && $Params['inPersonalCalendar']) { ?> <div class="bxec-popup-row"> <input id="<?php echo $id; ?> _bxec_cal_exch" type="checkbox" value="Y" checked="checked"><label for="<?php echo $id; ?> _bxec_cal_exch"><?php echo GetMessage('EC_CALENDAR_TO_EXCH'); ?> </label> </div> <?php } ?> <?php if ($Params['bShowSuperpose'] && $Params['inPersonalCalendar']) { ?> <div class="bxec-popup-row" id="<?php echo $id; ?> _bxec_cal_add2sp_cont"> <input id="<?php echo $id; ?> _bxec_cal_add2sp" type="checkbox" value="Y"><label for="<?php echo $id; ?> _bxec_cal_add2sp"><?php echo GetMessage('EC_T_ADD_TO_SP'); ?> </label> </div> <?php } ?> </div> <?php /* ####### END TAB 0 ####### */ ?> <?php /* ####### TAB 1 : ACCESS ####### */ ?> <div id="<?php echo $id; ?> sect-tab-1-cont" class="bxec-d-cont-div"> <?php /* <?=GetMessage('EC_CAL_STATUS')?>: <select id="<?=$id?>_cal_priv_status" style="width: 230px"> <option value="private" title="<?=GetMessage('EC_CAL_STATUS_PRIVATE')?>"><?=GetMessage('EC_CAL_STATUS_PRIVATE')?></option> <option value="time" title="<?=GetMessage('EC_CAL_STATUS_TIME')?>"><?=GetMessage('EC_CAL_STATUS_TIME')?></option> <option value="title" title="<?=GetMessage('EC_CAL_STATUS_TITLE')?>"><?=GetMessage('EC_CAL_STATUS_TITLE')?></option> <option value="full" selected="selected" title="<?=GetMessage('EC_CAL_STATUS_FULL')?>"><?=GetMessage('EC_CAL_STATUS_FULL')?></option> </select> */ ?> <div class="bxec-popup-row"> <div class="bxec-popup-row-title"><?php echo GetMessage('EC_SECT_ACCESS_TAB'); ?> </div> <div class="bxec-access-cont-row"> <div id="<?php echo $id; ?> access-values-cont" class="bxec-access-cont"></div> <?php self::GetAccessHTML('calendar_section'); ?> <div class="bxec-access-link-cont"><a href="javascript:void(0);" id="<?php echo $id; ?> access-link" class="bxec-access-link"><?php echo GetMessage('EC_T_ADD'); ?> </a></div> </div> </div> </div> <?php /* ####### END TAB 1 ####### */ ?> </div> </div> <?php }
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) { $bCalDavCur = CCalendar::IsCalDAVEnabled() && $oCurEvent['CAL_TYPE'] == 'user' && strlen($oCurEvent['CAL_DAV_LABEL']) > 0; $bExchangeEnabledCur = CCalendar::IsExchangeEnabled() && $oCurEvent['CAL_TYPE'] == 'user'; if ($bExchangeEnabledCur || $bCalDavCur) { $res = CCalendar::DoDeleteToDav(array('bCalDav' => $bCalDavCur, 'bExchangeEnabled' => $bExchangeEnabledCur, 'sectionId' => $oCurEvent['SECT_ID']), $oCurEvent); if ($oCurEvent['DAV_EXCH_LABEL']) { $oCurEvent['DAV_EXCH_LABEL'] = ''; } if ($res !== true) { return CCalendar::ThrowError($res); } } } } $arDavFields = $arFields; CCalendarEvent::CheckFields($arDavFields); if ($arDavFields['RRULE'] != '') { $arDavFields['RRULE'] = $arFields['RRULE']; } $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']; } // **** 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 $arFields['DAV_XML_ID'] = $DAVRes['XML_ID']; $arFields['CAL_DAV_LABEL'] = $DAVRes['MODIFICATION_LABEL']; } elseif ($bExchange && $oSect['IS_EXCHANGE'] && strlen($oSect['DAV_EXCH_CAL']) > 0 && $oSect['DAV_EXCH_CAL'] !== 0) { $ownerId = $arFields['OWNER_ID']; $fromTo = CCalendarEvent::GetEventFromToForUser($arDavFields, $ownerId); $arDavFields["DATE_FROM"] = $fromTo['DATE_FROM']; $arDavFields["DATE_TO"] = $fromTo['DATE_TO']; // Convert BBcode to HTML for exchange $arDavFields["DESCRIPTION"] = CCalendarEvent::ParseText($arDavFields['DESCRIPTION']); // New event or move existent event to Exchange calendar if ($arFields['ID'] <= 0 || $oCurEvent && !$oCurEvent['DAV_EXCH_LABEL']) { $exchRes = CDavExchangeCalendar::DoAddItem($ownerId, $oSect['DAV_EXCH_CAL'], $arDavFields); } else { $exchRes = CDavExchangeCalendar::DoUpdateItem($ownerId, $oCurEvent['DAV_XML_ID'], $oCurEvent['DAV_EXCH_LABEL'], $arDavFields); } if (!is_array($exchRes) || !array_key_exists("XML_ID", $exchRes)) { return CCalendar::CollectExchangeErrors($exchRes); } // It's ok, we successfuly save event to exchange calendar - and save it to DB $arFields['DAV_XML_ID'] = $exchRes['XML_ID']; $arFields['DAV_EXCH_LABEL'] = $exchRes['MODIFICATION_LABEL']; } return true; }