function Show($Params) { global $APPLICATION, $USER, $EC_UserFields; $this->GetPermissions(array('userId' => $curUserId)); if (!$this->bAccess) { return $APPLICATION->ThrowException(GetMessage("EC_ACCESS_DENIED")); } if ($this->reserveMeetingReadonlyMode) { $this->bReadOnly = true; } $arCalendars = $this->GetCalendarsEx(); // Cache inside $sectionId = $this->GetSectionId(); // * * * HANDLE SUPERPOSED CALENDARS * * * if ($this->allowSuperpose) { $this->HandleSuperpose($this->arSPIblIds, true); } $arCalendarIds = $this->GetUserActiveCalendars(); // Show popup event at start if (isset($_GET['EVENT_ID']) && intVal($_GET['EVENT_ID']) > 0) { $eventId = intVal($_GET['EVENT_ID']); $bDelEvent = false; $rsEvent = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $this->iblockId, "ACTIVE" => "Y", "ID" => $eventId, "CHECK_PERMISSIONS" => "N"), false, false, array("ACTIVE_FROM", "IBLOCK_SECTION_ID", "CREATED_BY", "PROPERTY_CONFIRMED")); if ($ev = $rsEvent->Fetch()) { if ($ev["CREATED_BY"] == $USER->GetId() && isset($_GET['CONFIRM']) && $ev["PROPERTY_CONFIRMED_ENUM_ID"] == $this->GetConfirmedID($this->iblockId, "Q")) { $this->GenEventDynClose($eventId); if ($_GET['CONFIRM'] == 'Y') { $this->ClearCache($this->cachePath . 'events/' . $this->iblockId . '/'); $this->ConfirmEvent(array('id' => $eventId, 'bCheckOwner' => false)); } elseif ($_GET['CONFIRM'] == 'N') { $this->ClearCache($this->cachePath . 'events/' . $this->iblockId . '/'); CECEvent::Delete(array('id' => $eventId, 'iblockId' => $this->iblockId, 'ownerType' => $this->ownerType, 'ownerId' => $this->ownerId, 'userId' => $USER->GetId(), 'pathToUserCalendar' => $this->pathToUserCalendar, 'RMiblockId' => $this->allowResMeeting ? $this->RMiblockId : 0, 'allowResMeeting' => $this->allowResMeeting, 'VMiblockId' => $this->allowVideoMeeting ? $this->VMiblockId : 0, 'allowVideoMeeting' => $this->allowVideoMeeting)); $bDelEvent = true; // Event was deleted $eventId = false; } } elseif ($ev["CREATED_BY"] == $USER->GetId() && isset($_GET['CLOSE_MESS']) && $_GET['CLOSE_MESS'] == 'Y') { $this->GenEventDynClose($eventId); } if (!$bDelEvent) { // If user turn off this calendar if (!in_array($ev["IBLOCK_SECTION_ID"], $arCalendarIds)) { $arCalendarIds[] = $ev["IBLOCK_SECTION_ID"]; } if (!isset($_GET['EVENT_DATE'])) { $date = $ev['ACTIVE_FROM']; } else { $date = $_GET['EVENT_DATE']; } $ts = MakeTimeStamp($date, getTSFormat()); $startup_event_date = date(getDateFormat(false), $ts); $init_month = date('m', $ts); $init_year = date('Y', $ts); } } $arStartupEvent = $eventId ? array('id' => $eventId, 'date' => $startup_event_date) : false; } else { $arStartupEvent = false; } if (!$init_month && !$init_year && strlen($Params["initDate"]) > 0 && strpos($Params["initDate"], '.') !== false) { $ts = MakeTimeStamp($Params["initDate"], getTSFormat()); $init_month = date('m', $ts); $init_year = date('Y', $ts); } if (!isset($init_month)) { $init_month = date("m"); } if (!isset($init_year)) { $init_year = date("Y"); } $id = 'EC' . rand() . '_'; if (!isset($Params['weekHolidays'])) { $Params['weekHolidays'] = array(5, 6); } if ($Params["workTime"][0] <= 0) { $Params["workTime"][0] = 9; } if ($Params["workTime"][1] <= 0) { $Params["workTime"][1] = 19; } if (isset($Params['yearHolidays'])) { $Params['yearHolidays'] = explode(',', $Params['yearHolidays']); array_walk($Params['yearHolidays'], 'trim_'); } else { $Params['yearHolidays'] = array(); } $arCalColors = array('#CEE669', '#E6A469', '#98AEF6', '#7DDEC2', '#B592EC', '#D98E85', '#F6EA68', '#DDBFEB'); $arStrWeek = array(array(GetMessage('EC_MON_F'), GetMessage('EC_MON')), array(GetMessage('EC_TUE_F'), GetMessage('EC_TUE')), array(GetMessage('EC_WEN_F'), GetMessage('EC_WEN')), array(GetMessage('EC_THU_F'), GetMessage('EC_THU')), array(GetMessage('EC_FRI_F'), GetMessage('EC_FRI')), array(GetMessage('EC_SAT_F'), GetMessage('EC_SAT')), array(GetMessage('EC_SAN_F'), GetMessage('EC_SAN'))); $arStrMonth = array(GetMessage('EC_JAN'), GetMessage('EC_FEB'), GetMessage('EC_MAR'), GetMessage('EC_APR'), GetMessage('EC_MAY'), GetMessage('EC_JUN'), GetMessage('EC_JUL'), GetMessage('EC_AUG'), GetMessage('EC_SEP'), GetMessage('EC_OCT'), GetMessage('EC_NOV'), GetMessage('EC_DEC')); $arStrMonth_R = array(GetMessage('EC_JAN_R'), GetMessage('EC_FEB_R'), GetMessage('EC_MAR_R'), GetMessage('EC_APR_R'), GetMessage('EC_MAY_R'), GetMessage('EC_JUN_R'), GetMessage('EC_JUL_R'), GetMessage('EC_AUG_R'), GetMessage('EC_SEP_R'), GetMessage('EC_OCT_R'), GetMessage('EC_NOV_R'), GetMessage('EC_DEC_R')); $EC_UserFields = false; $this->CheckSectionProperties($this->iblockId, $this->ownerType); $UserSettings = $this->GetUserSettings(); if (!$this->bReadOnly && count($arCalendars) > 0) { $this->bShowBanner = true; } if (isset($UserSettings['ShowBanner']) && !$UserSettings['ShowBanner']) { $this->bShowBanner = false; } $JSConfig = array('sessid' => bitrix_sessid(), 'month' => $arStrMonth, 'month_r' => $arStrMonth_R, 'days' => $arStrWeek, 'id' => $id, 'week_holidays' => $Params['weekHolidays'], 'year_holidays' => $Params['yearHolidays'], 'iblockId' => $this->iblockId, 'init_month' => $init_month, 'init_year' => $init_year, 'arCalColors' => $arCalColors, 'bReadOnly' => $this->bReadOnly, 'ownerType' => $this->ownerType, 'ownerId' => $this->ownerId, 'userId' => $this->userId, 'userName' => $this->userName, 'section_id' => $sectionId, 'arCalendars' => $arCalendars, 'arCalendarIds' => $arCalendarIds, 'page' => $this->pageUrl, 'fullUrl' => $this->fullUrl, 'startupEvent' => $arStartupEvent, 'bSuperpose' => $this->bSuperpose, 'arSPCalendars' => $this->arSPCal, 'arSPCalendarsShow' => $this->arSPCalShow, 'superposeExportLink' => $this->superposeExportLink, 'bSPUserCals' => $this->superposeUsersCals || $this->superposeCurUserCals, 'SP' => $this->GetCurCalsSPParams(), 'allowAdd2SP' => $this->allowAdd2SP, 'workTime' => $Params["workTime"], 'Settings' => $UserSettings, 'bSocNet' => $this->bSocNet, 'pathToUser' => $this->pathToUser, 'dateFormat' => CSite::GetDateFormat("SHORT", SITE_ID), 'meetingRooms' => $this->GetMeetingRoomList(), 'allowResMeeting' => $this->allowResMeeting, 'allowVideoMeeting' => $this->allowVideoMeeting, 'bExtranet' => $this->bExtranet, 'bShowBanner' => $this->bShowBanner, 'planner_js_src' => '/bitrix/js/intranet/event_calendar/planner.js?v=' . filemtime($_SERVER['DOCUMENT_ROOT'] . "/bitrix/js/intranet/event_calendar/planner.js"), 'reserveMeetingReadonlyMode' => $this->reserveMeetingReadonlyMode); if ($this->reserveMeetingReadonlyMode) { $JSConfig['pathToReserveNew'] = $this->pathToReserveNew; } if (CEventCalendar::IsCalDAVEnabled() && $this->ownerType == "USER") { $JSConfig['bCalDAV'] = true; if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) { $serverName = SITE_SERVER_NAME; } else { $serverName = COption::GetOptionString("main", "server_name", $_SERVER["SERVER_NAME"]); } $JSConfig['caldav_link_all'] = (CMain::IsHTTPS() ? "https://" : "http://") . $serverName; if ($this->ownerType == 'USER') { if ($this->ownerId == $this->userId) { $login = $USER->GetLogin(); } else { $rsUser = CUser::GetByID($this->ownerId); if ($arUser = $rsUser->Fetch()) { $login = $arUser['LOGIN']; } } $JSConfig['caldav_link_one'] = (CMain::IsHTTPS() ? "https://" : "http://") . $_SERVER["SERVER_NAME"] . "/bitrix/groupdav.php/" . SITE_ID . "/" . $login . "/calendar/#CALENDAR_ID#/"; } else { if ($this->ownerType == 'GROUP') { $JSConfig['caldav_link_one'] = (CMain::IsHTTPS() ? "https://" : "http://") . $_SERVER["SERVER_NAME"] . "/bitrix/groupdav.php/" . SITE_ID . "/group-" . $this->ownerId . "/calendar/#CALENDAR_ID#/"; } } if ($this->ownerType == 'USER') { $res = CDavConnection::GetList(array("ID" => "DESC"), array("ENTITY_TYPE" => "user", "ENTITY_ID" => $this->ownerId, "ACCOUNT_TYPE" => 'caldav'), false, false); $arConnections = array(); while ($arCon = $res->Fetch()) { $arConnections[] = array('id' => $arCon['ID'], 'name' => $arCon['NAME'], 'link' => $arCon['SERVER'], 'user_name' => $arCon['SERVER_USERNAME'], 'last_result' => $arCon['LAST_RESULT'], 'sync_date' => $arCon['SYNCHRONIZED']); } $JSConfig['connections'] = $arConnections; } } if (CEventCalendar::IsExchangeEnabled() && $this->ownerType == 'USER') { $JSConfig['bExchange'] = true; } $from_limit = date(getDateFormat(false), mktime(0, 0, 0, $init_month - 1, 20, $init_year)); $to_limit = date(getDateFormat(false), mktime(0, 0, 0, $init_month + 1, 10, $init_year)); $this->SetLoadLimits($init_month, $init_year); if ($sectionId !== false) { // Get events (*Cache Inside) $ids = array(); for ($i = 0, $l = count($arCalendars); $i < $l; $i++) { if (in_array($arCalendars[$i]['ID'], $arCalendarIds)) { $ids[] = $arCalendars[$i]['ID']; } } $JS_arEvents = $this->GetEventsEx(array("bJS" => true, "arCalendarIds" => $ids, 'DontSaveOptions' => true, 'checkPermissions' => false)); // Get events from superposed calendars *Favorite calendars* $JS_arSPEvents = $this->GetSuperposedEvents(array('bJS' => true)); } else { $JS_arEvents = '[]'; $JS_arSPEvents = '[]'; } $APPLICATION->AddHeadString('<link rel="stylesheet" type="text/css" href="' . CUtil::GetAdditionalFileURL("/bitrix/js/intranet/event_calendar/event_calendar.css") . '">'); // Build calendar base html and dialogs CEventCalendar::BuildCalendarSceleton(array('bExtranet' => $this->bExtranet, 'bReadOnly' => $this->bReadOnly, 'id' => $id, 'arCalendarsCount' => count($arCalendars), 'allowSuperpose' => $this->allowSuperpose, 'bSocNet' => $this->bSocNet, 'week_days' => $arStrWeek, 'ownerId' => $this->ownerId, 'ownerType' => $this->ownerType, 'component' => $component, 'bShowBanner' => $this->bShowBanner)); // Append Javascript files and CSS files $this->AppendJS(array('JSConfig' => CUtil::PhpToJSObject($JSConfig), 'JS_arEvents' => $JS_arEvents, 'JS_arSPEvents' => $JS_arSPEvents)); }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } CEventCalendar::BuildCalendarSceleton(array('bExtranet' => $arResult['bExtranet'], 'bReadOnly' => $arResult['bReadOnly'], 'id' => $arResult['id'], 'arCalendarsCount' => $arResult['arCalendarsCount'], 'bSuperpose' => $arResult['bSuperpose'], 'bSocNet' => $arResult['bSocNet'], 'week_days' => $arResult['week_days'], 'ownerType' => $arResult['ownerType'], 'component' => $component, 'JSConfig' => $arResult['JSConfig'], 'JS_arEvents' => $arResult['JS_arEvents'], 'JS_arSPEvents' => $arResult['JS_arSPEvents'], 'bShowOutlookBanner' => $arResult['bShowOutlookBanner']));