CanDoOperation('edit_php')) // Is admin $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED")); $aTabs = array( array( "DIV" => "edit1", "TAB" => GetMessage("CAL_OPT_SETTINGS"), "ICON" => "calendar_settings", "TITLE" => GetMessage("CAL_SETTINGS_TITLE"), ), array( "DIV" => "edit2", "TAB" => GetMessage("CAL_OPT_TYPES"), "ICON" => "calendar_settings", "TITLE" => GetMessage("CAL_OPT_TYPES"), ) ); $tabControl = new CAdminTabControl("tabControl", $aTabs); CUtil::InitJSCore(array('ajax', 'window', 'popup', 'access')); $arTypes = CCalendarType::GetList(); $dbSites = CSite::GetList('sort', 'asc', array('ACTIVE' => 'Y')); $sites = array(); $default_site = ''; while ($arRes = $dbSites->GetNext()) { $sites[$arRes['ID']] = '('.$arRes['ID'].') '.$arRes['NAME']; if ($arRes['DEF'] == 'Y') $default_site = $arRes['ID']; } $arForums = array(); if (CModule::IncludeModule("forum")) { $db = CForumNew::GetListEx(); while ($ar = $db->GetNext()) $arForums[$ar["ID"]] = "[".$ar["ID"]."] ".$ar["NAME"]; } if ($REQUEST_METHOD == "POST" && isset($_REQUEST['save_type']) && $_REQUEST['save_type'] == 'Y' && check_bitrix_sessid()) { //CUtil::JSPostUnEscape(); $APPLICATION->RestartBuffer(); if (isset($_REQUEST['del_type']) && $_REQUEST['del_type'] == 'Y') { $xmlId = trim($_REQUEST['type_xml_id']); if ($xmlId != '') CCalendarType::Delete($xmlId); } else { $bNew = isset($_POST['type_new']) && $_POST['type_new'] == 'Y'; $xmlId = trim($bNew ? $_POST['type_xml_id'] : $_POST['type_xml_id_hidden']); $name = trim($_POST['type_name']); if ($xmlId != '' && $name != '') { $XML_ID = CCalendarType::Edit(array( 'NEW' => $bNew, 'arFields' => array( 'XML_ID' => $xmlId, 'NAME' => $name, 'DESCRIPTION' => trim($_POST['type_desc']) ) )); if ($XML_ID) { $arTypes_ = CCalendarType::GetList(array('arFilter' => array('XML_ID' => $XML_ID))); if ($arTypes_[0]) OutputTypeHtml($arTypes_[0]); } } } die(); } if($REQUEST_METHOD=="POST" && $Update.$Apply.$RestoreDefaults <> '' && check_bitrix_sessid()) { if($RestoreDefaults <> '') { COption::RemoveOption("calendar"); } else { // Save permissions for calendar types foreach($_POST['cal_type_perm'] as $xml_id => $perm) { // Save type permissions CCalendarType::Edit(array( 'NEW' => false, 'arFields' => array( 'XML_ID' => $xml_id, 'ACCESS' => $perm ) )); } $SET = array( 'work_time_start' => $_REQUEST['work_time_start'], 'work_time_end' => $_REQUEST['work_time_end'], 'year_holidays' => $_REQUEST['year_holidays'], 'year_workdays' => $_REQUEST['year_workdays'], 'week_holidays' => is_array($_REQUEST['week_holidays']) ? implode('|',$_REQUEST['week_holidays']) : '', //'week_start' => $_REQUEST['week_start'], 'user_name_template' => $_REQUEST['user_name_template'], 'sync_by_push' => isset($_REQUEST['sync_by_push']), 'user_show_login' => isset($_REQUEST['user_show_login']), 'path_to_user' => $_REQUEST['path_to_user'], 'path_to_user_calendar' => $_REQUEST['path_to_user_calendar'], 'path_to_group' => $_REQUEST['path_to_group'], 'path_to_group_calendar' => $_REQUEST['path_to_group_calendar'], 'path_to_vr' => $_REQUEST['path_to_vr'], 'path_to_rm' => $_REQUEST['path_to_rm'], 'denied_superpose_types' => array(), 'pathes_for_sites' => isset($_REQUEST['pathes_for_sites']), 'pathes' => $_REQUEST['pathes'], 'dep_manager_sub' => isset($_REQUEST['dep_manager_sub']), 'forum_id' => intval($_REQUEST['calendar_forum_id']), 'rm_iblock_type' => $_REQUEST['rm_iblock_type'], 'rm_iblock_id' => $_REQUEST['rm_iblock_id'], 'rm_for_sites' => isset($_REQUEST['reserve_meetings_for_sites']) || count($sites) <= 1, 'rm_iblock_ids' => $_REQUEST['rm_iblock_ids'] ); foreach($arTypes as $type) { $pathType = 'path_to_type_'.$type['XML_ID']; if (isset($_REQUEST[$pathType])) { $SET[$pathType] = $_REQUEST[$pathType]; } } if (CModule::IncludeModule("video")) { $SET['vr_iblock_id'] = $_REQUEST['vr_iblock_id']; } foreach($arTypes as $type) { if ( isset($_REQUEST['denied_superpose_types']) && is_array($_REQUEST['denied_superpose_types']) && !in_array($type['XML_ID'], $_REQUEST['denied_superpose_types']) ) { $SET['denied_superpose_types'][] = $type['XML_ID']; } } $CUR_SET = CCalendar::GetSettings(array('getDefaultForEmpty' => false)); foreach($CUR_SET as $key => $value) { if (!isset($SET[$key]) && isset($value)) $SET[$key] = $value; } CCalendar::SetSettings($SET); } if($Update <> '' && $_REQUEST["back_url_settings"] <> '') LocalRedirect($_REQUEST["back_url_settings"]); else LocalRedirect($APPLICATION->GetCurPage()."?mid=".urlencode($mid)."&lang=".urlencode(LANGUAGE_ID)."&back_url_settings=".urlencode($_REQUEST["back_url_settings"])."&".$tabControl->ActiveTabParam()); } $dbIBlockType = CIBlockType::GetList(); $arIBTypes = array(); $arIB = array(); while ($arIBType = $dbIBlockType->Fetch()) { if ($arIBTypeData = CIBlockType::GetByIDLang($arIBType["ID"], LANG)) { $arIB[$arIBType['ID']] = array(); $arIBTypes[$arIBType['ID']] = '['.$arIBType['ID'].'] '.$arIBTypeData['NAME']; } } $dbIBlock = CIBlock::GetList(array('SORT' => 'ASC'), array('ACTIVE' => 'Y')); while ($arIBlock = $dbIBlock->Fetch()) { $arIB[$arIBlock['IBLOCK_TYPE_ID']][$arIBlock['ID']] = ($arIBlock['CODE'] ? '['.$arIBlock['CODE'].'] ' : '').$arIBlock['NAME']; } $SET = CCalendar::GetSettings(array('getDefaultForEmpty' => false, 'site' => false)); $tabControl->Begin(); ?>