• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/log_destination.php
  • Класс: CSocNetLogDestination
  • Вызов: CSocNetLogDestination::GetLastUser
static function GetLastUser()
{
	global $USER;

	static $resultCache = array();

	$userId = intval($USER->GetID());

	if(!isset($resultCache[$userId]))
	{
		$arLastSelected = CUserOptions::GetOption("socialnetwork", "log_destination", array());
		$arLastSelected = (
			is_array($arLastSelected)
			&& $arLastSelected['users'] <> ''
			&& $arLastSelected['users'] !== '"{}"'
				? array_reverse(CUtil::JsObjectToPhp($arLastSelected['users']))
				: array()
		);

		if (is_array($arLastSelected))
		{
			if (!isset($arLastSelected[$userId]))
			{
				$arLastSelected['U'.$userId] = 'U'.$userId;
			}
		}
		else
		{
			$arLastSelected['U'.$userId] = 'U'.$userId;
		}

		$count = 0;
		$arUsers = Array();
		foreach ($arLastSelected as $userId)
		{
			if ($count < 5)
			{
				$count++;
			}
			else
			{
				break;
			}

			$arUsers[$userId] = $userId;
		}
		$resultCache[$userId] = array_reverse($arUsers);
	}

	return $resultCache[$userId];
}