• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/session.php
  • Класс: BitrixImOpenLinesSession
  • Вызов: Session::getLast
public function getLast(array $params): Result
{
	$result = new Result();

	if (empty($params['USER_CODE']))
	{
		$result->addError(new Error(Loc::getMessage('IMOL_SESSION_ERROR_NO_USER_CODE'), 'NO IMOL CONFIGURATION', __METHOD__));
	}

	$select = ModelSessionTable::getSelectFieldsPerformance();

	$orm = ModelSessionTable::getList([
		'select' => $select,
		'filter' => [
			'=USER_CODE' => $params['USER_CODE'],
		],
		'order' => ['ID' => 'DESC'],
		'limit' => 1
	]);
	$loadSession = $orm->fetch();

	if (!empty($loadSession))
	{
		$loadSession['SESSION_ID'] = $loadSession['ID'];
		$this->session = $loadSession;
		$this->chat = new Chat($this->session['CHAT_ID']);

		$configManager = new Config();
		$this->config = $configManager->get($loadSession['CONFIG_ID']);
	}
	else
	{
		$result->addError(new Error(Loc::getMessage('IMOL_SESSION_ERROR_NO_LAST_SESSION'), 'NO LAST SESSION', __METHOD__));
	}

	return $result;
}