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();
 }
 /**
  * Whether or not the users account is activated.
  * 
  * @todo This method is probably a little rough according to the specific way 
  *       phpBB3 actually works, and might need a little more work.
  */
 public static function isActivated($user)
 {
     if (method_exists($user, 'isActivated')) {
         return call_user_func(array($user, 'isActivated'));
     }
     // If activation is not required, the user is per definition activated.
     if (avrPhpbbConfig::getConfigValueFor('require_activation') == 0) {
         return true;
     }
     // If there is no activation key, but activation is required, the user has
     // activated the account.
     if ($user->getUserActKey() == '') {
         return true;
     }
     return false;
 }
 protected function unsetCookies()
 {
     $cookieName = avrPhpbbConfig::getCookieName();
     $domain = avrPhpbbConfig::getCookieDomain();
     $response = sfContext::getInstance()->getResponse();
     $response->setCookie($cookieName . '_k', '', time() - 3600, '/', $domain);
     $response->setCookie($cookieName . '_u', 0, time() - 3600, '/', $domain);
     $response->setCookie($cookieName . '_sid', '', time() - 3600, '/', $domain);
 }