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,7 +48,10 @@ class upgradeWelcome extends step {
48 protected $storeInSession = true; 48 protected $storeInSession = true;
49 49
50 public function doStep() { 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 if($this->next()) { 55 if($this->next()) {
53 if ($this->doRun()) { 56 if ($this->doRun()) {
54 return 'next'; 57 return 'next';
@@ -80,10 +83,25 @@ class upgradeWelcome extends step { @@ -80,10 +83,25 @@ class upgradeWelcome extends step {
80 } 83 }
81 84
82 private function checkPassword($username, $password) { 85 private function checkPassword($username, $password) {
  86 + $upgradeOnly = false;
  87 +
  88 + if(isset($_POST['upgradeOnly'])) $upgradeOnly = $_POST['upgradeOnly'];
83 $dconf = $this->getDataFromPackage('installers', 'database'); // Use info from install 89 $dconf = $this->getDataFromPackage('installers', 'database'); // Use info from install
84 - if($dconf) { 90 + if($dconf) { // From Install
85 $this->util->dbUtilities->load($dconf['dhost'], $dconf['dport'], $dconf['duname'], $dconf['dpassword'], $dconf['dname']); 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 require_once("../wizard/steps/configuration.php"); // configuration to read the ini path 105 require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
88 $wizConfigHandler = new configuration(); 106 $wizConfigHandler = new configuration();
89 $configPath = $wizConfigHandler->readConfigPathIni(); 107 $configPath = $wizConfigHandler->readConfigPathIni();
@@ -96,7 +114,7 @@ class upgradeWelcome extends step { @@ -96,7 +114,7 @@ class upgradeWelcome extends step {
96 if($ass[0]['match_count'] == 1) 114 if($ass[0]['match_count'] == 1)
97 return true; 115 return true;
98 } 116 }
99 - 117 + print_r($this->util->dbUtilities);
100 $this->error[] = 'Could Not Authenticate User'; 118 $this->error[] = 'Could Not Authenticate User';
101 return false; 119 return false;
102 120
setup/upgrade/templates/backup.tpl
@@ -56,8 +56,10 @@ if ($dir != '') @@ -56,8 +56,10 @@ if ($dir != '')
56 ?><input type="button" name="BackupNow" value="Next" class="button_next" onclick="doSubmit(this);"><?php 56 ?><input type="button" name="BackupNow" value="Next" class="button_next" onclick="doSubmit(this);"><?php
57 } 57 }
58 else if ($backupStatus) { 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 else { 64 else {
63 ?><input type="submit" name="Next" value="Next" class="button_next""><?php 65 ?><input type="submit" name="Next" value="Next" class="button_next""><?php
setup/upgrade/templates/welcome.tpl
1 <form action="index.php?step_name=welcome" method="post"> 1 <form action="index.php?step_name=welcome" method="post">
2 <p class="title">Welcome to the KnowledgeTree Database Upgrade Wizard</p> 2 <p class="title">Welcome to the KnowledgeTree Database Upgrade Wizard</p>
3 - 3 + <input type="hidden" value="<?php echo $upgradeOnly?>" name="upgradeOnly">
4 <div id="step_content" class="step"> 4 <div id="step_content" class="step">
5 <br/> 5 <br/>
6 <br/> 6 <br/>