/** * Determines if the number of channels that current user participates has been reached. * * @param WiseChatChannel $channel * * @return boolean */ public function isChatChannelsLimitReached($channel) { $limit = $this->options->getIntegerOption('channels_limit', 0); if ($limit > 0) { $this->userService->refreshChannelUsersData(); $amountOfChannels = $this->channelUsersDAO->getAmountOfActiveBySessionId(session_id()); $user = $this->authentication->getUser(); if ($user === null || $channel === null || $this->channelUsersDAO->getActiveByUserIdAndChannelId($user->getId(), $channel->getId()) === null) { $amountOfChannels++; } if ($amountOfChannels > $limit) { return true; } } return false; }