/** * Marks the current user as authorized for given channel. * * @param WiseChatChannel $channel * * @return null */ public function markAuthorizedForChannel($channel) { $grants = $this->userSessionDAO->get(self::SESSION_KEY_USER_CHANNEL_AUTHORIZATION); if (!is_array($grants)) { $grants = array(); } $grants[$channel->getId()] = true; $this->userSessionDAO->set(self::SESSION_KEY_USER_CHANNEL_AUTHORIZATION, $grants); }
/** * Resets tracking of the given event. Resets all events if event ID equals null. * * @param string $group Event group * @param string|null $id Event id * * @return null */ public function resetEventTracker($group, $id = null) { $prefix = self::SESSION_KEY_EVENT_TIME . md5($group) . '_'; if ($id !== null) { $sessionKey = $prefix . md5($id); if ($this->userSessionDAO->contains($sessionKey)) { $this->userSessionDAO->drop($sessionKey); } } else { $this->userSessionDAO->dropAllByPrefix($prefix); } }
/** * @param string $userName * * @return WiseChatUser */ private function createUserAndSave($userName) { WiseChatContainer::load('model/WiseChatUser'); // construct username and user object: $user = new WiseChatUser(); $user->setName($userName); $user->setSessionId($this->userSessionDAO->getSessionId()); $user->setIp($this->getRemoteAddress()); if ($this->options->isOptionEnabled('collect_user_stats', true)) { $this->fillWithGeoDetails($user); } // save user in DB and in the session: $this->usersDAO->save($user); $this->userSessionDAO->set(self::SESSION_KEY_USER_ID, $user->getId()); return $user; }
/** * Clears abuses counter. The counter is stored in user's session. * * @return null */ public function clearAbusesCounter() { $this->userSessionDAO->set(self::SESSION_KEY_ABUSES_COUNTER, 0); }