• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/V2/Chat.php
  • Класс: BitrixImV2Chat
  • Вызов: Chat::hasPostAccess
public function hasPostAccess(?int $userId = null): bool
{
	$canPost = $this->getCanPost();

	if (!$userId)
	{
		$userId = $this->getContext()->getUserId();
	}

	switch ($canPost)
	{
		case self::MANAGE_RIGHTS_MEMBER:
			return !!$this->getRelations([
				'FILTER' => [
					'USER_ID' => $userId,
				],
				'LIMIT' => 1,
			])->count();
		case self::MANAGE_RIGHTS_MANAGERS:
			return !!$this->getRelations([
				'FILTER' => [
					'USER_ID' => $userId,
					'MANAGER' => 'Y'
				],
				'LIMIT' => 1,
			])->count();
		case self::MANAGE_RIGHTS_OWNER:
			return $userId === $this->getAuthorId();
		default:
			return false;
	}
}