• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/classes/general/im_chat.php
  • Класс: CIMChat
  • Вызов: CIMChat::Join
public function Join($chatId)
{
	$chatId = intval($chatId);
	if ($chatId <= 0)
	{
		$GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_EMPTY_CHAT_ID"), "EMPTY_CHAT_ID");
		return false;
	}

	$orm = IMModelChatTable::getById($chatId);
	if (!($chatData = $orm->fetch()))
	{
		$GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_CHAT_NOT_EXISTS"), "ERROR_CHAT_NOT_EXISTS");
		return false;
	}

	if ($chatData['TYPE'] != IM_MESSAGE_OPEN)
	{
		$GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_ACCESS_JOIN"), "ACCESS_JOIN");
		return false;
	}

	if (IMUser::getInstance($this->user_id)->isExtranet())
	{
		$GLOBALS["APPLICATION"]->ThrowException(GetMessage("IM_ERROR_ACCESS_JOIN"), "ACCESS_JOIN");
		return false;
	}

	$chat = new CIMChat(0);
	$chat->AddUser($chatId, $this->user_id);

	return true;
}