Example #1
0
 /**
  * Get a file from a users session stored hash
  *
  * @param string $filename
  * @return \Foundation\Virtual\RealFile
  */
 public function getSessionFile($filename)
 {
     $sessionKey = $this->sessionKeyFromFileName($filename);
     if ($this->getSessionStore()->check($sessionKey) and $path = $this->getFilePath($this->_sessionStore->get($sessionKey))) {
         return new \Foundation\Virtual\RealFile($filename, $path);
     }
     return false;
 }
Example #2
0
 /**
  * Check saml authentication and store credential into
  */
 public final function __construct()
 {
     parent::__construct();
     $this->layout = 'wide';
     $this->_store = $this->_session->getStore(self::SESSION_STORE_NAME, $this->_config->getAdminSessionLifetime());
     if ($this->isPreviewMode()) {
         $class = '\\Jazzee\\AdminAuthentication\\PreviewApplication';
     } else {
         $class = $this->_config->getAdminAuthenticationClass();
     }
     $this->_adminAuthentication = new $class($this);
     if (!$this->_adminAuthentication instanceof Interfaces\AdminAuthentication) {
         throw new Exception($this->_config->getAdminAuthenticationClass() . ' does not implement AdminAuthentication Interface.');
     }
     if ($this->_adminAuthentication->isValidUser()) {
         $this->_user = $this->_adminAuthentication->getUser();
         if ($this->_user->getDefaultProgram()) {
             $this->_program = $this->_user->getDefaultProgram();
         } else {
             if ($programs = $this->_user->getPrograms()) {
                 $programId = array_pop($programs);
                 $program = $this->_em->getRepository('\\Jazzee\\Entity\\Program')->find($programId);
                 $this->_program = $program;
                 $this->_user->setDefaultProgram($program);
                 $this->_em->persist($this->_user);
             }
         }
         if ($this->_user->getDefaultCycle()) {
             $this->_cycle = $this->_user->getDefaultCycle();
         } else {
             if ($cycle = $this->_em->getRepository('\\Jazzee\\Entity\\Cycle')->findBestCycle($this->_program)) {
                 $this->_cycle = $cycle;
                 $this->_user->setDefaultCycle($cycle);
                 $this->_em->persist($this->_user);
             }
         }
         if (isset($this->_store->currentProgramId)) {
             $this->_program = $this->_em->getRepository('\\Jazzee\\Entity\\Program')->find($this->_store->currentProgramId);
         }
         if (isset($this->_store->currentCycleId)) {
             $this->_cycle = $this->_em->getRepository('\\Jazzee\\Entity\\Cycle')->find($this->_store->currentCycleId);
         }
         if ($this->_cycle and $this->_program) {
             if (!($this->_application = $this->_em->getRepository('Jazzee\\Entity\\Application')->findOneByProgramAndCycle($this->_program, $this->_cycle))) {
                 $this->_application = null;
             }
         }
     } else {
         //expire the store for non users - so there are no navigation or caching problems
         $this->_store->expire();
     }
     if ($this->_config->getAdminSessionLifetime()) {
         setcookie('JazzeeAdminLoginTimeout', time() + $this->_config->getAdminSessionLifetime(), 0, '/');
     } else {
         //if there is no seesion limiter then setup for 24 hours
         setcookie('JazzeeAdminLoginTimeout', time() + 86400, 0, '/');
     }
 }