コード例 #1
0
ファイル: calendar.php プロジェクト: andy-profi/bxApiDocs
 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;
 }
コード例 #2
0
 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;
 }
コード例 #3
0
    public static function Build($Params)
    {
        global $APPLICATION;
        $id = $Params['id'];
        $Tabs = array(array('name' => GetMessage('EC_TAB_MONTH'), 'title' => GetMessage('EC_TAB_MONTH_TITLE'), 'id' => $id . "_tab_month"), array('name' => GetMessage('EC_TAB_WEEK'), 'title' => GetMessage('EC_TAB_WEEK_TITLE'), 'id' => $id . "_tab_week"), array('name' => GetMessage('EC_TAB_DAY'), 'title' => GetMessage('EC_TAB_DAY_TITLE'), 'id' => $id . "_tab_day"));
        $bCalDAV = CCalendar::IsCalDAVEnabled() && $Params['type'] == 'user';
        // Here can be added user's dialogs, scripts, html
        foreach (GetModuleEvents("calendar", "OnBeforeBuildSceleton", true) as $arEvent) {
            ExecuteModuleEventEx($arEvent);
        }
        $days = self::GetWeekDaysEx(CCalendar::GetWeekStart());
        ?>
<script>
/* Event handler for user control*/
function bxcUserSelectorOnchange(arUsers){BX.onCustomEvent(window, 'onUserSelectorOnChange', [arUsers]);}
</script>
		<?php 
        if ($Params['bShowSections'] || $Params['bShowSuperpose'] || $Params['bShowBanner']) {
            ?>
<div class="bxec-sect-cont" id="<?php 
            echo $id;
            ?>
_sect_cont">
	<b class="r2"></b><b class="r1"></b><b class="r0"></b>
		<?php 
            if ($Params['bShowSections']) {
                ?>
		<span class="bxec-sect-cont-wrap" id="<?php 
                echo $id;
                ?>
sections">
			<b class="r-2"></b><b class="r-1"></b><b class="r-0"></b>
			<div class="bxec-sect-cont-inner">
				<div class="bxec-sect-title"><span class="bxec-spr bxec-flip"></span><span class="bxec-sect-title-text"><?php 
                echo GetMessage('EC_T_CALENDARS');
                ?>
</span>
				<a id="<?php 
                echo $id;
                ?>
-add-section" class="bxec-sect-top-action" href="javascript:void(0);" title="<?php 
                echo GetMessage('EC_ADD_CAL_TITLE');
                ?>
"  hidefocus="true" style="visibility:hidden;"><?php 
                echo strtolower(GetMessage('EC_T_ADD'));
                ?>
</a>
				</div>
				<div class="bxec-sect-cont-white">
					<div id="<?php 
                echo $id;
                ?>
sections-cont"></div>
					<?php 
                if ($Params['bShowTasks']) {
                    ?>
					<div id="<?php 
                    echo $id;
                    ?>
tasks-sections-cont"></div>
					<?php 
                }
                ?>
					<div id="<?php 
                echo $id;
                ?>
caldav-sections-cont"></div>
				</div>
			</div>
			<i class="r-0"></i><i class="r-1"></i><i class="r-2"></i>
		</span>
		<?php 
            }
            /*bShowSections*/
            ?>

		<?php 
            if ($Params['bShowSuperpose']) {
                ?>
		<span class="bxec-sect-cont-wrap" id="<?php 
                echo $id;
                ?>
sp-sections">
			<b class="r-2"></b><b class="r-1"></b><b class="r-0"></b>
			<div class="bxec-sect-cont-inner bxec-sect-superpose">
				<div class="bxec-sect-title"><span class="bxec-spr bxec-flip"></span><span class="bxec-sect-title-text"><?php 
                echo GetMessage('EC_T_SP_CALENDARS');
                ?>
</span>
				<a id="<?php 
                echo $id;
                ?>
-manage-superpose" class="bxec-sect-top-action" href="javascript:void(0);" title="<?php 
                echo GetMessage('EC_ADD_EX_CAL_TITLE');
                ?>
"  hidefocus="true" style="visibility:hidden;"><?php 
                echo strtolower(GetMessage('EC_ADD_EX_CAL'));
                ?>
</a>
				</div>
				<div class="bxec-sect-cont-white"  id="<?php 
                echo $id;
                ?>
sp-sections-cont"></div>
			</div>
			<i class="r-0"></i><i class="r-1"></i><i class="r-2"></i>
		</span>
		<?php 
            }
            /*bShowSuperpose*/
            ?>

		<?php 
            if ($Params['bShowBanner']) {
                ?>
		<span class="bxec-sect-cont-wrap" id="<?php 
                echo $id;
                ?>
banner">
			<div class="bxec-sect-cont-inner bxec-sect-banner">
				<div class="bxec-banner">
					<?php 
                if ($Params['bOutlook']) {
                    ?>
					<div class="bxec-banner-elem bxec-ban-outlook">
						<i></i>
						<span class="bxec-banner-text" id="<?php 
                    echo $id;
                    ?>
_outl_sel"><span><?php 
                    echo GetMessage('EC_BAN_CONNECT_OUTL');
                    ?>
</span><b class="bxec-ban-arrow"></b></span>
					</div>
					<?php 
                }
                ?>
					<?php 
                if ($Params['bCalDAV']) {
                    ?>
					<div class="bxec-banner-elem bxec-ban-mobile">
						<i></i>
						<span class="bxec-banner-text" id="<?php 
                    echo $id;
                    ?>
_mob_sel" <?php 
                    if (strlen(GetMessage('EC_BAN_CONNECT_MOBI')) < 30) {
                        echo 'style="margin-top:9px!important;"';
                    }
                    ?>
><span><?php 
                    echo GetMessage('EC_BAN_CONNECT_MOBI');
                    ?>
</span><b class="bxec-ban-arrow"></b></span>
					</div>
					<?php 
                }
                ?>

					<?php 
                if ($Params['bExchange']) {
                    ?>
					<div class="bxec-banner-elem bxec-ban-exch<?php 
                    if ($Params['bExchangeConnected']) {
                        echo ' bxec-ban-exch-connected';
                    }
                    ?>
" title="<?php 
                    echo $Params['bExchangeConnected'] ? GetMessage('EC_BAN_CONNECT_EXCH_TITLE') : GetMessage('EC_BAN_NOT_CONNECT_EXCH_TITLE');
                    ?>
">
						<i></i>
						<span class="bxec-banner-text">
						<span class="bxec-banner-text-ok">
							<?php 
                    echo GetMessage('EC_BAN_CONNECT_EXCH');
                    ?>
							<a href="javascript:void('');"  id="<?php 
                    echo $id;
                    ?>
_exch_sync" title="<?php 
                    echo GetMessage('EC_BAN_EXCH_SYNC_TITLE');
                    ?>
"><?php 
                    echo GetMessage('EC_BAN_EXCH_SYNC');
                    ?>
</a>
						</span>
						<span class="bxec-banner-text-warn">
							<?php 
                    echo GetMessage('EC_BAN_NOT_CONNECT_EXCH');
                    ?>
						</span>
						</span>
						<span class="bxec-banner-status"></span>
					</div>
					<?php 
                }
                ?>
					<a href="javascript:void('');" class="bxec-close"  id="<?php 
                echo $id;
                ?>
_ban_close" title="<?php 
                echo GetMessage('EC_T_CLOSE');
                ?>
"></a>
				</div>
			</div>
		</span>
		<?php 
            }
            /*bShowBanner*/
            ?>
	<i class="r0"></i><i class="r1"></i><i class="r2"></i>
</div>
		<?php 
        }
        /* bShowSections || bShowSuperpose || bShowBanner*/
        ?>

<div class="bxcal-loading" id="<?php 
        echo $id;
        ?>
_bxcal" style="">
<div class="bxcal-wait"></div>
<div class="bxec-tabs-cnt">
	<div class="bxec-tabs-div">
		<?php 
        foreach ($Tabs as $tab) {
            ?>
		<div class="bxec-tab-div" title="<?php 
            echo $tab['title'];
            ?>
" id="<?php 
            echo $tab['id'];
            ?>
">
			<b></b><div class="bxec-tab-c"><span><?php 
            echo $tab['name'];
            ?>
</span></div><i></i>
		</div>
		<?php 
        }
        ?>
	</div>
	<div class="bxec-bot-bg"></div>

	<div class="bxec-view-selector-cont">
		<div id="<?php 
        echo $id;
        ?>
_selector" class="bxec-selector-cont">
		<a class="bxec-sel-left"  id="<?php 
        echo $id;
        ?>
selector-prev"></a>
		<span class="bxec-sel-cont">
			<a class="bxec-sel-but" id="<?php 
        echo $id;
        ?>
selector-cont"><b></b><span class="bxec-sel-but-inner" id="<?php 
        echo $id;
        ?>
selector-cont-inner"><span class="bxec-sel-but-arr"></span></span><i></i></a>
		</span>
		<a class="bxec-sel-right" id="<?php 
        echo $id;
        ?>
selector-next"></a>
		</div>
		<div id="bxec_month_win_<?php 
        echo $id;
        ?>
" class="bxec-month-dialog">
			<div class="bxec-md-year-selector">
				<a class="bxec-sel-left"  id="<?php 
        echo $id;
        ?>
md-selector-prev"></a>
				<span class="bxec-md-year-text"><span class="bxec-md-year-text-inner" id="<?php 
        echo $id;
        ?>
md-year"></span></span>
				<a class="bxec-sel-right" id="<?php 
        echo $id;
        ?>
md-selector-next"></a>
			</div>
			<div class="bxec-md-month-list"  id="<?php 
        echo $id;
        ?>
md-month-list"></div>
		</div>
	</div>
	<div id="<?php 
        echo $id;
        ?>
_buttons_cont" class="bxec-buttons-cont"></div>
</div>
<div>
	<table class="BXEC-Calendar" cellPadding="0" cellSpacing="0" id="<?php 
        echo $id;
        ?>
_scel_table_month" style="display:none;">
	<tr class="bxec-days-title"><td>
		<!--Don't insert spases inside DOM layout!-->
		<div id="<?php 
        echo $id;
        ?>
_days_title" class="bxc-month-title"><?php 
        foreach ($days as $day) {
            ?>
<b id="<?php 
            echo $id . '_' . $day['2'];
            ?>
" title="<?php 
            echo $day['0'];
            ?>
"><i><?php 
            echo $day['1'];
            ?>
</i></b><?php 
        }
        ?>
</div>
	</td></tr>
	<tr><td class="bxec-days-grid-td"><div id="<?php 
        echo $id;
        ?>
_days_grid" class="bxec-days-grid-cont"></div>
	</td></tr>
	</table>
	<table class="BXEC-Calendar-week" id="<?php 
        echo $id;
        ?>
_scel_table_week" cellPadding="0" cellSpacing="0" style="display:none;">
		<tr class="bxec-days-tbl-title"><td class="bxec-pad"><div class="bxec-day-t-event-holder"></div><img src="/bitrix/images/1.gif" width="40" height="1"/></td><td class="bxec-pad2"><img src="/bitrix/images/1.gif" width="16" height="1"/></td></tr>
		<tr class="bxec-days-tbl-more-ev"><td class="bxec-pad"></td><td class="bxec-pad2"></td></tr>
		<tr class="bxec-days-tbl-grid"><td class="bxec-cont"><div class="bxec-timeline-div"></div></td></tr>
	</table>
	<table class="BXEC-Calendar-week" id="<?php 
        echo $id;
        ?>
_scel_table_day" cellPadding="0" cellSpacing="0" style="display:none;">
		<tr class="bxec-days-tbl-title"><td class="bxec-pad"><div class="bxec-day-t-event-holder"></div><img src="/bitrix/images/1.gif" width="40" height="1" /></td></tr>
		<tr class="bxec-days-tbl-more-ev"><td class="bxec-pad"></td></tr>
		<tr class="bxec-days-tbl-grid"><td class="bxec-cont" colSpan="2"><div class="bxec-timeline-div"></div></td></tr>
	</table>
</div>
</div>
<?php 
        self::BuildDialogs($Params);
        if ($Params['bShowTasks']) {
            ?>
<script>
// Js event handlers which will be captured in calendar's js
function onPopupTaskAdded(arTask){BX.onCustomEvent(window, 'onCalendarPopupTaskAdded', [arTask]);}
function onPopupTaskChanged(arTask){BX.onCustomEvent(window, 'onCalendarPopupTaskChanged', [arTask]);}
function onPopupTaskDeleted(taskId){BX.onCustomEvent(window, 'onCalendarPopupTaskDeleted', [taskId]);}
</script>
		<?php 
            $APPLICATION->IncludeComponent("bitrix:tasks.iframe.popup", "", array("ON_TASK_ADDED" => "onPopupTaskAdded", "ON_TASK_CHANGED" => "onPopupTaskChanged", "ON_TASK_DELETED" => "onPopupTaskDeleted", "TASKS_LIST" => $Params['arTaskIds']), null, array("HIDE_ICONS" => "Y"));
        }
        // Here can be added user's dialogs, scripts, html
        foreach (GetModuleEvents("calendar", "OnAfterBuildSceleton", true) as $arEvent) {
            ExecuteModuleEventEx($arEvent);
        }
    }
コード例 #4
0
ファイル: calendar.php プロジェクト: DarneoStudio/bitrix
 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;
 }