Ejemplo n.º 1
0
 public function sessionsTable($sessions)
 {
     $this->logger = SfContext::getInstance()->getLogger();
     $this->sessionsArray = $sessions;
     $this->haveClassesToday = false;
     //Agafem com a date el dia actual
     $this->date = date('d/m/Y', mktime(0, 0, 0, date('m'), date('d'), date('Y')));
 }
Ejemplo n.º 2
0
 /**
  * Executes this filter.
  *
  * @param sfFilterChain $filterChain A sfFilterChain instance
  */
 public function execute($filterChain)
 {
     //load oauth configuration
     $actionInstance = $this->context->getController()->getActionStack()->getLastEntry()->getActionInstance();
     $sfoauth = new sfOauth($this->context, $actionInstance->getModuleName(), $actionInstance->getActionName());
     $request = $this->context->getRequest();
     $req = OAuthRequest::from_request();
     SfContext::getInstance()->getLogger()->debug("Abans de comprovar la versió");
     if ($req->get_parameter('oauth_version', NULL) == "1.0") {
         SfContext::getInstance()->getLogger()->debug("Versio 1.0");
         $oauthServer = new sfoauthserver(new sfOAuthDataStore());
         $oauthServer->verify_request($req);
     } else {
         if ($request->getParameter('oauth_version', NULL) != NULL) {
             throw new OAuthException('not supported version');
         } else {
             SfContext::getInstance()->getLogger()->debug("No hi ha versio");
             throw new OAuthException('oauth_version parameter missing');
         }
     }
     SfContext::getInstance()->getLogger()->debug("Configura coses");
     $token = $req->get_parameter('oauth_token');
     $sfToken = Doctrine::getTable('sfOauthServerAccessToken')->findOneByToken($token);
     $user = $sfToken->getUser();
     // Select user concerned
     $consumer = $sfToken->getConsumer();
     $consumer->increaseNumberQuery();
     $request->setParameter('sfGuardUser', $user);
     // save this user in a parameter 'user'
     $request->setParameter('sfOauthConsumer', $consumer);
     // save consumer in a parameter 'consumer'
     $credential = $sfoauth->getOauthCredential();
     SfContext::getInstance()->getLogger()->debug("Acaba de configurar coses");
     if (null !== $credential && !$sfToken->hasCredential($credential)) {
         throw new OAuthException('Unauthorized Access');
     }
     // chek if the consumer is allowed to access to this action
     // this aplpication has access, continue
     $filterChain->execute();
 }