Commit 83ec1eacebcc566ebe4b7cfcb72d525f982e843f

Authored by jarrett
1 parent e3c1352a

Updated Upgrade Wizard Refactor

Commited By: Jarrett Jordaan

Reviewed By: Megan Watson
setup/migrate/step.php
... ... @@ -117,15 +117,6 @@ class Step
117 117 */
118 118 public $util;
119 119  
120   - /**
121   - * Reference to utility object
122   - *
123   - * @author KnowledgeTree Team
124   - * @access protected
125   - * @var object
126   - */
127   - public $dbhandler;
128   -
129 120 public function __construct() {
130 121 $this->util = new MigrateUtil();
131 122 }
... ...
setup/migrate/steps/migrateInstallation.php
... ... @@ -147,7 +147,8 @@ class migrateInstallation extends step
147 147 $this->storeSilent();
148 148 return false;
149 149 } else {
150   - if($this->readVersion()) {
  150 + $this->foundVersion = $this->readVersion();
  151 + if($version) {
151 152 $this->checkVersion();
152 153 }
153 154 $this->storeSilent();
... ... @@ -169,8 +170,8 @@ class migrateInstallation extends step
169 170 public function readVersion() {
170 171 $verFile = $this->location."/knowledgeTree/docs/VERSION.txt";
171 172 if(file_exists($verFile)) {
172   - $this->foundVersion = file_get_contents($verFile);
173   - return true;
  173 + $foundVersion = file_get_contents($verFile);
  174 + return $foundVersion;
174 175 } else {
175 176 $this->error[] = "KT installation version not found";
176 177 }
... ... @@ -226,9 +227,7 @@ class migrateInstallation extends step
226 227 }
227 228  
228 229 private function loadConfig($path) {
229   -// $ini = $this->util->loadInstallIni($path);
230 230 $this->util->iniUtilities->load($path);
231   -// $dbSettings = $ini->getSection('db');
232 231 $dbSettings = $this->util->iniUtilities->getSection('db');
233 232 $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'],
234 233 'dbName'=> $dbSettings['dbName'],
... ... @@ -239,15 +238,12 @@ class migrateInstallation extends step
239 238 'dbAdminPass'=> $dbSettings['dbAdminPass'],
240 239 );
241 240 $ktSettings = $this->util->iniUtilities->getSection('KnowledgeTree');
242   -// $ktSettings = $ini->getSection('KnowledgeTree');
243 241 $froot = $ktSettings['fileSystemRoot'];
244 242 if ($froot == 'default') {
245 243 $froot = $this->location;
246 244 }
247 245 $this->ktSettings = array('fileSystemRoot'=> $froot,
248 246 );
249   -// $urlPaths = $ini->getSection('urls');
250   -// $urlPaths = $this->util->iniUtilities->getSection('urls');
251 247 $varDir = $froot.DS.'var';
252 248 $this->urlPaths = array(array('name'=> 'Var Directory', 'path'=> $varDir),
253 249 array('name'=> 'Log Directory', 'path'=> $varDir.DS.'log'),
... ...
setup/migrate/templates/error.tpl
1 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2 2 <html>
3 3 <head>
  4 + <link rel="shortcut icon" href="../wizard/resources/graphics/favicon.ico" type="image/x-icon">
4 5 <title>KnowledgeTree Installer</title>
5 6 <script type="text/javascript" src="resources/jquery.js"></script>
6 7 <script type="text/javascript" src="resources/wizard.js" ></script>
7 8 <link rel="stylesheet" type="text/css" href="resources/wizard.css" />
8   -
9 9 </head>
10 10  
11 11 <body onload="">
... ... @@ -14,7 +14,7 @@
14 14 <div id="logo"><img src="resources/graphics/dame/installer-header_logo.png"/></div>
15 15 <div id="install_details">
16 16 <span style="font-size:120%;"> 3.7 </span>
17   - <span style="font-size:80%;">Commercial Edition</span>
  17 + <span style="font-size:80%;">Community Edition</span>
18 18 </div>
19 19 </div>
20 20 <div id="wrapper">
... ...
setup/migrate/templates/wizard.tpl
1 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2 2 <html>
3 3 <head>
  4 + <link rel="shortcut icon" href="../wizard/resources/graphics/favicon.ico" type="image/x-icon">
4 5 <title>KnowledgeTree Installer</title>
5 6 <?php echo $html->js('jquery.js'); ?>
6 7 <?php echo $html->js('jquery.form.js'); ?>
... ...
setup/upgrade/step.php
... ... @@ -110,7 +110,6 @@ class Step
110 110  
111 111 public function __construct() {
112 112 $this->util = new UpgradeUtil();
113   - //$this->dbhandler = $this->util->dbUtilities;
114 113 }
115 114  
116 115 /**
... ...
setup/upgrade/steps/upgradeDatabase.php
... ... @@ -43,7 +43,8 @@
43 43 //require_once('../../config/dmsDefaults.php');
44 44 //require_once(KT_LIB_DIR . '/config/config.inc.php');
45 45 //require_once(KT_LIB_DIR . '/plugins/pluginutil.inc.php');
46   -//require_once(KT_LIB_DIR . '/upgrades/upgrade.inc.php');
  46 +//define('KT_LIB_DIR', SYSTEM_DIR.'lib'.DS);
  47 +//require_once(SYSTEM_DIR . 'lib/upgrades/upgrade.inc.php');
47 48  
48 49 class upgradeDatabase extends Step
49 50 {
... ... @@ -141,13 +142,16 @@ class upgradeDatabase extends Step
141 142 }
142 143  
143 144 private function doRun($action = null) {
144   - $this->readConfig(KTConfig::getConfigFilename());
145   -
  145 +// $this->readConfig(KTConfig::getConfigFilename());
  146 + require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
  147 + $wizConfigHandler = new configuration();
  148 + $configPath = $wizConfigHandler->readConfigPathIni();
  149 + $this->readConfig($configPath);
146 150 if($this->dbSettings['dbPort'] == '') {
147   - $con = $this->dbhandler->load($this->dbSettings['dbHost'], $this->dbSettings['dbUser'],
  151 + $con = $this->util->dbUtilities->load($this->dbSettings['dbHost'], $this->dbSettings['dbUser'],
148 152 $this->dbSettings['dbPass'], $this->dbSettings['dbName']);
149 153 } else {
150   - $con = $this->dbhandler->load($this->dbSettings['dbHost'].":".$this->dbSettings['dbPort'], $this->dbSettings['dbUser'],
  154 + $con = $this->util->dbUtilities->load($this->dbSettings['dbHost'].":".$this->dbSettings['dbPort'], $this->dbSettings['dbUser'],
151 155 $this->dbSettings['dbPass'], $this->dbSettings['dbName']);
152 156 }
153 157  
... ... @@ -173,17 +177,20 @@ class upgradeDatabase extends Step
173 177 }
174 178  
175 179 private function generateUpgradeTable() {
176   - global $default;
177   -
178   - $this->temp_variables['systemVersion'] = $default->systemVersion;
179   - $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table);
180   -
181   - $result = $this->dbhandler->query($query);
  180 +// global $default;
  181 + $v = $this->readVersion();
  182 +// $this->temp_variables['systemVersion'] = $default->systemVersion;
  183 + $this->temp_variables['systemVersion'] = $v;
  184 +
  185 +// $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table);
  186 + $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', 'config_settings');
  187 +
  188 + $result = $this->util->dbUtilities->query($query);
182 189 if ($result) {
183   - $lastVersionObj = $this->dbhandler->fetchNextObject($result);
  190 + $lastVersionObj = $this->util->dbUtilities->fetchNextObject($result);
184 191 $lastVersion = $lastVersionObj->value;
185 192 }
186   - $currentVersion = $default->systemVersion;
  193 + $currentVersion = $v;
187 194  
188 195 $upgrades = describeUpgrade($lastVersion, $currentVersion);
189 196  
... ... @@ -202,6 +209,17 @@ class upgradeDatabase extends Step
202 209 return $ret;
203 210 }
204 211  
  212 + public function readVersion() {
  213 + $verFile = SYSTEM_DIR."docs".DS."VERSION.txt";
  214 + if(file_exists($verFile)) {
  215 + $foundVersion = file_get_contents($verFile);
  216 + return $foundVersion;
  217 + } else {
  218 + $this->error[] = "KT installation version not found";
  219 + }
  220 +
  221 + return false;
  222 + }
205 223 /**
206 224 * Stores varibles used by template
207 225 *
... ... @@ -243,9 +261,8 @@ class upgradeDatabase extends Step
243 261  
244 262 private function readConfig($path) {
245 263 //$ini = $this->util->loadInstallIni($path);
246   - $ini = $this->util->iniUtilities;
247   - $ini->load($path);
248   - $dbSettings = $ini->getSection('db');
  264 + $this->util->iniUtilities->load($path);
  265 + $dbSettings = $this->util->iniUtilities->getSection('db');
249 266 $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'],
250 267 'dbName'=> $dbSettings['dbName'],
251 268 'dbUser'=> $dbSettings['dbUser'],
... ... @@ -269,7 +286,7 @@ class upgradeDatabase extends Step
269 286  
270 287 private function doDatabaseUpgrade()
271 288 {
272   - global $default;
  289 +// global $default;
273 290  
274 291 $errors = false;
275 292  
... ... @@ -318,7 +335,7 @@ class upgradeDatabase extends Step
318 335 // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works.
319 336 // It should idealy work the same as the upgrades.
320 337  
321   - global $default;
  338 +// global $default;
322 339  
323 340 // Lock the scheduler
324 341 $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock';
... ... @@ -332,7 +349,7 @@ class upgradeDatabase extends Step
332 349 // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works.
333 350 // It should idealy work the same as the upgrades.
334 351  
335   - global $default;
  352 +// global $default;
336 353  
337 354 // Ensure all plugins are re-registered.
338 355 $sql = "TRUNCATE plugin_helper";
... ... @@ -360,7 +377,7 @@ class upgradeDatabase extends Step
360 377 }
361 378  
362 379 private function performAllUpgrades () {
363   - global $default;
  380 +// global $default;
364 381  
365 382 $row = 1;
366 383  
... ...
setup/upgrade/steps/upgradeWelcome.php
... ... @@ -84,21 +84,28 @@ class upgradeWelcome extends step {
84 84 private function checkPassword($username, $password) {
85 85 $dconf = $this->getDataFromPackage('installers', 'database'); // Use info from install
86 86 if($dconf) {
87   - $this->dbhandler->load($dconf['dhost'], $dconf['duname'], $dconf['dpassword'], $dconf['dname']);
  87 + $this->util->dbUtilities->load($dconf['dhost'], $dconf['duname'], $dconf['dpassword'], $dconf['dname']);
88 88 } else {
89   - require_once("../wizard/iniUtilities.php"); // ini to read the ini content
90 89 require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
91 90 $wizConfigHandler = new configuration();
92 91 $configPath = $wizConfigHandler->readConfigPathIni();
93   - $ini = new iniUtilities($configPath);
94   - $dconf = $ini->getSection('db');
95   - $this->dbhandler->load($dconf['dbHost'], $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']);
  92 + $this->util->iniUtilities->load($configPath);
  93 + $dconf = $this->util->iniUtilities->getSection('db');
  94 + if($dconf['dbPort'] == 'default')
  95 + $dconf['dbPort'] = 3306;
  96 + $this->util->dbUtilities->load($dconf['dbHost'].":".$dconf['dbPort'], $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']);
  97 + $sQuery = "SELECT count(*) AS match_count FROM users WHERE username = '$username' AND password = '".md5($password)."'";
  98 + $res = $this->util->dbUtilities->query($sQuery);
  99 + $ass = $this->util->dbUtilities->fetchAssoc($res);
  100 + if($ass[0]['match_count'] == 1)
  101 + return true;
96 102 }
  103 +
97 104 $this->error[] = 'Could Not Authenticate User';
98 105 return false;
99 106  
100 107 }
101   -
  108 +
102 109 public function getErrors() {
103 110 return $this->error;
104 111 }
... ...
setup/upgrade/templates/complete.tpl
1   -<?php global $default; ?>
  1 +<?php //global $default; ?>
2 2 <form>
3 3 <p class="title">Database Upgrade Completed</p>
4 4  
... ... @@ -6,7 +6,7 @@
6 6 <!-- Services -->
7 7 <br/><br/>
8 8 <div>
9   - Your database has been upgraded to <?php echo $default->systemVersion; ?>
  9 + Your database has been upgraded to <?php //echo $default->systemVersion; ?>
10 10 </div>
11 11 </div>
12 12 <a href="../../" class="back button_next" style="width:90px;" onclick="javascript:{w.clearSessions();}">Goto Login</a>
... ...
setup/upgrade/templates/error.tpl
1 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2 2 <html>
3 3 <head>
  4 + <link rel="shortcut icon" href="../wizard/resources/graphics/favicon.ico" type="image/x-icon">
4 5 <title>KnowledgeTree Installer</title>
5 6 <script type="text/javascript" src="resources/jquery.js"></script>
6 7 <script type="text/javascript" src="resources/wizard.js" ></script>
... ... @@ -14,7 +15,7 @@
14 15 <div id="logo"><img src="resources/graphics/dame/installer-header_logo.png"/></div>
15 16 <div id="install_details">
16 17 <span style="font-size:120%;"> 3.7 </span>
17   - <span style="font-size:80%;">Commercial Edition</span>
  18 + <span style="font-size:80%;">Community Edition</span>
18 19 </div>
19 20 </div>
20 21 <div id="wrapper">
... ...
setup/upgrade/templates/progress.tpl
1 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2 2 <html>
3 3 <head>
  4 + <link rel="shortcut icon" href="../wizard/resources/graphics/favicon.ico" type="image/x-icon">
4 5 <title>KnowledgeTree Upgrade Wizard</title>
5 6 <script type="text/javascript" src="resources/jquery.js"></script>
6 7 <script type="text/javascript" src="resources/wizard.js" ></script>
... ... @@ -14,7 +15,7 @@
14 15 <div id="logo"><img src="resources/graphics/dame/upgrader-header_logo.png"/></div>
15 16 <div id="install_details">
16 17 <span style="font-size:120%;"> 3.7 </span>
17   - <span style="font-size:80%;">Commercial Edition</span>
  18 + <span style="font-size:80%;">Community Edition</span>
18 19 </div>
19 20 </div>
20 21 <div id="wrapper">
... ...
setup/upgrade/templates/wizard.tpl
1 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2 2 <html>
3 3 <head>
  4 + <link rel="shortcut icon" href="../wizard/resources/graphics/favicon.ico" type="image/x-icon">
4 5 <title>KnowledgeTree Upgrader</title>
5 6 <?php echo $html->js('jquery.js'); ?>
6 7 <?php echo $html->js('jquery.form.js'); ?>
... ...
setup/wizard/dbUtilities.php
... ... @@ -119,10 +119,10 @@ class dbUtilities {
119 119 $new = array($dhost, $duname, $dpassword, $dbname);
120 120 $diff = array_diff($new, $current);
121 121 if(count($diff) == 0) {
122   - echo 'same';
123   - return true;
  122 + if($this->getDatabaseLink()) // Make sure theres a link
  123 + return true; // Already connected
124 124 }
125   - return false;
  125 + return false; // Reconnect
126 126 }
127 127  
128 128 public function getDatabaseLink() {
... ...
setup/wizard/installUtil.php
... ... @@ -39,9 +39,8 @@
39 39 * @package Installer
40 40 * @version Version 0.1
41 41 */
42   -require_once("path.php"); // Include if util is loaded directly
43   -require_once(WIZARD_DIR."iniUtilities.php");
44   -require_once(WIZARD_DIR."dbUtilities.php");
  42 +require_once("iniUtilities.php");
  43 +require_once("dbUtilities.php");
45 44  
46 45 class InstallUtil {
47 46 private $salt = 'installers';
... ...
setup/wizard/installWizard.php
... ... @@ -282,7 +282,7 @@ class InstallWizard {
282 282 }
283 283 if(!$this->isSystemInstalled()) { // Check if the systems not installed
284 284 if($this->util->migrationSpecified()) { // Check if the migrator needs to be accessed
285   - $this->util->redirect('../migrate');
  285 + $this->util->redirect('../migrate/index.php');
286 286 } elseif ($this->util->upgradeSpecified()) {
287 287 $this->util->redirect('../upgrade/index.php?action=installer');
288 288 }
... ...
setup/wizard/lib/helpers/htmlHelper.php
... ... @@ -114,6 +114,10 @@ class htmlHelper {
114 114 return $image;
115 115 }
116 116  
  117 + function url() {
  118 +
  119 + }
  120 +
117 121 function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) {
118 122 if (is_array($options)) {
119 123 $options = array_merge(array('escape' => true), $options);
... ...
setup/wizard/lib/services/unixLucene.php
... ... @@ -201,7 +201,7 @@ class unixLucene extends unixService {
201 201 public function start() {
202 202 $state = $this->status();
203 203 if($state != 'STARTED') {
204   - $logFile = $this->outputDir."lucene.log";
  204 + $logFile = $this->outputDir."log".DS."lucene.log";
205 205 @unlink($logFile);
206 206 $cmd = "cd ".$this->getLuceneDir()."; ";
207 207 $cmd .= "nohup java {$this->getJavaXmx()} {$this->getJavaXmx()} -jar ".$this->getLuceneSource()." > ".$logFile." 2>&1 & echo $!";
... ...
setup/wizard/lib/services/unixScheduler.php
... ... @@ -180,7 +180,7 @@ class unixScheduler extends unixService {
180 180 // TODO : Write sh on the fly? Not sure the reasoning here
181 181 $source = $this->getSchedulerSourceLoc();
182 182 $this->writeSchedulerTask();
183   - $logFile = $this->outputDir."scheduler.log";
  183 + $logFile = $this->outputDir."log".DS."scheduler.log";
184 184 @unlink($logFile);
185 185 if($source) { // Source
186 186 $cmd = "nohup ".$source." > ".$logFile." 2>&1 & echo $!";
... ...
setup/wizard/resources/graphics/favicon.ico 0 → 100644
No preview for this file type
setup/wizard/step.php
... ... @@ -117,15 +117,6 @@ class Step
117 117 */
118 118 public $util;
119 119  
120   - /**
121   - * Reference to utility object
122   - *
123   - * @author KnowledgeTree Team
124   - * @access protected
125   - * @var object
126   - */
127   -// public $dbhandler;
128   -
129 120 public function __construct() {
130 121 $this->util = new InstallUtil();
131 122 }
... ...
setup/wizard/templates/complete.tpl
... ... @@ -142,7 +142,7 @@
142 142 if ($install_environment == 'Zend') {
143 143 ?>
144 144 <!-- <input type="submit" name="type" value="Zend Server Configuration" class="button_previous"/>-->
145   - <a href="<?php echo "http://".$_SERVER['HTTP_HOST'].":10081/ZendServer/Index"; ?>" class="back" target="_blank" onclick="javascript:{w.clearSessions();}">Zend Server Configuration</a>
  145 +<!-- <a href="<?php //echo "http://".$_SERVER['HTTP_HOST'].":10081/ZendServer/Index"; ?>" class="back" target="_blank" onclick="javascript:{w.clearSessions();}">Zend Server Configuration</a>-->
146 146 <?php
147 147 }
148 148 ?>
... ...
setup/wizard/templates/error.tpl
1 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2 2 <html>
3 3 <head>
  4 + <link rel="shortcut icon" href="../wizard/resources/graphics/favicon.ico" type="image/x-icon">
4 5 <title>KnowledgeTree Installer</title>
5 6 <script type="text/javascript" src="resources/js/jquery-tooltip/lib/jquery.js"></script>
6 7 <script type="text/javascript" src="resources/js/wizard.js" ></script>
... ... @@ -15,7 +16,7 @@
15 16 <div id="logo"><img src="resources/graphics/dame/installer-header_logo.png"/></div>
16 17 <div id="install_details">
17 18 <span style="font-size:120%;"> 3.7 </span>
18   - <span style="font-size:80%;">Commercial Edition</span>
  19 + <span style="font-size:80%;">Community Edition</span>
19 20 </div>
20 21 </div>
21 22 <div id="wrapper">
... ...
setup/wizard/templates/wizard.tpl
1 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2 2 <html>
3 3 <head>
  4 + <link rel="shortcut icon" href="../wizard/resources/graphics/favicon.ico" type="image/x-icon">
4 5 <title>KnowledgeTree Installer</title>
5 6 <?php echo $html->js('jquery.js'); ?>
6 7 <?php echo $html->js('jquery.form.js'); ?>
... ...