/** * 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); }
/** * Checks whether it is time to trigger an event identified by group and id. * * @param string $group Event group * @param string $id Event id * * @return boolean */ public function shouldTriggerEvent($group, $id) { $sessionKey = self::SESSION_KEY_EVENT_TIME . md5($group) . '_' . md5($id); if (!$this->userSessionDAO->contains($sessionKey)) { $this->userSessionDAO->set($sessionKey, time()); return true; } else { $diff = time() - $this->userSessionDAO->get($sessionKey); if ($diff > $this->getEventTimeThreshold($group)) { $this->userSessionDAO->set($sessionKey, time()); return true; } } return false; }
/** * @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); }