예제 #1
0
 /**
  * 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);
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
 /**
  * @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;
 }
예제 #4
0
 /**
  * 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);
 }