• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/classes/general/event_calendar.php
  • Класс: CEventCalendar
  • Вызов: CEventCalendar::HandleSuperpose
function HandleSuperpose($arCommonIDs = array(), $bCleanCache = false)
{
	if (!class_exists('CUserOptions'))
		return false;

	$arIds = $this->GetDisplayedSPCalendars();
	$this->arSPCalShow = array();

	$bCache = $this->bCache;
	$cachePath = $this->cachePath.'sp_handle/'.($this->curUserId % 1000)."/";
	if ($bCleanCache && $bCache)
	{
		$cache = new CPHPCache;
		$cache->CleanDir($cachePath);
		$bCache = false;
	}

	if ($bCache)
	{
		$cache = new CPHPCache;
		$cacheId = serialize(array($this->curUserId, $GLOBALS['USER']->GetUserGroupArray()));

		if ($cache->InitCache($this->cacheTime, $cacheId, $cachePath))
		{
			$res = $cache->GetVars();
			$this->arSPCal = $res['arSPCal'];
			$this->bSuperpose = $res['bSuperpose'];
		}
	}

	if (!$bCache || empty($res['arSPCal']))
	{
		$this->arSPCal = array();

		// *** For social network ***
		if (class_exists('CSocNetUserToGroup') && ($GLOBALS['USER']->IsAuthorized() || !$this->bCurUser))
		{
			//Groups calendars
			if ($this->superposeGroupsCals)
				$this->GetGroupsSPCalendars();

			//Users calendars
			$arUserIds = $this->superposeUsersCals ? $this->GetTrackingUsers() : array();

			// Add current user
			if ($this->superposeCurUserCals && !in_array($this->userId, $arUserIds))
				$arUserIds[] = $this->userId;

			if (count($arUserIds) > 0)
			{
				$arFeatures = CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $arUserIds, "calendar");
				$arView = CSocNetFeaturesPerms::CanPerformOperation($this->userId, SONET_ENTITY_USER, $arUserIds, "calendar", 'view');

				for($i = 0, $l = count($arUserIds); $i < $l; $i++)
				{
					$userId = intval($arUserIds[$i]);
					if ($userId <= 0)
						continue;

					if ($arFeatures[$userId] && $arView[$userId])
						$this->GetUserSPCalendars($userId, $this->userId == $userId);
				}
			}
		}

		// Common calendars
		if (is_array($arCommonIDs) && count($arCommonIDs) > 0)
			$this->GetCommonSPCalendars($arCommonIDs);

		if ($bCache)
		{
			$cache->StartDataCache($this->cacheTime, $cacheId, $cachePath);
			$cache->EndDataCache(array(
				"arSPCal" => $this->arSPCal,
				"bSuperpose" => $this->bSuperpose,
			));
		}
	}

	if (count($this->arSPCal) > 0)
		$this->arSPCalShow = $this->CheckDisplayedSPCalendars($arIds, $this->arSPCal);
}