public function execute($request)
 {
     $upgradeUtility = new UpgradeUtility();
     $upgradeUtility->setDbConnection($this->getUser()->getAttribute('dbConnection'));
     $tableStatus = $upgradeUtility->isUpgradeInfoTableAvailable();
     $versionInfo = $request->getParameter('versionInfo');
     $submitBy = $versionInfo['submitBy'];
     if (!$tableStatus && $submitBy != 'selectVersion') {
         $this->redirect('upgrade/selectVersion');
     }
     $this->form = new VersionInfoForm();
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $selectedVersion = $this->form->getValue('version');
             if ($selectedVersion < 0) {
                 throw new Exception("Invalid version");
             }
             $this->getUser()->setAttribute('upgrade.startIncNumber', $upgradeUtility->getStartIncrementNumber($selectedVersion));
             $this->getUser()->setAttribute('upgrade.endIncNumber', $upgradeUtility->getEndIncrementNumber());
             $this->getUser()->setAttribute('upgrade.currentVersion', $selectedVersion);
             $this->getRequest()->setParameter('submitBy', 'calculateIncrementNumbers');
             $this->forward('upgrade', 'index');
         }
     }
 }
 public function execute($request)
 {
     $this->form = new DatabaseInfo();
     $upgradeUtility = new UpgradeUtility();
     $this->newVersion = $upgradeUtility->getNewVersion();
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter('databaseInfo'));
         if ($this->form->isValid()) {
             $dbInfo = array();
             $dbInfo['host'] = $this->form->getValue('host');
             $dbInfo['port'] = $this->form->getValue('port');
             $dbInfo['username'] = $this->form->getValue('username');
             $dbInfo['password'] = $this->form->getValue('password');
             $dbInfo['database'] = $this->form->getValue('database_name');
             $this->getUser()->setAttribute('dbInfo', $dbInfo);
             $upgraderUtility = new UpgradeUtility();
             $result = $upgraderUtility->checkDatabaseConnection($dbInfo['host'], $dbInfo['username'], $dbInfo['password'], $dbInfo['database'], $dbInfo['port']);
             if (!$result) {
                 $this->getUser()->setFlash('errorMessage', __('Failed to Connect: Check Database Details'));
             } else {
                 $result = $upgraderUtility->checkDatabaseStatus();
                 if (!$result) {
                     $this->getUser()->setFlash('errorMessage', __('Failed to Proceed: Interrupted Database'));
                 } else {
                     $this->getUser()->setAuthenticated(true);
                     $this->getRequest()->setParameter('submitBy', 'databaseInfo');
                     $this->forward('upgrade', 'index');
                 }
             }
         }
     }
 }
 public function execute($request)
 {
     $upgradeUtility = new UpgradeUtility();
     $this->newVersion = $upgradeUtility->getNewVersion();
     $currentUri = $this->getRequest()->getUri();
     $this->mainAppUrl = str_replace("/upgrader/web/index.php/upgrade/executeComplete", "", $currentUri);
 }
Exemplo n.º 4
0
 protected function getVersionWidgetOptions()
 {
     $widgetVersions = array('-1' => '-- ' . __('Select') . ' --');
     $upgradeUtility = new UpgradeUtility();
     $versionArray = array_keys($upgradeUtility->getVersionAndIncrementerNumbers());
     foreach ($versionArray as $version) {
         $widgetVersions[$version] = $version;
     }
     return $widgetVersions;
 }
 public function execute($request)
 {
     $upgradeUtility = new UpgradeUtility();
     $startIncNumber = $this->getUser()->getAttribute('upgrade.startIncNumber');
     $endIncNumber = $this->getUser()->getAttribute('upgrade.endIncNumber');
     $startVersion = $this->getUser()->getAttribute('upgrade.currentVersion');
     $endVersion = $upgradeUtility->getNewVersion();
     $this->newVersion = $upgradeUtility->getNewVersion();
     $this->notes = $upgradeUtility->getNotes($startIncNumber, $endIncNumber);
     $upgradeDetails = array('start_version' => $startVersion, 'end_version' => $endVersion, 'start_increment' => $startIncNumber, 'end_increment' => $endIncNumber);
     UpgradeLogger::writeNoteMessage($upgradeDetails, $this->notes);
     if ($request->isMethod('post')) {
         $this->getRequest()->setParameter('submitBy', 'displayVersionInfo');
         $this->forward('upgrade', 'index');
     }
 }
 public function execute($request)
 {
     $this->form = new ConfigureFile();
     $this->confFileCreted = array('Pending', 'Pending');
     $this->buttonState = "Start";
     if ($request->isMethod('post')) {
         if ($request->getParameter('sumbitButton') == 'Proceed') {
             $this->getRequest()->setParameter('submitBy', 'configureFile');
             $this->forward('upgrade', 'index');
         }
         $this->form->bind($request->getParameter('configureFile'));
         if ($this->form->isValid()) {
             $upgraderUtility = new UpgradeUtility();
             $dbInfo = $this->getUser()->getAttribute('dbInfo');
             $host = $dbInfo['host'];
             $username = $dbInfo['username'];
             $password = $dbInfo['password'];
             $port = $dbInfo['port'];
             $database = $dbInfo['database'];
             $upgraderUtility->setApplicationRootPath($this->applicationRootPath);
             $result[] = $upgraderUtility->writeConfFile($host, $port, $database, $username, $password);
             $result[] = $upgraderUtility->writeSymfonyDbConfigFile($host, $port, $database, $username, $password);
             if ($result[0]) {
                 $this->confFileCreted[0] = 'Done';
             }
             if ($result[1]) {
                 $this->confFileCreted[1] = 'Done';
             }
             $success = true;
             foreach ($result as $res) {
                 if (!$res) {
                     $success = false;
                     break;
                 }
             }
             if ($success) {
                 $this->buttonState = 'Proceed';
                 $upgraderUtility->getDbConnection($host, $username, $password, $database, $port);
                 $upgraderUtility->dropUpgradeStatusTable();
                 $startIncrement = $this->getUser()->getAttribute('upgrade.startIncNumber');
                 $endIncrement = $this->getUser()->getAttribute('upgrade.endIncNumber');
                 $startVersion = $this->getUser()->getAttribute('upgrade.currentVersion');
                 $endVersion = $upgraderUtility->getNewVersion();
                 $date = gmdate("Y-m-d H:i:s", time());
                 $result = $upgraderUtility->insertUpgradeHistory($startVersion, $endVersion, $startIncrement, $endIncrement, $date);
             }
         }
     }
 }
Exemplo n.º 7
0
         $final_version = max($script->to_version, $final_version);
     }
     // foreach
     require UPGRADE_SCRIPT_PATH . '/include/upgrade_steps.php';
     die;
     break;
     // Execute single upgrade step
 // Execute single upgrade step
 case 'execute_step':
     $group = array_var($_POST, 'group');
     $step = array_var($_POST, 'step');
     if (empty($group) || empty($step)) {
         die('Group and step are required');
     }
     // if
     $util = new UpgradeUtility();
     $script = $util->getScriptByGroup($group);
     if (instance_of($script, 'UpgradeScript')) {
         $execute = $script->{$step}();
         if ($execute === true) {
             die('all_ok');
         } else {
             die('Error: ' . $execute);
         }
     } else {
         die("Failed to load gorup '{$group}'");
     }
     // if
     break;
     // Unknown action, nothing to do here
 // Unknown action, nothing to do here