コード例 #1
0
 public function execute($filterChain)
 {
     if (!$this->isFirstCall()) {
         return;
     }
     $this->prefix = sfConfig::get('app_phpbb_prefix', 'Phpbb');
     // When we are logged out of phpBB, the system sets a cookie with id = 1.
     // Because we want to log out of Symfony when this happens, we check for
     // cookies with user id different from the current logged in symfony user.
     if ($this->getContext()->getUser()->isAuthenticated() && $this->getContext()->getRequest()->getCookie(avrPhpbbConfig::getCookieName() . '_u') != $this->getContext()->getUser()->getUserId()) {
         $this->getContext()->getUser()->signOut();
     }
     // We only want to invoke the sign in if the user is not already authenticated.
     if (!$this->getContext()->getUser()->isAuthenticated()) {
         $cookieName = avrPhpbbConfig::getCookieName();
         // If the cookies are ok, the user gets signed in.
         if (avrPhpbbSessions::checkCookie($cookieName)) {
             $userId = $this->getContext()->getRequest()->getCookie($cookieName . '_u');
             $user = avrPropelTools::invokePeerMethod($this->prefix . 'Users', 'retrieveByPk', $userId);
             // Since the user is already signed in to phpBB, we only sign in to Symfony
             $this->getContext()->getUser()->signInSymfony($user);
         }
     }
     $filterChain->execute();
 }
コード例 #2
0
 public static function getUserByUsername($username)
 {
     $prefix = sfConfig::get('app_phpbb_prefix', 'Phpbb');
     $c = new Criteria();
     avrPropelTools::criteriaAdd($c, $prefix . 'Users', 'username', $username);
     return avrPropelTools::invokePeerMethod($prefix . 'Users', 'doSelectOne', $c);
 }
コード例 #3
0
 public static function checkCookie($cookieName)
 {
     $prefix = sfConfig::get('app_phpbb_prefix', 'Phpbb');
     $request = sfContext::getInstance()->getRequest();
     $sessionKey = $request->getCookie($cookieName . '_k');
     $sessionId = $request->getCookie($cookieName . '_sid');
     $userId = $request->getCookie($cookieName . '_u');
     $c = new Criteria();
     avrPropelTools::criteriaAdd($c, $prefix . 'Sessions', 'session_id', $sessionId);
     avrPropelTools::criteriaAdd($c, $prefix . 'Sessions', 'session_user_id', $userId);
     $sessions = avrPropelTools::invokePeerMethod($prefix . 'Sessions', 'doCount', $c);
     return $sessions == 1;
 }
コード例 #4
0
 public function getPhpbbUser()
 {
     if (!$this->user && ($id = $this->getAttribute('user_id', null, 'avrPhpbbSecurityUser'))) {
         $this->user = avrPropelTools::invokePeerMethod($this->prefix . "Users", "retrieveByPK", $id);
         if (!$this->user) {
             // the user does not exist anymore in the database
             $this->signOut();
             // @todo Create avrPhpbbException
             throw new sfException('The user does not exist anymore in the database.');
         }
     }
     return $this->user;
 }
コード例 #5
0
 public function execute($filterChain)
 {
     $this->prefix = sfConfig::get('app_phpbb_prefix', 'Phpbb');
     // We only want to invoke the remembering filter if the user is not already authenticated
     if ($this->isFirstCall() && !$this->getContext()->getUser()->isAuthenticated()) {
         if ($cookie = $this->getContext()->getRequest()->getCookie(sfConfig::get('app_phpbb_remember_cookie_name', 'avrPhpbbRememberKey'))) {
             $key = unserialize(base64_decode($cookie));
             $c = new Criteria();
             avrPropelTools::criteriaAdd($c, $this->prefix . 'ProfileFieldData', 'PF_REMEMBER_KEY', $key[0]);
             avrPropelTools::criteriaAdd($c, $this->prefix . 'ProfileFieldData', 'USER_ID', $key[1]);
             avrPropelTools::criteriaAddJoin($c, $this->prefix . 'ProfileFieldData', 'USER_ID', $this->prefix . 'User', 'USER_ID');
             $user = avrPropelTools::invokePeerMethod($this->prefix . 'User', 'doSelectOne', $c);
             // If the user is found with the given key and user id, the user is logged in. Otherwise nothing happens.
             if ($user) {
                 $this->getContext()->getUser()->signIn($user);
             }
         }
     }
     $filterChain->execute();
 }
コード例 #6
0
 public static function setConfigValueFor($input, $value)
 {
     $prefix = sfConfig::get('app_phpbb_prefix', 'Phpbb');
     $c = new Criteria();
     avrPropelTools::criteriaAdd($c, $prefix . 'Config', 'config_name', $input);
     $newestUserConfig = avrPropelTools::invokePeerMethod($prefix . 'Config', 'doSelectOne', $c);
     $newestUserConfig->setConfigValue($value);
     $newestUserConfig->save();
     sfProcessCache::delete('config_values');
     sfProcessCache::delete('config_values_dynamic');
 }