/**
  * Handles all errors in the application
  *
  * @access public
  * @return void
  */
 public function errorAction()
 {
     $content = null;
     $errors = $this->_getParam('error_handler');
     switch ($errors->type) {
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
             // 404 error -- controller or action not found
             $this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found');
             // ... get some output to display...
             $content .= '<h1>' . $this->t->_('404 Page not found!') . '</h1>' . PHP_EOL;
             $content .= '<p>' . $this->t->_('The page you requested was not found.') . '</p>';
             break;
         default:
             // application error; display error page, but don't change
             // status code
             $content .= '<h1>' . $this->t->_('Error!') . '</h1>' . PHP_EOL;
             $content .= '<p>' . $this->t->_('An unexpected error occurred with your request. Please try again later.') . '</p>';
             // Log the exception
             $exception = $errors->exception;
             App_Logger::log(sprintf("%s\n\n%s", $exception->getMessage(), $exception->getTraceAsString()), Zend_Log::ERR);
             break;
     }
     // Clear previous content
     $this->getResponse()->clearBody();
     $this->view->content = $content;
 }
Example #2
0
 /**
  * Remove a file from the CDN and S3
  *
  * @return void
  */
 public function removeFromCDN()
 {
     //Remove from S3
     App_DI_Container::get('S3StorageEngine')->deleteItem($this->filename, array(Zend_Cloud_StorageService_Adapter_S3::BUCKET_NAME => App_DI_Container::get('ConfigObject')->amazon->s3->assets_bucket));
     //Invalidate the image in the CDN
     if (!App_DI_Container::get('CloudFront')->invalidate($this->filename)) {
         App_Logger::log(sprintf('Error removing %s from CDN', $this->filename), Zend_Log::ERR);
     }
 }
 /**
  * Logs an user in the application based on his
  * username and email
  * 
  * @param string $username
  * @param string $password
  * @param boolean $remember
  * @access public
  * @return void
  */
 public function login($username, $password, $remember = FALSE)
 {
     // adapter cfg
     $adapter = new Zend_Auth_Adapter_DbTable($this->_db);
     $adapter->setTableName($this->_name);
     $adapter->setIdentityColumn('username');
     $adapter->setCredentialColumn('password');
     // checking credentials
     $adapter->setIdentity($username);
     $adapter->setCredential(BaseUser::hashPassword($password));
     try {
         $result = $adapter->authenticate();
     } catch (Zend_Auth_Adapter_Exception $e) {
         App_Logger::log(sprintf("Exception catched while login: %s", $e->getMessage()), Zend_Log::ERR);
         return FALSE;
     }
     if ($result->isValid()) {
         // get the user row
         $loggedUser = $adapter->getResultRowObject(NULL, 'password');
         //Check if the account has been closed
         if ($loggedUser->deleted) {
             return NULL;
         }
         // clear the existing data
         $auth = Zend_Auth::getInstance();
         $auth->clearIdentity();
         if (!empty($loggedUser->id)) {
             switch (CURRENT_MODULE) {
                 case 'frontend':
                     $userModel = new User();
                     $user = $userModel->findById($loggedUser->id);
                     $user->get('group');
                     $session = new stdClass();
                     foreach (get_object_vars($loggedUser) as $k => $v) {
                         $session->{$k} = $v;
                     }
                     $session->group->name = $user->get('group')->name;
                     break;
                 case 'backoffice':
                     $userModel = new BackofficeUser();
                     $user = $userModel->findById($loggedUser->id);
                     $user->groups = $user->findManyToManyRowset('Group', 'BackofficeUserGroup');
                     $user->group = $user->groups[0];
                     $session = new stdClass();
                     foreach (get_object_vars($loggedUser) as $k => $v) {
                         $session->{$k} = $v;
                     }
                     $session->group->name = $user->group->name;
                     break;
             }
             $auth->getStorage()->write($session);
         }
         $this->update(array('last_login' => new Zend_Db_Expr('NOW()')), $this->_db->quoteInto('id = ?', $user->id));
         if ($rememberMe) {
             Zend_Session::rememberMe(App_DI_Container::get('ConfigObject')->session->remember_me->lifetime);
         } else {
             Zend_Session::forgetMe();
         }
         return TRUE;
     } else {
         return FALSE;
     }
 }
 /**
  * Controller's entry point
  *
  * @access public
  * @return void
  */
 public function indexAction()
 {
     App_Logger::log('test');
 }