Calendar::getAccessibility

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. Calendar
  4. getAccessibility
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/controller/activity/settings/calendar.php
  • Класс: Bitrix\Crm\Controller\Activity\Settings\Calendar
  • Вызов: Calendar::getAccessibility
private function getAccessibility(int $from, int $to, int $currentEventId): array
{
	$result = [];

	$fromDate = DateTime::createFromTimestamp($from)->toUserTime();
	$toDate = DateTime::createFromTimestamp($to)->toUserTime();

	$accessibility = CCalendar::GetAccessibilityForUsers([
		'users' => [$this->getCurrentUser()->getId()],
		'from' => $fromDate,
		'to' => $toDate,
		'curEventId' => $currentEventId,
		'getFromHR' => true,
	]);

	foreach ($accessibility as $userId => $entries)
	{
		foreach ($entries as $entry)
		{
			if (isset($entry['DT_FROM']) && !isset($entry['DATE_FROM']))
			{
				$result[$userId][] = [
					'id' => $entry['ID'],
					'dateFrom' => $entry['DT_FROM'],
					'dateTo' => $entry['DT_TO'],
					'type' => $entry['FROM_HR'] ? 'hr' : 'event',
					'title' => $entry['NAME'],
				];
				continue;
			}

			$fromTs = CCalendar::Timestamp($entry['DATE_FROM']);
			$toTs = CCalendar::Timestamp($entry['DATE_TO']);
			if ($entry['DT_SKIP_TIME'] !== 'Y')
			{
				$fromTs -= $entry['~USER_OFFSET_FROM'];
				$toTs -= $entry['~USER_OFFSET_TO'];
			}

			$result[$userId][] = [
				'id' => $entry['ID'],
				'dateFrom' => CCalendar::Date($fromTs, $entry['DT_SKIP_TIME'] !== 'Y'),
				'dateTo' => CCalendar::Date($toTs, $entry['DT_SKIP_TIME'] !== 'Y'),
				'type' => isset($entry['FROM_HR']) ? 'hr' : 'event',
				'title' => $entry['NAME'] ?? '',
			];
		}
	}

	return $result;
}

Добавить комментарий