Beispiel #1
0
            foreach (GetModuleEvents("photogallery", "OnAfterPhotoDrop", true) as $arEvent) {
                ExecuteModuleEventEx($arEvent, array($arEventFields, $arParams));
            }
            PClearComponentCacheEx($arParams["IBLOCK_ID"], array(0, $arParams["SECTION_ID"]));
        } else {
            ?>
			<script>
				window.bxph_error = '<?php 
            echo GetMessage("DEL_ITEM_ERROR") . ($ex = $APPLICATION->GetException() ? ': ' . $ex->GetString() : '');
            ?>
';
			</script>
			<?php 
        }
    } elseif ($photo_list_action == 'edit' && $arParams["PERMISSION"] >= "U") {
        CUtil::JSPostUnEscape();
        CModule::IncludeModule("iblock");
        if (intVal($_REQUEST["SECTION_ID"]) > 0) {
            $arParams["SECTION_ID"] = intVal($_REQUEST["SECTION_ID"]);
        }
        if (!$arParams["USER_ALIAS"] && isset($_REQUEST["USER_ALIAS"])) {
            $arParams["USER_ALIAS"] = $_REQUEST["USER_ALIAS"];
        }
        // Don't delete <!--BX_PHOTO_EDIT_RES-->, <!--BX_PHOTO_EDIT_RES_END--> comments - they are used in js to catch html content
        ?>
<!--BX_PHOTO_EDIT_RES--><?php 
        $APPLICATION->IncludeComponent("bitrix:photogallery.detail.edit", "", array("IBLOCK_TYPE" => $arParams["IBLOCK_TYPE"], "IBLOCK_ID" => $arParams["IBLOCK_ID"], "USER_ALIAS" => $arParams["USER_ALIAS"], "PERMISSION" => $arParams["PERMISSION"], "SECTION_ID" => $arParams["SECTION_ID"], "SECTION_CODE" => $arParams["SECTION_CODE"], "ELEMENT_ID" => $arParams["ELEMENT_ID"], "BEHAVIOUR" => $arParams["BEHAVIOUR"], "ACTION" => "EDIT", "GALLERY_URL" => $arResult["URL_TEMPLATES"]["gallery"], "DETAIL_URL" => $arResult["URL_TEMPLATES"]["detail"], "SECTION_URL" => $arResult["URL_TEMPLATES"]["section"], "DATE_TIME_FORMAT" => $arParams["DATE_TIME_FORMAT_DETAIL"], "SHOW_TAGS" => $arParams["SHOW_TAGS"], "GALLERY_SIZE" => $arParams["GALLERY_SIZE"], "SET_STATUS_404" => $arParams["SET_STATUS_404"], "CACHE_TYPE" => $arParams["CACHE_TYPE"], "CACHE_TIME" => $arParams["CACHE_TIME"], "DISPLAY_PANEL" => $arParams["DISPLAY_PANEL"], "SET_TITLE" => "N", "ADD_CHAIN_ITEM" => "N", "SHOW_PUBLIC" => "N", "SHOW_APPROVE" => "N", "SHOW_TITLE" => "N", "SEARCH_URL" => $arParams["SEARCH_URL"], "~RESTART_BUFFER" => false), $component);
        ?>
<!--BX_PHOTO_EDIT_RES_END--><?php 
    }
    die;
Beispiel #2
0
	public static function RequestAction($action = '')
	{
		global $USER, $APPLICATION;
		$result = array();

		switch($action)
		{
			case "load_site_template":
				if (!$USER->CanDoOperation('fileman_view_file_structure'))
					break;
				$siteTemplate = $_REQUEST['site_template'];
				$siteId = isset($_REQUEST['site_id']) ? $_REQUEST['site_id'] : SITE_ID;
				$result = self::GetSiteTemplateParams($siteTemplate, $siteId);
				break;
			case "load_components_list":
				if (!$USER->CanDoOperation('fileman_view_file_structure'))
					break;
				$siteTemplate = $_REQUEST['site_template'];
				$result = self::GetComponents($siteTemplate, true);
				break;

			case "video_oembed":
				$result = self::GetVideoOembed($_REQUEST['video_source']);
				break;

			// Snippets actions
			case "load_snippets_list":
				if (!$USER->CanDoOperation('fileman_view_file_structure'))
					break;
				$template = $_REQUEST['site_template'];
				$result = array(
					'result' => true,
					'snippets' => array($template => self::GetSnippets($template, $_REQUEST['clear_cache'] == 'Y'))
				);
				break;
			case "edit_snippet":
				if (!$USER->CanDoOperation('fileman_view_file_structure'))
					break;
				CUtil::JSPostUnEscape();
				$template = $_REQUEST['site_template'];

				// Update
				if ($_REQUEST['current_path'])
				{
					$result = CSnippets::Update(array(
						'template' => $template,
						'path' => $_REQUEST['path'],
						'code' => $_REQUEST['code'],
						'title' => $_REQUEST['name'],
						'current_path' => $_REQUEST['current_path'],
						'description' => $_REQUEST['description']
					));
				}
				// Add new
				else
				{
					$result = CSnippets::Add(array(
						'template' => $template,
						'path' => $_REQUEST['path'],
						'code' => $_REQUEST['code'],
						'title' => $_REQUEST['name'],
						'description' => $_REQUEST['description']
					));
				}

				if ($result && $result['result'])
				{
					$result['snippets'] = array($template => self::GetSnippets($template));
				}

				break;
			case "remove_snippet":
				if (!$USER->CanDoOperation('fileman_view_file_structure'))
					break;
				CUtil::JSPostUnEscape();
				$template = $_REQUEST['site_template'];

				$res = CSnippets::Remove(array(
					'template' => $template,
					'path' => $_REQUEST['path']
				));

				if ($res)
				{
					$result = array(
						'result' => true,
						'snippets' => array($template => self::GetSnippets($template))
					);
				}
				else
				{
					$result = array('result' => false);
				}

				break;
			case "snippet_add_category":
				if (!$USER->CanDoOperation('fileman_view_file_structure'))
					break;
				CUtil::JSPostUnEscape();
				$template = $_REQUEST['site_template'];
				$res = CSnippets::CreateCategory(array(
					'template' => $template,
					'name' => $_REQUEST['category_name'],
					'parent' => $_REQUEST['category_parent']
				));

				if ($res)
				{
					$result = array(
						'result' => true,
						'snippets' => array($template => self::GetSnippets($template))
					);
				}
				else
				{
					$result = array('result' => false);
				}
				break;
			case "snippet_remove_category":
				if (!$USER->CanDoOperation('fileman_view_file_structure'))
					break;
				CUtil::JSPostUnEscape();
				$template = $_REQUEST['site_template'];
				$res = CSnippets::RemoveCategory(array(
					'template' => $template,
					'path' => $_REQUEST['category_path']
				));

				if ($res)
				{
					$result = array(
						'result' => true,
						'snippets' => array($template => self::GetSnippets($template))
					);
				}
				else
				{
					$result = array('result' => false);
				}
				break;
			case "snippet_rename_category":
				if (!$USER->CanDoOperation('fileman_view_file_structure'))
					break;
				CUtil::JSPostUnEscape();
				$template = $_REQUEST['site_template'];
				$res = CSnippets::RenameCategory(array(
					'template' => $template,
					'path' => $_REQUEST['category_path'],
					'new_name' => $_REQUEST['category_new_name']
				));

				if ($res)
				{
					$result = array(
						'result' => true,
						'snippets' => array($template => self::GetSnippets($template))
					);
				}
				else
				{
					$result = array('result' => false);
				}
				break;
			// END *** Snippets actions

			// spellcheck
			case "spellcheck_words":
			case "spellcheck_add_word":
				CUtil::JSPostUnEscape();
				$spellChecker = new CSpellchecker(array(
					"lang" => $_REQUEST['lang'],
					"skip_length" => 2,
					"use_pspell" => $_REQUEST['use_pspell'] !== "N",
					"use_custom_spell" => $_REQUEST['use_custom_spell'] !== "N",
					"mode" => PSPELL_FAST
				));

				if ($action == "spellcheck_words")
				{
					$words = (isset($_REQUEST['words']) && is_array($_REQUEST['words'])) ? $_REQUEST['words'] : array();
					$result = array(
						'words' => $spellChecker->checkWords($words)
					);
				}
				else // Add word
				{
					$word = CFileMan::SecurePathVar($_REQUEST['word']);
					$spellChecker->addWord($word);
				}
				break;
			// END *** spellcheck
		}

		self::ShowResponse(intVal($_REQUEST['reqId']), $result);
	}
