Commit 428c43b8770513373289191430662d366e687818

Authored by Jarrett Jordaan
1 parent 0f3e84ed

Story ID:1166880:Updated Upgrade Refactor

Committed by: Jarrett Jordaan

Reviewed by: Paul Barrett
setup/upgrade/steps/upgradeWelcome.php
... ... @@ -48,7 +48,10 @@ class upgradeWelcome extends step {
48 48 protected $storeInSession = true;
49 49  
50 50 public function doStep() {
51   - $this->temp_variables = array("step_name"=>"welcome");
  51 + $upgradeOnly = false;
  52 + if(isset($_GET['action'])) if($_GET['action'] == 'installer') $upgradeOnly = true;
  53 +// print_r($_GET['action']);
  54 + $this->temp_variables = array("step_name"=>"welcome", "upgradeOnly"=>$upgradeOnly);
52 55 if($this->next()) {
53 56 if ($this->doRun()) {
54 57 return 'next';
... ... @@ -80,10 +83,25 @@ class upgradeWelcome extends step {
80 83 }
81 84  
82 85 private function checkPassword($username, $password) {
  86 + $upgradeOnly = false;
  87 +
  88 + if(isset($_POST['upgradeOnly'])) $upgradeOnly = $_POST['upgradeOnly'];
83 89 $dconf = $this->getDataFromPackage('installers', 'database'); // Use info from install
84   - if($dconf) {
  90 + if($dconf) { // From Install
85 91 $this->util->dbUtilities->load($dconf['dhost'], $dconf['dport'], $dconf['duname'], $dconf['dpassword'], $dconf['dname']);
86   - } else {
  92 + } elseif($upgradeOnly) {
  93 + require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
  94 + $wizConfigHandler = new configuration();
  95 + $configPath = $wizConfigHandler->readConfigPathIni();
  96 + $this->util->iniUtilities->load($configPath);
  97 + $dconf = $this->util->iniUtilities->getSection('db');
  98 + $this->util->dbUtilities->load($dconf['dbHost'],$dconf['dbPort'], $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']);
  99 + $sQuery = "SELECT count(*) AS match_count FROM users WHERE username = '$username' AND password = '".md5($password)."'";
  100 + $res = $this->util->dbUtilities->query($sQuery);
  101 + $ass = $this->util->dbUtilities->fetchAssoc($res);
  102 + if($ass[0]['match_count'] == 1)
  103 + return true;
  104 + } else { // Upgrade
87 105 require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
88 106 $wizConfigHandler = new configuration();
89 107 $configPath = $wizConfigHandler->readConfigPathIni();
... ... @@ -96,7 +114,7 @@ class upgradeWelcome extends step {
96 114 if($ass[0]['match_count'] == 1)
97 115 return true;
98 116 }
99   -
  117 + print_r($this->util->dbUtilities);
100 118 $this->error[] = 'Could Not Authenticate User';
101 119 return false;
102 120  
... ...
setup/upgrade/templates/backup.tpl
... ... @@ -56,8 +56,10 @@ if ($dir != '')
56 56 ?><input type="button" name="BackupNow" value="Next" class="button_next" onclick="doSubmit(this);"><?php
57 57 }
58 58 else if ($backupStatus) {
59   - ?><input type="submit" name="Next" value="Restore" class="button_next">
60   - <input type="submit" name="Upgrade" value="Upgrade" class="button_next"><?php
  59 + ?>
  60 + <input type="submit" name="Upgrade" value="Upgrade" class="button_next">
  61 + <input type="submit" name="Next" value="Restore" class="button_next">
  62 + <?php
61 63 }
62 64 else {
63 65 ?><input type="submit" name="Next" value="Next" class="button_next""><?php
... ...
setup/upgrade/templates/welcome.tpl
1 1 <form action="index.php?step_name=welcome" method="post">
2 2 <p class="title">Welcome to the KnowledgeTree Database Upgrade Wizard</p>
3   -
  3 + <input type="hidden" value="<?php echo $upgradeOnly?>" name="upgradeOnly">
4 4 <div id="step_content" class="step">
5 5 <br/>
6 6 <br/>
... ...