Util::getPathToCalendar

  1. Bitrix24 API (v. 23.675.0)
  2. calendar
  3. Util
  4. getPathToCalendar
  • Модуль: calendar
  • Путь к файлу: ~/bitrix/modules/calendar/lib/util.php
  • Класс: BitrixCalendarUtil
  • Вызов: Util::getPathToCalendar
static function getPathToCalendar(?int $ownerId, ?string $type): string
{
	$key = $type . $ownerId;
	if (!isset(self::$pathCache[$key]) || !is_string(self::$pathCache[$key]))
	{
		if ($type === 'user')
		{
			$path = COption::GetOptionString(
				'calendar',
				'path_to_user_calendar',
				COption::getOptionString('socialnetwork', 'user_page', "/company/personal/")
				. "user/#user_id#/calendar/"
			);
		}
		elseif ($type === 'group')
		{
			$path = COption::GetOptionString(
				'calendar',
				'path_to_group_calendar',
				COption::getOptionString('socialnetwork', 'workgroups_page', "/workgroups/")
				. "group/#group_id#/calendar/"
			);
		}
		else
		{
			$settings = CCalendar::GetSettings();
			$path = $settings['path_to_type_' . $type] ?? null;
		}

		if (!COption::GetOptionString('calendar', 'pathes_for_sites', true))
		{
			$siteId = CCalendar::GetSiteId();
			$pathList = CCalendar::GetPathes();
			if (isset($pathList[$siteId]))
			{
				if ($type === 'user' && isset($pathList[$siteId]['path_to_user_calendar']))
				{
					$path = $pathList[$siteId]['path_to_user_calendar'];
				}
				elseif ($type === 'group' && isset($pathList[$siteId]['path_to_group_calendar']))
				{
					$path = $pathList[$siteId]['path_to_group_calendar'];
				}
				else if (!empty($pathList[$siteId]['path_to_type_' . $type]))
				{
					$path = $pathList[$siteId]['path_to_type_' . $type];
				}
			}
		}

		if (!is_string($path))
		{
			$path =  '';
		}

		if (!empty($path) && $ownerId > 0)
		{
			if ($type === 'user')
			{
				$path = str_replace(['#user_id#', '#USER_ID#'], $ownerId, $path);
			}
			elseif ($type === 'group')
			{
				$path = str_replace(['#group_id#', '#GROUP_ID#'], $ownerId, $path);
			}
		}
		self::$pathCache[$key] = $path;
	}

	return self::$pathCache[$key];
}

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