Ejemplo n.º 1
0
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     /* Redirect to the upgrade controller if an upgrade is neccessary */
     if (Phprojekt_Auth::isLoggedIn() && ($request->getModuleName() != 'Core' || $request->getControllerName() != 'Upgrade') && ($request->getControllerName() != 'Login' || $request->getActionName() != 'logout')) {
         $migration = new Phprojekt_Migration($this->_extensions);
         if ($migration->needsUpgrade()) {
             $this->_request->setModuleName('Core');
             $this->_request->setControllerName('Upgrade');
             $this->_request->setActionName('index');
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Perform the upgrade for a single module.
  *
  * The module is taken from the 'upgradeModule' parameter of the request.
  *
  * @return void
  */
 public function jsonUpgradeAction()
 {
     if (!Phprojekt_Auth::isAdminUser()) {
         throw new Zend_Controller_Action_Exception('Insufficient rights.', 403);
     }
     $extensions = new Phprojekt_Extensions(PHPR_CORE_PATH);
     $migration = new Phprojekt_Migration($extensions);
     $failed = true;
     try {
         $migration->performUpgrade($this->getRequest()->getParam('upgradeModule'));
         $failed = false;
     } catch (Phprojekt_Migration_IKilledTheDatabaseException $e) {
         Phprojekt::getInstance()->getLog()->debug("IKilledTheDatabaseException occurred while migrating: " . $e->getFile() . ':' . $e->getLine() . "\n" . $e->getMessage() . "\n" . $e->getTraceAsString() . "\n");
         Phprojekt_Converter_Json::echoConvert(array('type' => 'fatalFailure', 'message' => 'A fatal error has occured.'));
     } catch (Exception $e) {
         Phprojekt::getInstance()->getLog()->debug("Exception occurred while migrating: " . $e->getFile() . ':' . $e->getLine() . "\n" . $e->getMessage() . "\n" . $e->getTraceAsString() . "\n");
         Phprojekt_Converter_Json::echoConvert(array('type' => 'failure', 'message' => 'An error has occured.'));
     }
     if (!$failed) {
         Phprojekt_Converter_Json::echoConvert(array('type' => 'success', 'message' => 'The module was upgraded correctly'));
     }
 }