• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/chat.php
  • Класс: BitrixImOpenLinesChat
  • Вызов: Chat::startSession
public function startSession($userId)
{
	$result = false;

	if($this->isDataLoaded())
	{
		$session = new Session();
		$session->setChat($this);

		$resultLoad = $session->load(Array(
			'USER_CODE' => $this->chat['ENTITY_ID'],
			'MODE' => Session::MODE_OUTPUT,
			'OPERATOR_ID' => $userId,
		));

		if($resultLoad)
		{
			if($this->validationAction($session->getData('CHAT_ID')))
			{
				if ($session->isNowCreated())
				{
					$dateClose = new DateTime();
					$dateClose->add('1 MONTH');

					$sessionUpdate = Array(
						'CHECK_DATE_CLOSE' => $dateClose
					);
					$session->update($sessionUpdate);
				}
				else
				{
					$this->join($userId, false);
				}

				$result = true;
			}
		}
	}

	return $result;
}