• Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/controller/calendarajax.php
  • Класс: BitrixCalendarControllerCalendarAjax
  • Вызов: CalendarAjax::getEditEventSliderAction
public function getEditEventSliderAction()
{
	$request = $this->getRequest();
	$responseParams = [];
	$uniqueId = 'calendar_edit_slider_' . mt_rand();
	$formType = preg_replace('/W/', '', $request->get('form_type'));
	$entryId = (int)$request->get('event_id');
	$userCodes = $request->get('userCodes');
	$userId = CCalendar::GetCurUserId();
	$ownerId = (int)$request->get('ownerId');
	$type = $request->get('type');
	$sections = [];

	if ($entryId > 0)
	{
		$fromTs = !empty($_REQUEST['date_from_offset']) ? CCalendar::Timestamp($_REQUEST['date_from'])
			- $_REQUEST['date_from_offset'] : CCalendar::Timestamp($_REQUEST['date_from']);
		$entry = CCalendarEvent::getEventForEditInterface($entryId, ['eventDate' => CCalendar::Date($fromTs)]);
		$entryId = is_array($entry) && isset($entry['ID']) ? (int)$entry['ID'] : $entryId;
	}
	else
	{
		$entry = [];
	}

	if (!$entryId || (!empty($entry) && CCalendarSceleton::CheckBitrix24Limits(['id' => $uniqueId])))
	{
		$responseParams['uniqueId'] = $uniqueId;
		$responseParams['userId'] = $userId;
		$responseParams['editorId'] = $uniqueId . '_entry_slider_editor';
		$responseParams['entry'] = $entry;
		$responseParams['timezoneList'] = CCalendar::GetTimezoneList();
		$responseParams['formSettings'] = UserSettings::getFormSettings($formType);

		if ($type)
		{
			if (($type === 'user' && $ownerId !== $userId) || $type !== 'user')
			{
				$sectionList = CCalendar::getSectionList([
					'CAL_TYPE' => $type,
					'OWNER_ID' => $ownerId,
					'ACTIVE' => 'Y',
					'checkPermissions' => true,
					'getPermissions' => true
				]);

				foreach ($sectionList as $section)
				{
					if ($section['PERM']['edit'] || $section['PERM']['add'])
					{
						$sections[] = $section;
					}
				}
			}

			if (empty($sections) && $type === 'group')
			{
				$sections[] = CCalendarSect::createDefault([
					'type' => $type,
					'ownerId' => $ownerId
				]);

				CCalendarSect::setClearOperationCache();
			}
		}
		$sections = array_merge(
			$sections,
			CCalendar::getSectionListAvailableForUser($userId, (array)($entry['SECTION_ID'] ?? null))
		);

		$responseParams['sections'] = [];
		foreach ($sections as $section)
		{
			if (
				($section['PERM']['edit'] ?? false)
				&& !CCalendarSect::CheckGoogleVirtualSection(
					$section['GAPI_CALENDAR_ID'] ?? null,
					$section['EXTERNAL_TYPE'] ?? null,
				)
			)
			{
				$responseParams['sections'][] = $section;
			}
		}

		$responseParams['dayOfWeekMonthFormat'] = stripslashes(
			BitrixMainContext::getCurrent()
				->getCulture()
				->getDayOfWeekMonthFormat()
		);
		$responseParams['trackingUsersList'] = UserSettings::getTrackingUsers($userId);
		$responseParams['userSettings'] = UserSettings::get($userId);
		$responseParams['eventWithEmailGuestLimit'] = Bitrix24Manager::getEventWithEmailGuestLimit();
		$responseParams['countEventWithEmailGuestAmount'] = Bitrix24Manager::getCountEventWithEmailGuestAmount();
		$responseParams['iblockMeetingRoomList'] = RoomsIBlockMeetingRoom::getMeetingRoomList();
		$responseParams['userIndex'] = CCalendarEvent::getUserIndex();
		$responseParams['locationFeatureEnabled'] = Bitrix24Manager::isFeatureEnabled("calendar_location");
		if ($responseParams['locationFeatureEnabled'])
		{
			$responseParams['locationList'] = RoomsManager::getRoomsList();
			$responseParams['locationAccess'] = RoomsUtil::getLocationAccess($userId);
		}
		$responseParams['plannerFeatureEnabled'] = Bitrix24Manager::isPlannerFeatureEnabled();
		$responseParams['attendeesEntityList'] = ($entryId > 0 && !empty($entry['attendeesEntityList']))
			? $entry['attendeesEntityList']
			: Util::getDefaultEntityList($userId, $type, $ownerId);
		$responseParams['meetSection'] = null;
		if ($type === Dictionary::EVENT_TYPE['user'])
		{
			$responseParams['meetSection'] = UserSettings::get($ownerId)['meetSection'] ?? null;
		}

		return new BitrixMainEngineResponseComponent(
			'bitrix:calendar.edit.slider',
			'',
			[
				'id' => $uniqueId,
				'event' => $entry,
				'formType' => $formType,
				'type' => CCalendar::GetType(),
				'bIntranet' => CCalendar::IsIntranetEnabled(),
				'bSocNet' => CCalendar::IsSocNet(),
				'AVATAR_SIZE' => 21,
				'ATTENDEES_CODES' => $userCodes,
				'hiddenFields' => $this->getEventEditFormHiddenFields($entry),
			],
			$responseParams
		);
	}

	$this->addError(new Error('[se05] No entry found'));

	return [];
}