Beispiel #3
0
    function Request($action)
    {
        global $APPLICATION;
        $sectionId = $_REQUEST['section_id'] == 'none' ? 'none' : intVal($_REQUEST['section_id']);
        CUtil::JSPostUnEscape();
        // Export calendar
        if ($action == 'export') {
            // We don't need to check access  couse we will check security SIGN from the URL
            $bCheck = $_GET['check'] == 'Y';
            $calendarId = $_GET['calendar_id'];
            if ($bCheck) {
                $GLOBALS['APPLICATION']->RestartBuffer();
                if ($this->CheckSign($_GET['sign'], intVal($_GET['user_id']), $calendarId > 0 ? $calendarId : 'superposed_calendars')) {
                    echo 'BEGIN:VCALENDAR';
                }
                die;
            }
            if (!isset($calendarId) || intVal($calendarId) <= 0) {
                $this->ReturnICal_SP(array('userId' => intVal($_GET['user_id']), 'sign' => $_GET['sign']));
            } else {
                $this->ReturnICal(array('calendarId' => intVal($calendarId), 'userId' => intVal($_GET['user_id']), 'sign' => $_GET['sign'], 'ownerType' => $_GET['owner_type'], 'ownerId' => $_GET['owner_id'], 'iblockId' => $_GET['ibl']));
            }
        } else {
            // First of all - CHECK ACCESS
            $this->GetPermissions(array('userId' => $curUserId));
            if (!$this->bAccess) {
                return $APPLICATION->ThrowException(GetMessage("EC_ACCESS_DENIED"));
            }
            $APPLICATION->RestartBuffer();
            if (!check_bitrix_sessid()) {
                echo '<!--BX_EC_DUBLICATE_ACTION_REQUEST' . bitrix_sessid() . '-->';
                return;
            }
            switch ($action) {
                // * * * * * Add and Edit event * * * * *
                case 'add':
                case 'edit':
                    if ($this->bReadOnly) {
                        return $this->ThrowError(GetMessage('EC_ACCESS_DENIED'));
                    }
                    $id = intVal($_POST['id']);
                    // If other calendar was selected for event
                    if ($_POST['b_recreate'] == 'Y' && intVal($_POST['old_calendar'])) {
                        $old_id = $id;
                        $id = 0;
                        $action = 'add';
                    }
                    $from_ts = MakeTimeStamp($_POST['from'], getTSFormat());
                    $to_ts = MakeTimeStamp($_POST['to'], getTSFormat());
                    $arGuests = isset($_POST['guest']) ? $_POST['guest'] : false;
                    $bPeriodic = isset($_POST['per_type']) && $_POST['per_type'] != 'none';
                    if ($bPeriodic) {
                        $per_type = trim($_POST['per_type']);
                        $per_count = intVal($_POST['per_count']);
                        $per_from_ts = MakeTimeStamp($_POST['per_from'], getTSFormat());
                        if ($per_from_ts < $from_ts) {
                            $per_from_ts = mktime(date("H", $from_ts), date("i", $from_ts), date("s", $from_ts), date("m", $per_from_ts), date("d", $per_from_ts), date("Y", $per_from_ts));
                        } else {
                            $per_from_ts = $from_ts;
                        }
                        $per_from = date(getDateFormat(), $per_from_ts);
                        $per_ts = $_POST['per_to'] == 'no_limit' ? 2145938400 : MakeTimeStamp($_POST['per_to'], getTSFormat());
                        $per_to = date(getDateFormat(), $per_ts);
                        $per_week_days = $per_type == 'weekly' ? trim($_POST['per_week_days']) : '';
                        $per_len = intVal($to_ts - $from_ts);
                        $from = $per_from;
                        $to = $per_to;
                        $PROP = array('PERIOD_TYPE' => strtoupper($per_type), 'PERIOD_COUNT' => $per_count, 'EVENT_LENGTH' => $per_len, 'PERIOD_ADDITIONAL' => $per_week_days);
                    } else {
                        $from = date(getDateFormat(), $from_ts);
                        $to = date(getDateFormat(), $to_ts);
                        $PROP = array('PERIOD_TYPE' => 'NONE');
                    }
                    if ($_POST['rem'] == 'Y' && floatval($_POST['rem_count']) > 0 && in_array($_POST['rem_type'], array('min', 'hour', 'day'))) {
                        $arRem = array('count' => floatval($_POST['rem_count']), 'type' => $_POST['rem_type']);
                    } else {
                        $arRem = false;
                    }
                    $PROP['ACCESSIBILITY'] = $_POST['accessibility'] && in_array($_POST['accessibility'], array('quest', 'free', 'absent')) ? $_POST['accessibility'] : 'busy';
                    $PROP['IMPORTANCE'] = $_POST['importance'] && in_array($_POST['importance'], array('high', 'low')) ? $_POST['importance'] : 'normal';
                    $PROP['PRIVATE'] = $_POST['private_event'] == true ? $_POST['private_event'] : false;
                    if (isset($_POST['host']) && intVal($_POST['host']) > 0) {
                        $PROP['PARENT'] = intVal($_POST['host']);
                    }
                    $isMeeting = !!$_POST['is_meeting'];
                    $arParams = array('iblockId' => $this->iblockId, 'ownerType' => $this->ownerType, 'ownerId' => $this->ownerId, 'sectionId' => $sectionId, 'calendarId' => $_POST['calendar'], 'bNew' => $action == 'add', 'id' => $id, 'name' => trim($_POST['name']), 'desc' => trim($_POST['desc']), 'dateFrom' => cutZeroTime($from), 'dateTo' => cutZeroTime($to), 'isMeeting' => $isMeeting, 'prop' => $PROP, 'remind' => $arRem, 'fullUrl' => $this->fullUrl, 'userId' => $this->userId, 'pathToUserCalendar' => $this->pathToUserCalendar, 'pathToGroupCalendar' => $this->pathToGroupCalendar, 'userIblockId' => $this->userIblockId, 'location' => array('old' => trim($_POST['location_old']), 'new' => trim($_POST['location_new']), 'change' => $_POST['location_change'] == 'Y'), 'RMiblockId' => $this->allowResMeeting ? $this->RMiblockId : 0, 'allowResMeeting' => $this->allowResMeeting, 'RMPath' => $this->RMPath, 'VMiblockId' => $this->allowVideoMeeting ? $this->VMiblockId : 0, 'allowVideoMeeting' => $this->allowVideoMeeting, 'VMPath' => $this->VMPath, 'VMPathDetail' => $this->VMPathDetail);
                    if ($isMeeting) {
                        $arParams['guests'] = $arGuests;
                        $arParams['meetingText'] = trim($_POST['meeting_text']);
                        $arParams['setSpecialNotes'] = !!$_POST['setSpecialNotes'];
                        if (isset($_POST['status'])) {
                            $arParams['status'] = $_POST['status'];
                        }
                        $arParams['reinviteParamsList'] = $this->reinviteParamsList;
                    }
                    $eventId = $this->SaveEvent($arParams);
                    // We successfully create new event and have to delete old
                    if (is_int($eventId) && $eventId > 0 && $_POST['b_recreate'] == 'Y' && intVal($_POST['old_calendar'])) {
                        // delete original event
                        $res = CECEvent::Delete(array('id' => $old_id, 'iblockId' => $this->iblockId, 'ownerType' => $this->ownerType, 'ownerId' => $this->ownerId, 'userId' => $this->userId, 'pathToUserCalendar' => $this->pathToUserCalendar, 'pathToGroupCalendar' => $this->pathToGroupCalendar, 'userIblockId' => $this->userIblockId, 'RMiblockId' => $this->allowResMeeting ? $this->RMiblockId : 0, 'allowResMeeting' => $this->allowResMeeting, 'VMiblockId' => $this->allowVideoMeeting ? $this->VMiblockId : 0, 'allowVideoMeeting' => $this->allowVideoMeeting));
                        if ($res !== true) {
                            return $this->ThrowError(strlen($res) > 0 ? $res : GetMessage('EC_EVENT_DEL_ERROR'));
                        }
                    }
                    break;
                    // * * * * * Delete event * * * * *
                // * * * * * Delete event * * * * *
                case 'delete':
                    if ($this->bReadOnly) {
                        return $this->ThrowError(GetMessage('EC_ACCESS_DENIED'));
                    }
                    $res = CECEvent::Delete(array('id' => intVal($_POST['id']), 'iblockId' => $this->iblockId, 'ownerType' => $this->ownerType, 'ownerId' => $this->ownerId, 'userId' => $this->userId, 'pathToUserCalendar' => $this->pathToUserCalendar, 'pathToGroupCalendar' => $this->pathToGroupCalendar, 'userIblockId' => $this->userIblockId, 'RMiblockId' => $this->allowResMeeting ? $this->RMiblockId : 0, 'allowResMeeting' => $this->allowResMeeting, 'VMiblockId' => $this->allowVideoMeeting ? $this->VMiblockId : 0, 'allowVideoMeeting' => $this->allowVideoMeeting));
                    if ($res !== true) {
                        return $this->ThrowError(strlen($res) > 0 ? $res : GetMessage('EC_EVENT_DEL_ERROR'));
                    }
                    ?>
<script>window._bx_result = true;</script><?php 
                    $this->ClearCache($this->cachePath . 'events/' . $this->iblockId . '/');
                    break;
                    // * * * * * Load events for some time limits * * * * *
                // * * * * * Load events for some time limits * * * * *
                case 'load_events':
                    $this->SetLoadLimits(intVal($_POST['month']), intVal($_POST['year']));
                    $cl = $_POST['usecl'] == 'Y' && !isset($_POST['cl']) ? array() : $_POST['cl'];
                    $this->arCalendarIds = $cl;
                    $this->arHiddenCals_ = is_array($_POST['hcl']) ? $_POST['hcl'] : array();
                    $ev = $this->GetEventsEx(array("bJS" => true, 'bCheckSPEvents' => true));
                    if ($this->allowSuperpose && !$this->bListMode) {
                        $this->HandleSuperpose($this->arSPIblIds);
                        $spev = $this->GetSuperposedEvents(array('bJS' => true));
                        if ($spev != '[]') {
                            if ($ev == '[]') {
                                $ev = $spev;
                            } else {
                                $ev = substr($ev, 0, -1) . ',' . substr($spev, 1);
                            }
                        }
                    }
                    ?>
<script>window._bx_ar_events = <?php 
                    echo $ev;
                    ?>
;</script><?php 
                    break;
                    // * * * * * Edit calendar * * * * *
                // * * * * * Edit calendar * * * * *
                case 'calendar_edit':
                    if ($this->bReadOnly) {
                        return $this->ThrowError(GetMessage('EC_ACCESS_DENIED'));
                    }
                    $id = intVal($_POST['id']);
                    $bNew = !isset($id) || $id == 0;
                    $arFields = array('ID' => $id, 'NAME' => trim($_POST['name']), 'DESCRIPTION' => trim($_POST['desc']), 'COLOR' => colorReplace($_POST['color']), 'EXPORT' => isset($_POST['export']) && $_POST['export'] == 'Y', 'EXPORT_SET' => isset($_POST['exp_set']) && in_array($_POST['exp_set'], array('all', '3_9', '6_12')) ? $_POST['exp_set'] : 'all', 'PRIVATE_STATUS' => isset($_POST['private_status']) && in_array($_POST['private_status'], array('private', 'time', 'title')) ? $_POST['private_status'] : 'full');
                    if ($bNew) {
                        $arFields['IS_EXCHANGE'] = $_POST['is_exchange'] == 'Y';
                    }
                    $id = $this->SaveCalendar(array('sectionId' => $sectionId, 'arFields' => $arFields));
                    if (intVal($id) <= 0) {
                        return $this->ThrowError(strlen($res) > 0 ? $res : GetMessage('EC_CALENDAR_SAVE_ERROR'));
                    }
                    $export_link = $arFields['EXPORT'] ? $this->GetExportLink($id, $this->ownerType, $this->ownerId, $this->iblockId) : '';
                    $outlookJs = CECCalendar::GetOutlookLink(array('ID' => $id, 'PREFIX' => $this->GetOwnerName(array('iblockId' => $this->iblockId, 'ownerType' => $this->ownerType, 'ownerId' => $this->ownerId))));
                    if ($this->ownerType == 'USER' && $_POST['is_def_meet_calendar'] == 'Y') {
                        $SET = $this->GetUserSettings();
                        $SET['MeetCalId'] = $id;
                        $this->SetUserSettings($SET);
                    }
                    ?>
<script>window._bx_calendar = {ID: <?php 
                    echo intVal($id);
                    ?>
, EXPORT_LINK: '<?php 
                    echo $export_link;
                    ?>
',  EXPORT: '<?php 
                    echo $arFields['EXPORT'];
                    ?>
',  EXPORT_SET: '<?php 
                    echo $arFields['EXPORT_SET'];
                    ?>
', OUTLOOK_JS: '<?php 
                    echo CUtil::JSEscape($outlookJs);
                    ?>
'};</script><?php 
                    // Clear cache
                    $this->ClearCache($this->cachePath . $this->iblockId . "/calendars/" . ($this->bOwner ? $this->ownerId : 0) . "/");
                    $this->ClearCache($this->cachePath . 'events/' . $this->iblockId . '/');
                    if ($this->ownerType == 'GROUP') {
                        $this->ClearCache($this->cachePath . 'sp_groups/');
                    } elseif ($this->ownerType == 'USER') {
                        $this->ClearCache($this->cachePath . 'sp_user/');
                    } else {
                        $this->ClearCache($this->cachePath . 'sp_common/');
                    }
                    break;
                    // * * * * * Delete calendar * * * * *
                // * * * * * Delete calendar * * * * *
                case 'calendar_delete':
                    if ($this->bReadOnly) {
                        return $this->ThrowError(GetMessage('EC_ACCESS_DENIED'));
                    }
                    $id = intVal($_POST['id']);
                    if (!$this->CheckCalendar(array('calendarId' => $id, 'sectionId' => $sectionId))) {
                        return $this->ThrowError(GetMessage('EC_CALENDAR_DEL_ERROR') . ' ' . GetMessage('EC_CAL_INCORRECT_ERROR'));
                    }
                    $res = $this->DeleteCalendar($id);
                    if ($res !== true) {
                        return $this->ThrowError(strlen($res) > 0 ? $res : GetMessage('EC_CALENDAR_DEL_ERROR'));
                    }
                    // Clear cache
                    $this->ClearCache($this->cachePath . $this->iblockId . "/calendars/" . ($this->bOwner ? $this->ownerId : 0) . "/");
                    if ($this->ownerType == 'GROUP') {
                        $this->ClearCache($this->cachePath . 'sp_groups/');
                    } elseif ($this->ownerType == 'USER') {
                        $this->ClearCache($this->cachePath . 'sp_user/');
                    } else {
                        $this->ClearCache($this->cachePath . 'sp_common/');
                    }
                    ?>
<script>window._bx_result = true;</script><?php 
                    break;
                    // * * * * * Append superposed calendar * * * * *
                // * * * * * Append superposed calendar * * * * *
                case 'spcal_disp_save':
                    $spcl = is_array($_POST['spcl']) ? $_POST['spcl'] : array();
                    if (!$this->SaveDisplayedSPCalendars($spcl)) {
                        return $this->ThrowError('Error! Cant save displayed superposed calendars');
                    }
                    ?>
<script>window._bx_result = true;</script><?php 
                    break;
                    // * * * * * Hide superposed calendar * * * * *
                // * * * * * Hide superposed calendar * * * * *
                case 'spcal_hide':
                    $this->HideSPCalendar(intVal($_POST['id']));
                    ?>
<script>window._bx_result = true;</script><?php 
                    break;
                    // * * * * * Return info about user, and user calendars * * * * *
                // * * * * * Return info about user, and user calendars * * * * *
                case 'spcal_user_cals':
                    $name = trim($_POST['name']);
                    if ($res = $this->HandleSPUserCals($name)) {
                        ?>
<script>window._bx_result = <?php 
                        echo CUtil::PhpToJSObject($res);
                        ?>
;</script><?php 
                    } else {
                        ?>
<script>window._bx_result = [];</script><?php 
                    }
                    break;
                    // * * * * * Return info about user, and user calendars * * * * *
                // * * * * * Return info about user, and user calendars * * * * *
                case 'spcal_del_user':
                    if (!$this->DeleteTrackingUser(intVal($_POST['id']))) {
                        return $this->ThrowError('Error! Cant delete tracking user!');
                    }
                    ?>
<script>window._bx_result = true;</script><?php 
                    break;
                    // * * * * * Delete all tracking users * * * * *
                // * * * * * Delete all tracking users * * * * *
                case 'spcal_del_all_user':
                    $this->DeleteTrackingUser();
                    ?>
<script>window._bx_result = true;</script><?php 
                    break;
                    // * * * * * Add calendar to Superposed * * * * *
                // * * * * * Add calendar to Superposed * * * * *
                case 'add_cal2sp':
                    if (!$this->AddCalendar2SP()) {
                        return $this->ThrowError('Error! Cant add calendar');
                    }
                    $this->ClearCache($this->cachePath . 'sp_handle/' . $this->curUserId % 1000 . "/");
                    ?>
<script>window._bx_result = true;</script><?php 
                    break;
                    // * * * * * Save user settings * * * * *
                // * * * * * Save user settings * * * * *
                case 'set_settings':
                    if (isset($_POST['clear_all']) && $_POST['clear_all'] == true) {
                        // Del user options
                        $res = $this->SetUserSettings(false);
                        ?>
<script>window._bx_result = <?php 
                        echo CUtil::PhpToJSObject($res);
                        ?>
;</script><?php 
                    } else {
                        $Set = array('tab_id' => $_POST['tab_id'], 'cal_sec' => $_POST['cal_sec'], 'sp_cal_sec' => $_POST['sp_cal_sec'], 'planner_scale' => isset($_POST['planner_scale']) ? intVal($_POST['planner_scale']) : false, 'planner_width' => isset($_POST['planner_width']) ? intVal($_POST['planner_width']) : false, 'planner_height' => isset($_POST['planner_height']) ? intVal($_POST['planner_height']) : false);
                        if (isset($_POST['meet_cal_id'])) {
                            $Set['MeetCalId'] = intVal($_POST['meet_cal_id']);
                        }
                        $Set['blink'] = $_POST['blink'] !== 'false';
                        if (isset($_POST['show_ban'])) {
                            $Set['ShowBanner'] = (bool) $_POST['show_ban'];
                        }
                        $this->SetUserSettings($Set);
                    }
                    break;
                    // * * * * * Find guests for event by name * * * * *
                // * * * * * Find guests for event by name * * * * *
                case 'get_guests':
                    if (isset($_POST['from'])) {
                        $from = date(getDateFormat(), MakeTimeStamp($_POST['from'], getTSFormat()));
                        $to = isset($_POST['to']) ? date(getDateFormat(), MakeTimeStamp($_POST['to'], getTSFormat())) : $from;
                    } else {
                        $from = false;
                        $to = false;
                    }
                    $bAddCurUser = false;
                    $res = $this->HandleUserSearch(trim($_POST['name']), $from, $to, false, $_POST['event_id'], $bAddCurUser);
                    ?>
<script>window._bx_result = <?php 
                    echo CUtil::PhpToJSObject($res);
                    ?>
;<?php 
                    if ($bAddCurUser) {
                        ?>
window._bx_add_cur_user = true;<?php 
                    }
                    ?>
</script><?php 
                    break;
                    // * * * * * Confirm user part in event * * * * *
                // * * * * * Confirm user part in event * * * * *
                case 'confirm_event':
                    $this->ClearCache($this->cachePath . 'events/' . $this->iblockId . '/');
                    $this->ConfirmEvent(array('id' => intVal($_POST['id'])));
                    ?>
<script>window._bx_result = true;</script><?php 
                    break;
                    // * * * * * Check users accessibility * * * * *
                // * * * * * Check users accessibility * * * * *
                case 'check_guests':
                    $res = $this->CheckGuestsAccessibility(array('arGuests' => $_POST['guests'], 'from' => $_POST['from'], 'to' => $_POST['to'], 'eventId' => $_POST['event_id']));
                    ?>
<script>window._bx_result = <?php 
                    echo CUtil::PhpToJSObject($res);
                    ?>
;</script><?php 
                    break;
                    // * * * * * Get list of group members * * * * *
                // * * * * * Get list of group members * * * * *
                case 'get_group_members':
                    if ($this->ownerType == 'GROUP') {
                        if (isset($_POST['from'])) {
                            $from = date(getDateFormat(), MakeTimeStamp($_POST['from'], getTSFormat()));
                            $to = isset($_POST['to']) ? date(getDateFormat(), MakeTimeStamp($_POST['to'], getTSFormat())) : $from;
                        } else {
                            $from = false;
                            $to = false;
                        }
                        $bAddCurUser = false;
                        $res = $this->GetGroupMembers(array('groupId' => $this->ownerId, 'from' => $from, 'to' => $to), $bAddCurUser);
                        ?>
<script>window._bx_result = <?php 
                        echo CUtil::PhpToJSObject($res);
                        ?>
;<?php 
                        if ($bAddCurUser) {
                            ?>
window._bx_add_cur_user = true;<?php 
                        }
                        ?>
</script><?php 
                    }
                    break;
                    // * * * * * Get intranet company structure * * * * *
                // * * * * * Get intranet company structure * * * * *
                case 'get_company_structure':
                    CEventCalendar::GetIntranetStructure();
                    break;
                    // * * * * * Get Guests Accessability * * * * *
                // * * * * * Get Guests Accessability * * * * *
                case 'get_guests_accessability':
                    $this->GetGuestsAccessability(array('users' => $_POST['users'], 'from' => date(getDateFormat(), MakeTimeStamp($_POST['from'], getTSFormat())), 'to' => date(getDateFormat(), MakeTimeStamp($_POST['to'], getTSFormat())), 'curEventId' => intVal($_POST['cur_event_id'])));
                    break;
                    // * * * * * Get meeting room accessibility * * * * *
                // * * * * * Get meeting room accessibility * * * * *
                case 'get_mr_accessability':
                    $this->GetMRAccessability(array('id' => intVal($_POST['id']), 'from' => date(getDateFormat(), MakeTimeStamp($_POST['from'], getTSFormat())), 'to' => date(getDateFormat(), MakeTimeStamp($_POST['to'], getTSFormat())), 'curEventId' => intVal($_POST['cur_event_id'])));
                    break;
                    // * * * * * Get meeting room accessibility * * * * *
                // * * * * * Get meeting room accessibility * * * * *
                case 'check_mr_vr_accessability':
                    $check = false;
                    $from = date(getDateFormat(), MakeTimeStamp($_POST['from'], getTSFormat()));
                    $to = date(getDateFormat(), MakeTimeStamp($_POST['to'], getTSFormat()));
                    $loc_old = $_POST['location_old'] ? CEventCalendar::ParseLocation(trim($_POST['location_old'])) : false;
                    $loc_new = CEventCalendar::ParseLocation(trim($_POST['location_new']));
                    $Params = array('dateFrom' => cutZeroTime($from), 'dateTo' => cutZeroTime($to), 'regularity' => isset($_POST['per_type']) && strlen($_POST['per_type']) > 0 ? strtoupper($_POST['per_type']) : 'NONE', 'members' => isset($_POST['guest']) ? $_POST['guest'] : false);
                    $tst = MakeTimeStamp($Params['dateTo']);
                    if (date("H:i", $tst) == '00:00') {
                        $Params['dateTo'] = CIBlockFormatProperties::DateFormat(getDateFormat(true), $tst + (23 * 60 + 59) * 60);
                    }
                    if (intVal($_POST['id']) > 0) {
                        $Params['ID'] = intVal($_POST['id']);
                    }
                    if ($loc_new['mrid'] == $this->VMiblockId) {
                        $Params['allowVideoMeeting'] = $this->allowVideoMeeting;
                        $Params['VMiblockId'] = $this->VMiblockId;
                        $check = CEventCalendar::CheckVR($Params);
                    } else {
                        $Params['allowResMeeting'] = $this->allowResMeeting;
                        $Params['RMiblockId'] = $this->RMiblockId;
                        $Params['mrid'] = $loc_new['mrid'];
                        $Params['mrevid_old'] = $loc_old ? $loc_old['mrevid'] : 0;
                        $check = CEventCalendar::CheckMR($Params);
                    }
                    ?>
<script>window._bx_result = <?php 
                    echo $check === true ? 'true' : '"' . $check . '"';
                    ?>
</script><?php 
                    break;
                case 'connections_edit':
                    if ($this->bReadOnly || $this->ownerType != 'USER') {
                        return $this->ThrowError(GetMessage('EC_ACCESS_DENIED'));
                    }
                    if (CEventCalendar::IsCalDAVEnabled()) {
                        $i = 0;
                        $l = count($_POST['connections']);
                        for ($i = 0; $i < $l; $i++) {
                            $con = $_POST['connections'][$i];
                            if ($con['id'] <= 0) {
                                if ($con['del'] == 'Y') {
                                    continue;
                                }
                                if (!CEventCalendar::CheckCalDavUrl($con['link'], $con['user_name'], $con['pass'])) {
                                    return CEventCalendar::ThrowError(GetMessage("EC_CALDAV_URL_ERROR"));
                                }
                                $id = CDavConnection::Add(array("ENTITY_TYPE" => 'user', "ENTITY_ID" => $this->ownerId, "ACCOUNT_TYPE" => 'caldav', "NAME" => $con['name'], "SERVER" => $con['link'], "SERVER_USERNAME" => $con['user_name'], "SERVER_PASSWORD" => $con['pass']));
                            } elseif ($con['del'] != 'Y') {
                                $arFields = array("NAME" => $con['name'], "SERVER" => $con['link'], "SERVER_USERNAME" => $con['user_name']);
                                // TODO
                                //if (!CEventCalendar::CheckCalDavUrl($con['link'], $con['user_name'], $con['pass']))
                                //	return CEventCalendar::ThrowError(GetMessage("EC_CALDAV_URL_ERROR", Array('#CALDAV_URL#' => $con['link'])));
                                if ($con['pass'] !== 'bxec_not_modify_pass') {
                                    $arFields["SERVER_PASSWORD"] = $con['pass'];
                                }
                                CDavConnection::Update(intVal($con['id']), $arFields);
                            } else {
                                CDavConnection::Delete(intVal($con['id']));
                                $db_res = CUserTypeEntity::GetList(array('ID' => 'ASC'), array("ENTITY_ID" => "IBLOCK_" . $this->iblockId . "_SECTION", "FIELD_NAME" => "UF_BXDAVEX_CDAV_COL"));
                                if ($db_res && ($r = $db_res->GetNext())) {
                                    $arSelectFields = array("IBLOCK_ID", "ID", "IBLOCK_SECTION_ID", "UF_BXDAVEX_CDAV_COL");
                                    $rsData = CIBlockSection::GetList(array('ID' => 'ASC'), array("IBLOCK_ID" => $this->iblockId, "CHECK_PERMISSIONS" => 'N', "UF_BXDAVEX_CDAV_COL" => intVal($con['id']), "CREATED_BY" => $this->ownerId, "SECTION_ID" => $this->GetSectionIDByOwnerId($this->ownerId, 'USER', $this->iblockId)), false, $arSelectFields);
                                    while ($arRes = $rsData->Fetch()) {
                                        if ($con['del_calendars'] == 'Y') {
                                            CIBlockSection::Delete($arRes['ID']);
                                        } else {
                                            $GLOBALS["USER_FIELD_MANAGER"]->Update("IBLOCK_" . $this->iblockId . "_SECTION", $arRes['ID'], array("UF_BXDAVEX_CDAV_COL" => ""));
                                        }
                                    }
                                }
                            }
                        }
                        if ($err = $APPLICATION->GetException()) {
                            CEventCalendar::ThrowError($err->GetString());
                        } else {
                            // Manually synchronize calendars
                            CDavGroupdavClientCalendar::DataSync("user", $this->ownerId);
                            // Clear cache
                            $this->ClearCache($this->cachePath . $this->iblockId . "/calendars/" . ($this->bOwner ? $this->ownerId : 0) . "/");
                            $this->ClearCache($this->cachePath . 'events/' . $this->iblockId . '/');
                            if ($this->ownerType == 'GROUP') {
                                $this->ClearCache($this->cachePath . 'sp_groups/');
                            } elseif ($this->ownerType == 'USER') {
                                $this->ClearCache($this->cachePath . 'sp_user/');
                            } else {
                                $this->ClearCache($this->cachePath . 'sp_common/');
                            }
                        }
                    }
                    break;
                case 'exchange_sync':
                    if ($this->ownerType == 'USER' && CEventCalendar::IsExchangeEnabled()) {
                        $error = "";
                        $res = CDavExchangeCalendar::DoDataSync($this->ownerId, $error);
                        if ($res === true) {
                            ?>
							<script>window._bx_result_sync = true;</script>
						<?php 
                        } elseif ($res === false) {
                            ?>
							<script>window._bx_result_sync = false;</script>
						<?php 
                        } else {
                            CEventCalendar::ThrowError($error);
                        }
                    }
                    break;
            }
            if ($this->ownerType == 'GROUP' && $action != 'load_events' && class_exists('CSocNetGroup')) {
                CSocNetGroup::SetLastActivity($this->ownerId);
            }
        }
        return true;
    }
Beispiel #4
0
 public static function Request($action = '')
 {
     global $APPLICATION;
     if ($_REQUEST['skip_unescape'] !== 'Y') {
         CUtil::JSPostUnEscape();
     }
     // Export calendar
     if ($action == 'export') {
         // We don't need to check access  couse we will check security SIGN from the URL
         $sectId = intVal($_GET['sec_id']);
         if ($_GET['check'] == 'Y') {
             $APPLICATION->RestartBuffer();
             if (CCalendarSect::CheckSign($_GET['sign'], intVal($_GET['user']), $sectId > 0 ? $sectId : 'superposed_calendars')) {
                 echo 'BEGIN:VCALENDAR';
             }
             CMain::FinalActions();
             die;
         }
         if (CCalendarSect::CheckAuthHash() && $sectId > 0) {
             // We don't need any warning in .ics file
             error_reporting(E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR | E_PARSE);
             CCalendarSect::ReturnICal(array('sectId' => $sectId, 'userId' => intVal($_GET['user']), 'sign' => $_GET['sign'], 'type' => $_GET['type'], 'ownerId' => intVal($_GET['owner'])));
         }
     } else {
         // // First of all - CHECK ACCESS
         if (!CCalendarType::CanDo('calendar_type_view', self::$type) || !check_bitrix_sessid()) {
             return $APPLICATION->ThrowException(GetMessage("EC_ACCESS_DENIED"));
         }
         $APPLICATION->ShowAjaxHead();
         $APPLICATION->RestartBuffer();
         $reqId = intVal($_REQUEST['reqId']);
         switch ($action) {
             // * * * * * Add and Edit event * * * * *
             case 'edit_event':
                 if (self::$bReadOnly || !CCalendarType::CanDo('calendar_type_view', self::$type)) {
                     return CCalendar::ThrowError(GetMessage('EC_ACCESS_DENIED'));
                 }
                 $id = intVal($_POST['id']);
                 if (isset($_POST['section'])) {
                     $sectId = intVal($_POST['section']);
                     $_POST['sections'] = array($sectId);
                 } else {
                     $sectId = intVal($_POST['sections'][0]);
                 }
                 if (self::$type != 'user' || self::$ownerId != self::$userId) {
                     if (!$id && !CCalendarSect::CanDo('calendar_add', $sectId, self::$userId)) {
                         return CCalendar::ThrowError(GetMessage('EC_ACCESS_DENIED'));
                     }
                     if ($id && !CCalendarSect::CanDo('calendar_edit', $sectId, self::$userId)) {
                         return CCalendar::ThrowError(GetMessage('EC_ACCESS_DENIED'));
                     }
                 }
                 // Default name for events
                 $_POST['name'] = trim($_POST['name']);
                 if ($_POST['name'] == '') {
                     $_POST['name'] = GetMessage('EC_DEFAULT_EVENT_NAME');
                 }
                 $remind = array();
                 if (isset($_POST['remind']['checked']) && $_POST['remind']['checked'] == 'Y') {
                     $remind[] = array('type' => $_POST['remind']['type'], 'count' => intval($_POST['remind']['count']));
                 }
                 $rrule = isset($_POST['rrule_enabled']) ? $_POST['rrule'] : false;
                 $from_ts = $_POST['from_ts'];
                 $to_ts = $_POST['to_ts'];
                 if (isset($_POST['skip_time']) && $_POST['skip_time'] == 'Y' || $rrule) {
                     $from_ts = self::_fixTimestamp($from_ts);
                     $to_ts = self::_fixTimestamp($to_ts);
                 }
                 $arFields = array("ID" => $id, "DT_FROM_TS" => $from_ts, "DT_TO_TS" => $to_ts, 'NAME' => $_POST['name'], 'DESCRIPTION' => trim($_POST['desc']), 'SECTIONS' => $_POST['sections'], 'COLOR' => $_POST['color'], 'TEXT_COLOR' => $_POST['text_color'], 'ACCESSIBILITY' => $_POST['accessibility'], 'IMPORTANCE' => $_POST['importance'], 'PRIVATE_EVENT' => $_POST['private_event'] == 'Y', 'RRULE' => $rrule, 'LOCATION' => is_array($_POST['location']) ? $_POST['location'] : array(), "REMIND" => $remind, "IS_MEETING" => !!$_POST['is_meeting'], "SKIP_TIME" => isset($_POST['skip_time']) && $_POST['skip_time'] == 'Y');
                 $arAccessCodes = array();
                 if (isset($_POST['EVENT_DESTINATION'])) {
                     foreach ($_POST["EVENT_DESTINATION"] as $v => $k) {
                         if (strlen($v) > 0 && is_array($k) && !empty($k)) {
                             foreach ($k as $vv) {
                                 if (strlen($vv) > 0) {
                                     $arAccessCodes[] = $vv;
                                 }
                             }
                         }
                     }
                     if (!$arFields["ID"]) {
                         $arAccessCodes[] = 'U' . self::$userId;
                     }
                     $arAccessCodes = array_unique($arAccessCodes);
                 }
                 $arFields['IS_MEETING'] = !empty($arAccessCodes) && $arAccessCodes != array('U' . self::$userId);
                 if ($arFields['IS_MEETING']) {
                     $arFields['ATTENDEES_CODES'] = $arAccessCodes;
                     $arFields['ATTENDEES'] = CCalendar::GetDestinationUsers($arAccessCodes);
                     $arFields['MEETING_HOST'] = self::$userId;
                     $arFields['MEETING'] = array('HOST_NAME' => self::GetUserName($arFields['MEETING_HOST']), 'TEXT' => isset($_POST['meeting_text']) ? $_POST['meeting_text'] : '', 'OPEN' => $_POST['open_meeting'] === 'Y', 'NOTIFY' => $_POST['meeting_notify'] === 'Y', 'REINVITE' => $_POST['meeting_reinvite'] === 'Y');
                 }
                 // Userfields for event
                 $arUFFields = array();
                 foreach ($_POST as $field => $value) {
                     if (substr($field, 0, 3) == "UF_") {
                         $arUFFields[$field] = $value;
                     }
                 }
                 $newId = self::SaveEvent(array('arFields' => $arFields, 'UF' => $arUFFields));
                 if ($newId) {
                     $arFilter = array("ID" => $newId);
                     $month = intVal($_REQUEST['month']);
                     $year = intVal($_REQUEST['year']);
                     $arFilter["FROM_LIMIT"] = self::Date(mktime(0, 0, 0, $month - 1, 20, $year), false);
                     $arFilter["TO_LIMIT"] = self::Date(mktime(0, 0, 0, $month + 1, 10, $year), false);
                     $arAttendees = array();
                     // List of attendees for event
                     $arEvents = CCalendarEvent::GetList(array('arFilter' => $arFilter, 'parseRecursion' => true, 'fetchAttendees' => true, 'userId' => self::$userId));
                 }
                 if ($arEvents && $arFields['IS_MEETING']) {
                     $arAttendees = CCalendarEvent::GetLastAttendees();
                 }
                 CCalendar::OutputJSRes($reqId, array('id' => $newId, 'events' => $arEvents, 'attendees' => $arAttendees, 'deletedEventId' => $id && $newId != $id ? $id : 0));
                 break;
             case 'move_event_to_date':
                 if (self::$bReadOnly || !CCalendarType::CanDo('calendar_type_view', self::$type)) {
                     return CCalendar::ThrowError(GetMessage('EC_ACCESS_DENIED'));
                 }
                 $id = intVal($_POST['id']);
                 $sectId = intVal($_POST['section']);
                 if (self::$type != 'user' || self::$ownerId != self::$userId) {
                     if (!$id && !CCalendarSect::CanDo('calendar_add', $sectId, self::$userId)) {
                         return CCalendar::ThrowError(GetMessage('EC_ACCESS_DENIED'));
                     }
                     if ($id && !CCalendarSect::CanDo('calendar_edit', $sectId, self::$userId)) {
                         return CCalendar::ThrowError(GetMessage('EC_ACCESS_DENIED'));
                     }
                 }
                 $from_ts = intVal($_POST['from_ts']);
                 if (isset($_POST['skip_time']) && $_POST['skip_time'] == 'Y') {
                     $from_ts = self::_fixTimestamp($from_ts);
                 }
                 $arFields = array("ID" => $id, "DT_FROM_TS" => $from_ts, "SKIP_TIME" => isset($_POST['skip_time']) && $_POST['skip_time'] == 'Y');
                 if (isset($_POST['to_ts']) && $_POST['to_ts'] > 0) {
                     $arFields["DT_TO_TS"] = intVal($_POST['to_ts'], 10);
                 }
                 //SaveEvent
                 $id = self::SaveEvent(array('arFields' => $arFields));
                 CCalendar::OutputJSRes($reqId, array('id' => $id));
                 break;
                 // * * * * * Delete event * * * * *
             // * * * * * Delete event * * * * *
             case 'delete':
                 if (self::$bReadOnly || !CCalendarType::CanDo('calendar_type_view', self::$type)) {
                     return CCalendar::ThrowError(GetMessage('EC_ACCESS_DENIED'));
                 }
                 $res = self::DeleteEvent(intVal($_POST['id']));
                 if ($res !== true) {
                     return CCalendar::ThrowError(strlen($res) > 0 ? $res : GetMessage('EC_EVENT_DEL_ERROR'));
                 }
                 CCalendar::OutputJSRes($reqId, true);
                 break;
                 // * * * * * Load events for some time limits * * * * *
             // * * * * * Load events for some time limits * * * * *
             case 'load_events':
                 $arSect = array();
                 $arHiddenSect = array();
                 $month = intVal($_REQUEST['month']);
                 $year = intVal($_REQUEST['year']);
                 $fromLimit = self::Date(mktime(0, 0, 0, $month - 1, 20, $year), false);
                 $toLimit = self::Date(mktime(0, 0, 0, $month + 1, 10, $year), false);
                 if ($_REQUEST['cal_dav_data_sync'] == 'Y' && CCalendar::IsCalDAVEnabled()) {
                     CDavGroupdavClientCalendar::DataSync("user", self::$ownerId);
                 }
                 $bGetTask = false;
                 if (is_array($_REQUEST['sa'])) {
                     foreach ($_REQUEST['sa'] as $sectId) {
                         if ($sectId == 'tasks') {
                             $bGetTask = true;
                         } elseif (intval($sectId) > 0) {
                             $arSect[] = intval($sectId);
                         }
                     }
                 }
                 if (is_array($_REQUEST['sh'])) {
                     foreach ($_REQUEST['sh'] as $sectId) {
                         if ($sectId == 'tasks') {
                             $arHiddenSect[] = 'tasks';
                         } elseif (intval($sectId) > 0) {
                             $arHiddenSect[] = intval($sectId);
                         }
                     }
                 }
                 $arAttendees = array();
                 // List of attendees for each event Array([ID] => Array(), ..,);
                 $arEvents = array();
                 if (count($arSect) > 0) {
                     // NOTICE: Attendees for meetings selected inside this method and returns as array by link '$arAttendees'
                     $arEvents = self::GetEventList(array('type' => self::$type, 'section' => $arSect, 'fromLimit' => $fromLimit, 'toLimit' => $toLimit, 'additonalMeetingsId' => is_array($_REQUEST['ameetid']) ? $_REQUEST['ameetid'] : array()), $arAttendees);
                 }
                 //  **** GET TASKS ****
                 $arTaskIds = array();
                 if (self::$bTasks && $bGetTask) {
                     $arTasks = self::GetTaskList(array('fromLimit' => $fromLimit, 'toLimit' => $toLimit), $arTaskIds);
                     if (count($arTasks) > 0) {
                         $arEvents = array_merge($arEvents, $arTasks);
                     }
                 }
                 // Save hidden calendars
                 CCalendarSect::Hidden(self::$userId, $arHiddenSect);
                 CCalendar::OutputJSRes($reqId, array('events' => $arEvents, 'attendees' => $arAttendees));
                 break;
                 // * * * * * Edit calendar * * * * *
             // * * * * * Edit calendar * * * * *
             case 'section_edit':
                 $id = intVal($_POST['id']);
                 $bNew = !isset($id) || $id == 0;
                 if ($bNew) {
                     if (self::$type == 'group') {
                         // It's for groups
                         if (!self::$perm['section_edit']) {
                             return CCalendar::ThrowError('[se01]' . GetMessage('EC_ACCESS_DENIED'));
                         }
                     } else {
                         if (self::$type == 'user') {
                             if (!self::IsPersonal()) {
                                 // If it's not owner of the group.
                                 return CCalendar::ThrowError('[se02]' . GetMessage('EC_ACCESS_DENIED'));
                             }
                         } else {
                             if (!CCalendarType::CanDo('calendar_type_edit_section')) {
                                 return CCalendar::ThrowError('[se03]' . GetMessage('EC_ACCESS_DENIED'));
                             }
                         }
                     }
                 } elseif (!self::IsPersonal() && !$bNew && !CCalendarSect::CanDo('calendar_edit_section', $id, self::$userId)) {
                     return CCalendar::ThrowError(GetMessage('[se02]EC_ACCESS_DENIED'));
                 }
                 $arFields = array('CAL_TYPE' => self::$type, 'ID' => $id, 'NAME' => trim($_POST['name']), 'DESCRIPTION' => trim($_POST['desc']), 'COLOR' => $_POST['color'], 'TEXT_COLOR' => $_POST['text_color'], 'OWNER_ID' => self::$bOwner ? self::GetOwnerId() : '', 'EXPORT' => array('ALLOW' => isset($_POST['export']) && $_POST['export'] == 'Y', 'SET' => $_POST['exp_set']), 'ACCESS' => is_array($_POST['access']) ? $_POST['access'] : array());
                 if ($bNew) {
                     $arFields['IS_EXCHANGE'] = $_POST['is_exchange'] == 'Y';
                 }
                 $id = intVal(self::SaveSection(array('arFields' => $arFields)));
                 if ($id > 0) {
                     CCalendarSect::SetClearOperationCache(true);
                     $oSect = CCalendarSect::GetById($id, true, true);
                     if (!$oSect) {
                         return CCalendar::ThrowError(GetMessage('EC_CALENDAR_SAVE_ERROR'));
                     }
                     if (self::$type == 'user' && isset($_POST['is_def_meet_calendar']) && $_POST['is_def_meet_calendar'] == 'Y') {
                         $set = CCalendar::GetUserSettings(self::$ownerId);
                         $set['meetSection'] = $id;
                         CCalendar::SetUserSettings($set, self::$ownerId);
                     }
                     CCalendar::OutputJSRes($reqId, array('calendar' => $oSect, 'accessNames' => CCalendar::GetAccessNames()));
                 }
                 if ($id <= 0) {
                     return CCalendar::ThrowError(GetMessage('EC_CALENDAR_SAVE_ERROR'));
                 }
                 break;
                 // * * * * * Delete calendar * * * * *
             // * * * * * Delete calendar * * * * *
             case 'section_delete':
                 $sectId = intVal($_REQUEST['id']);
                 if (!self::IsPersonal() && !CCalendarSect::CanDo('calendar_edit_section', $sectId, self::$userId)) {
                     return CCalendar::ThrowError(GetMessage('EC_ACCESS_DENIED'));
                 }
                 $res = self::DeleteSection($sectId);
                 // if ($res !== true)
                 // return CCalendar::ThrowError(strlen($res) > 0 ? $res : GetMessage('EC_CALENDAR_DEL_ERROR'));
                 CCalendar::OutputJSRes($reqId, array('result' => true));
                 break;
                 // * * * * * Save superposed sections * * * * *
             // * * * * * Save superposed sections * * * * *
             case 'set_superposed':
                 $trackedUser = intVal($_REQUEST['trackedUser']);
                 if ($trackedUser > 0) {
                     $arUserIds = self::TrackingUsers(self::$userId);
                     if (!in_array($trackedUser, $arUserIds)) {
                         $arUserIds[] = $trackedUser;
                         self::TrackingUsers(self::$userId, $arUserIds);
                     }
                 }
                 if (CCalendar::SetDisplayedSuperposed(self::$userId, $_REQUEST['sect'])) {
                     CCalendar::OutputJSRes($reqId, array('result' => true));
                 } else {
                     CCalendar::ThrowError('Error! Cant save displayed superposed calendars');
                 }
                 break;
                 // * * * * * Fetch all available sections for superposing * * * * *
             // * * * * * Fetch all available sections for superposing * * * * *
             case 'get_superposed':
                 CCalendar::OutputJSRes($reqId, array('sections' => CCalendar::GetSuperposed()));
                 break;
                 // * * * * * Return info about user, and user calendars * * * * *
             // * * * * * Return info about user, and user calendars * * * * *
             case 'spcal_user_cals':
                 CCalendar::OutputJSRes($reqId, array('sections' => CCalendar::GetSuperposedForUsers($_REQUEST['users'])));
                 break;
                 // * * * * * Delete tracking user * * * * *
             // * * * * * Delete tracking user * * * * *
             case 'spcal_del_user':
                 CCalendar::OutputJSRes($reqId, array('result' => CCalendar::DeleteTrackingUser(intVal($_REQUEST['userId']))));
                 break;
                 // * * * * * Save user settings * * * * *
             // * * * * * Save user settings * * * * *
             case 'save_settings':
                 if (isset($_POST['clear_all']) && $_POST['clear_all'] == true) {
                     // Clear personal settings
                     CCalendar::SetUserSettings(false);
                 } else {
                     // Personal
                     CCalendar::SetUserSettings($_REQUEST['user_settings']);
                     // Save access for type
                     if (CCalendarType::CanDo('calendar_type_access', self::$type)) {
                         // General
                         $_REQUEST['settings']['week_holidays'] = implode('|', $_REQUEST['settings']['week_holidays']);
                         CCalendar::SetSettings($_REQUEST['settings']);
                         CCalendarType::Edit(array('arFields' => array('XML_ID' => self::$type, 'ACCESS' => $_REQUEST['type_access'])));
                     }
                 }
                 CCalendar::OutputJSRes($reqId, array('result' => true));
                 break;
                 // * * * * * Confirm user part in event * * * * *
             // * * * * * Confirm user part in event * * * * *
             case 'set_meeting_status':
                 CCalendarEvent::SetMeetingStatus(self::$userId, intVal($_REQUEST['event_id']), in_array($_REQUEST['status'], array('Q', 'Y', 'N')) ? $_REQUEST['status'] : 'Q', $_REQUEST['status_comment']);
                 CCalendar::OutputJSRes($reqId, true);
                 break;
             case 'set_meeting_params':
                 CCalendarEvent::SetMeetingParams(self::$userId, intVal($_REQUEST['event_id']), array('ACCESSIBILITY' => $_REQUEST['accessibility'], 'REMIND' => $_REQUEST['remind']));
                 CCalendar::OutputJSRes($reqId, true);
                 break;
                 // * * * * * Check users accessibility * * * * *
             // * * * * * Check users accessibility * * * * *
             case 'check_guests':
                 CCalendar::OutputJSRes($reqId, array('data' => CCalendar::CheckUsersAccessibility(array('users' => $_REQUEST['attendees'], 'from' => self::Date($_POST['from']), 'to' => self::Date($_POST['to']), 'eventId' => intVal($_POST['event_id'])))));
                 break;
                 // * * * * * Get list of group members * * * * *
             // * * * * * Get list of group members * * * * *
             case 'get_group_members':
                 if (self::$type == 'group') {
                     CCalendar::OutputJSRes($reqId, array('users' => self::GetGroupMembers(self::$ownerId)));
                 }
                 break;
                 // * * * * * Get Guests Accessibility * * * * *
             // * * * * * Get Guests Accessibility * * * * *
             case 'get_accessibility':
                 $res = CCalendar::GetAccessibilityForUsers(array('users' => $_POST['users'], 'from' => self::Date(self::Timestamp($_POST['from'])), 'to' => self::Date(self::Timestamp($_POST['to'])), 'curEventId' => intVal($_POST['cur_event_id']), 'getFromHR' => true));
                 CCalendar::OutputJSRes($reqId, array('data' => $res));
                 break;
                 // * * * * * Get meeting room accessibility * * * * *
             // * * * * * Get meeting room accessibility * * * * *
             case 'get_mr_accessibility':
                 $res = CCalendar::GetAccessibilityForMeetingRoom(array('id' => intVal($_POST['id']), 'from' => self::Date(self::Timestamp($_POST['from'])), 'to' => self::Date(self::Timestamp($_POST['to'])), 'curEventId' => intVal($_POST['cur_event_id'])));
                 CCalendar::OutputJSRes($reqId, array('data' => $res));
                 break;
                 // * * * * * Get meeting room accessibility * * * * *
             // * * * * * Get meeting room accessibility * * * * *
             case 'check_meeting_room':
                 $check = false;
                 if (self::$allowReserveMeeting || self::$allowVideoMeeting) {
                     $from = self::Date($_POST['from']);
                     $to = self::Date($_POST['to']);
                     $loc_old = $_POST['location_old'] ? CCalendar::ParseLocation(trim($_POST['location_old'])) : false;
                     $loc_new = CCalendar::ParseLocation(trim($_POST['location_new']));
                     $Params = array('dateFrom' => self::CutZeroTime($from), 'dateTo' => self::CutZeroTime($to), 'regularity' => 'NONE', 'members' => isset($_POST['guest']) ? $_POST['guest'] : false);
                     $tst = MakeTimeStamp($Params['dateTo']);
                     if (date("H:i", $tst) == '00:00') {
                         $Params['dateTo'] = CIBlockFormatProperties::DateFormat(self::DFormat(true), $tst + (23 * 60 + 59) * 60);
                     }
                     if (intVal($_POST['id']) > 0) {
                         $Params['ID'] = intVal($_POST['id']);
                     }
                     if (self::$allowVideoMeeting && $loc_new['mrid'] == self::$settings['vr_iblock_id']) {
                         $Params['VMiblockId'] = self::$settings['vr_iblock_id'];
                         if ($loc_old['mrevid'] > 0) {
                             $Params['ID'] = $loc_old['mrevid'];
                         }
                         $check = CCalendar::CheckVideoRoom($Params);
                     } elseif (self::$allowReserveMeeting) {
                         $Params['RMiblockId'] = self::$settings['rm_iblock_id'];
                         $Params['mrid'] = $loc_new['mrid'];
                         $Params['mrevid_old'] = $loc_old ? $loc_old['mrevid'] : 0;
                         $check = CCalendar::CheckMeetingRoom($Params);
                     }
                 }
                 CCalendar::OutputJSRes($reqId, array('check' => $check));
                 break;
             case 'connections_edit':
                 if (self::$type == 'user' && CCalendar::IsCalDAVEnabled()) {
                     $res = CCalendar::ManageConnections($_POST['connections']);
                     if ($res !== true) {
                         CCalendar::ThrowError($res == '' ? 'Edit connections error' : $res);
                     } else {
                         CCalendar::OutputJSRes($reqId, array('result' => true));
                     }
                 }
                 break;
             case 'exchange_sync':
                 if (self::$type == 'user' && CCalendar::IsExchangeEnabled(self::$ownerId)) {
                     $error = "";
                     $res = CDavExchangeCalendar::DoDataSync(self::$ownerId, $error);
                     if ($res === true || $res === false) {
                         CCalendar::OutputJSRes($reqId, array('result' => true));
                     } else {
                         CCalendar::ThrowError($error);
                     }
                 }
                 break;
                 //				case 'userfield_view':
                 //					CCalendarSceleton::GetUserfieldsViewHtml(intVal($_REQUEST['event_id']));
                 //					CCalendar::OutputJSRes($reqId, array('result' => true));
                 //					break;
                 //				case 'userfield_edit':
                 //					CCalendarSceleton::GetUserfieldsEditHtml(intVal($_REQUEST['event_id']), self::$actionUrl);
                 //					CCalendar::OutputJSRes($reqId, array('result' => true));
                 //					break;
                 //				case 'userfield_save':
                 //					$arFields = array();
                 //					$bRefresh = false;
                 //					foreach ($_POST as $field => $value)
                 //						if (substr($field, 0, 3) == "UF_")
                 //						{
                 //							$arFields[$field] = $value;
                 //							if ($field == 'UF_CRM_CAL_EVENT')
                 //								$bRefresh = true;
                 //						}
                 //					if (count($arFields) > 0)
                 //						CCalendarEvent::UpdateUserFields($_REQUEST['event_id'], $arFields);
                 //
                 //					CCalendar::OutputJSRes($reqId, array('result' => true, 'refresh' => $bRefresh));
                 //					break;
             //				case 'userfield_view':
             //					CCalendarSceleton::GetUserfieldsViewHtml(intVal($_REQUEST['event_id']));
             //					CCalendar::OutputJSRes($reqId, array('result' => true));
             //					break;
             //				case 'userfield_edit':
             //					CCalendarSceleton::GetUserfieldsEditHtml(intVal($_REQUEST['event_id']), self::$actionUrl);
             //					CCalendar::OutputJSRes($reqId, array('result' => true));
             //					break;
             //				case 'userfield_save':
             //					$arFields = array();
             //					$bRefresh = false;
             //					foreach ($_POST as $field => $value)
             //						if (substr($field, 0, 3) == "UF_")
             //						{
             //							$arFields[$field] = $value;
             //							if ($field == 'UF_CRM_CAL_EVENT')
             //								$bRefresh = true;
             //						}
             //					if (count($arFields) > 0)
             //						CCalendarEvent::UpdateUserFields($_REQUEST['event_id'], $arFields);
             //
             //					CCalendar::OutputJSRes($reqId, array('result' => true, 'refresh' => $bRefresh));
             //					break;
             case 'get_view_event_dialog':
                 $APPLICATION->ShowAjaxHead();
                 $jsId = $color = preg_replace('/[^\\d|\\w]/', '', $_REQUEST['js_id']);
                 $event_id = intval($_REQUEST['event_id']);
                 $Event = CCalendarEvent::GetList(array('arFilter' => array("ID" => $event_id), 'parseRecursion' => false, 'fetchAttendees' => true, 'checkPermissions' => true, 'setDefaultLimit' => false));
                 if ($Event && is_array($Event[0])) {
                     CCalendarSceleton::DialogViewEvent(array('id' => $jsId, 'event' => $Event[0], 'sectionName' => $_REQUEST['section_name'], 'fromTs' => self::_fixTimestamp($_REQUEST['from_ts']), 'bIntranet' => self::IsIntranetEnabled(), 'bSocNet' => self::IsSocNet(), 'AVATAR_SIZE' => 21));
                 }
                 require $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/epilog_after.php";
                 break;
             case 'get_edit_event_dialog':
                 $APPLICATION->ShowAjaxHead();
                 $jsId = $color = preg_replace('/[^\\d|\\w]/', '', $_REQUEST['js_id']);
                 $event_id = intval($_REQUEST['event_id']);
                 if ($event_id > 0) {
                     $Event = CCalendarEvent::GetList(array('arFilter' => array("ID" => $event_id), 'parseRecursion' => false, 'fetchAttendees' => true, 'checkPermissions' => true, 'setDefaultLimit' => false));
                     $Event = $Event && is_array($Event[0]) ? $Event[0] : false;
                 } else {
                     $Event = array();
                 }
                 CCalendarSceleton::DialogEditEvent(array('id' => $jsId, 'event' => $Event, 'type' => self::$type, 'bIntranet' => self::IsIntranetEnabled(), 'bSocNet' => self::IsSocNet(), 'AVATAR_SIZE' => 21));
                 require $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/epilog_after.php";
                 break;
             case 'get_attendees_by_codes_planner':
             case 'get_attendees_by_codes':
                 $bPlanner = $action == 'get_attendees_by_codes_planner';
                 $users = CCalendar::GetDestinationUsers($_REQUEST['codes'], true);
                 $userIds = array();
                 $result = array();
                 foreach ($users as $user) {
                     $userIds[] = $user['USER_ID'];
                     $result[] = array('USER_ID' => $user['USER_ID'], 'DISPLAY_NAME' => CCalendar::GetUserName($user), 'AVATAR' => CCalendar::GetUserAvatarSrc($user), 'ACC' => '', 'URL' => CCalendar::GetUserUrl($user['USER_ID'], self::$pathToUser));
                 }
                 if ($_REQUEST['event_from_ts'] && $_REQUEST['event_to_ts']) {
                     $acc = CCalendar::CheckUsersAccessibility(array('users' => $userIds, 'from' => self::Date(self::_fixTimestamp($_REQUEST['event_from_ts'])), 'to' => self::Date(self::_fixTimestamp($_REQUEST['event_to_ts'])), 'eventId' => intVal($_REQUEST['cur_event_id'])));
                     foreach ($result as $i => $user) {
                         $result[$i]['ACC'] = $acc[$user['USER_ID']];
                     }
                 }
                 if ($bPlanner) {
                     $accessibility = CCalendar::GetAccessibilityForUsers(array('users' => $userIds, 'from' => self::Date($_REQUEST['from_ts']), 'to' => self::Date($_REQUEST['to_ts']), 'curEventId' => intVal($_REQUEST['cur_event_id']), 'getFromHR' => true));
                 } else {
                     $accessibility = array();
                 }
                 CCalendar::OutputJSRes($reqId, array('users' => $result, 'accessibility' => $accessibility));
                 break;
         }
     }
     if ($ex = $APPLICATION->GetException()) {
         ShowError($ex->GetString());
     }
     CMain::FinalActions();
     die;
 }
Beispiel #5
0
 public static function RequestAction($action = '')
 {
     global $USER, $APPLICATION;
     $result = array();
     switch ($action) {
         case "load_site_template":
             if (!$USER->CanDoOperation('fileman_view_file_structure')) {
                 break;
             }
             $siteTemplate = $_REQUEST['site_template'];
             $siteId = isset($_REQUEST['site_id']) ? $_REQUEST['site_id'] : SITE_ID;
             $result = self::GetSiteTemplateParams($siteTemplate, $siteId);
             break;
         case "load_components_list":
             if (!$USER->CanDoOperation('fileman_view_file_structure')) {
                 break;
             }
             $siteTemplate = $_REQUEST['site_template'];
             $componentFilter = isset($_REQUEST['componentFilter']) ? $_REQUEST['componentFilter'] : false;
             $result = self::GetComponents($siteTemplate, true, $componentFilter);
             break;
         case "video_oembed":
             $result = self::GetVideoOembed($_REQUEST['video_source']);
             break;
             // Snippets actions
         // Snippets actions
         case "load_snippets_list":
             if (!$USER->CanDoOperation('fileman_view_file_structure')) {
                 break;
             }
             $template = $_REQUEST['site_template'];
             $result = array('result' => true, 'snippets' => array($template => self::GetSnippets($template, $_REQUEST['clear_cache'] == 'Y')));
             break;
         case "edit_snippet":
             if (!$USER->CanDoOperation('fileman_view_file_structure')) {
                 break;
             }
             CUtil::JSPostUnEscape();
             $template = $_REQUEST['site_template'];
             // Update
             if ($_REQUEST['current_path']) {
                 $result = CSnippets::Update(array('template' => $template, 'path' => $_REQUEST['path'], 'code' => $_REQUEST['code'], 'title' => $_REQUEST['name'], 'current_path' => $_REQUEST['current_path'], 'description' => $_REQUEST['description']));
             } else {
                 $result = CSnippets::Add(array('template' => $template, 'path' => $_REQUEST['path'], 'code' => $_REQUEST['code'], 'title' => $_REQUEST['name'], 'description' => $_REQUEST['description']));
             }
             if ($result && $result['result']) {
                 $result['snippets'] = array($template => self::GetSnippets($template));
             }
             break;
         case "remove_snippet":
             if (!$USER->CanDoOperation('fileman_view_file_structure')) {
                 break;
             }
             CUtil::JSPostUnEscape();
             $template = $_REQUEST['site_template'];
             $res = CSnippets::Remove(array('template' => $template, 'path' => $_REQUEST['path']));
             if ($res) {
                 $result = array('result' => true, 'snippets' => array($template => self::GetSnippets($template)));
             } else {
                 $result = array('result' => false);
             }
             break;
         case "snippet_add_category":
             if (!$USER->CanDoOperation('fileman_view_file_structure')) {
                 break;
             }
             CUtil::JSPostUnEscape();
             $template = $_REQUEST['site_template'];
             $res = CSnippets::CreateCategory(array('template' => $template, 'name' => $_REQUEST['category_name'], 'parent' => $_REQUEST['category_parent']));
             if ($res) {
                 $result = array('result' => true, 'snippets' => array($template => self::GetSnippets($template)));
             } else {
                 $result = array('result' => false);
             }
             break;
         case "snippet_remove_category":
             if (!$USER->CanDoOperation('fileman_view_file_structure')) {
                 break;
             }
             CUtil::JSPostUnEscape();
             $template = $_REQUEST['site_template'];
             $res = CSnippets::RemoveCategory(array('template' => $template, 'path' => $_REQUEST['category_path']));
             if ($res) {
                 $result = array('result' => true, 'snippets' => array($template => self::GetSnippets($template)));
             } else {
                 $result = array('result' => false);
             }
             break;
         case "snippet_rename_category":
             if (!$USER->CanDoOperation('fileman_view_file_structure')) {
                 break;
             }
             CUtil::JSPostUnEscape();
             $template = $_REQUEST['site_template'];
             $res = CSnippets::RenameCategory(array('template' => $template, 'path' => $_REQUEST['category_path'], 'new_name' => $_REQUEST['category_new_name']));
             if ($res) {
                 $result = array('result' => true, 'snippets' => array($template => self::GetSnippets($template)));
             } else {
                 $result = array('result' => false);
             }
             break;
             // END *** Snippets actions
             // spellcheck
         // END *** Snippets actions
         // spellcheck
         case "spellcheck_words":
         case "spellcheck_add_word":
             CUtil::JSPostUnEscape();
             $spellChecker = new CSpellchecker(array("lang" => $_REQUEST['lang'], "skip_length" => 2, "use_pspell" => $_REQUEST['use_pspell'] !== "N", "use_custom_spell" => $_REQUEST['use_custom_spell'] !== "N", "mode" => PSPELL_FAST));
             if ($action == "spellcheck_words") {
                 $words = isset($_REQUEST['words']) && is_array($_REQUEST['words']) ? $_REQUEST['words'] : array();
                 $result = array('words' => $spellChecker->checkWords($words));
             } else {
                 $word = CFileMan::SecurePathVar($_REQUEST['word']);
                 $spellChecker->addWord($word);
             }
             break;
             // END *** spellcheck
         // END *** spellcheck
         case "load_file_dialogs":
             $editorId = $_REQUEST['editor_id'];
             $editorId = preg_replace("/[^a-zA-Z0-9_-]/is", "_", $editorId);
             CAdminFileDialog::ShowScript(array("event" => "BxOpenFileBrowserWindFile" . $editorId, "arResultDest" => array("FUNCTION_NAME" => "OnFileDialogSelect" . $editorId), "arPath" => array("SITE" => SITE_ID), "select" => 'F', "operation" => 'O', "showUploadTab" => true, "showAddToMenuTab" => false, "fileFilter" => 'image', "allowAllFiles" => true, "SaveConfig" => true));
             CMedialib::ShowBrowseButton(array('value' => '...', 'event' => "BxOpenFileBrowserWindFile" . $editorId, 'button_id' => "bx-open-file-link-medialib-but-" . $editorId, 'id' => "bx_open_file_link_medialib_button_" . $editorId, 'MedialibConfig' => array("event" => "BxOpenFileBrowserFileMl" . $editorId, "arResultDest" => array("FUNCTION_NAME" => "OnFileDialogSelect" . $editorId)), 'useMLDefault' => false));
             CMedialib::ShowBrowseButton(array('value' => '...', 'event' => "BxOpenFileBrowserWindFile" . $editorId, 'button_id' => "bx-open-file-medialib-but-" . $editorId, 'id' => "bx_open_file_medialib_button_" . $editorId, 'MedialibConfig' => array("event" => "BxOpenFileBrowserImgFileMl" . $editorId, "arResultDest" => array("FUNCTION_NAME" => "OnFileDialogImgSelect" . $editorId), "types" => array('image'))));
             $result = array('result' => true);
             break;
     }
     self::ShowResponse(intVal($_REQUEST['reqId']), $result);
 }