Commit 68cc1b4b81fc82a30eba902358b4dccb2ecbf2f2
1 parent
7b4a8353
Story ID:1166880:Updated Upgrade Refactor
Committed by: Jarrett Jordaan Reviewed by: Megan Watson
Showing
12 changed files
with
288 additions
and
40 deletions
setup/upgrade/config/databases.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | + | ||
| 3 | +<!-- | ||
| 4 | + Document : database.xml | ||
| 5 | + Created on : 01 July 2009, 1:13 PM | ||
| 6 | + Author : KnowledgeTree Team | ||
| 7 | + Description: Installer Default MySql Database Configuration | ||
| 8 | +--> | ||
| 9 | + | ||
| 10 | +<database> | ||
| 11 | + <dtypes> | ||
| 12 | + <dtype>mysql</dtype> | ||
| 13 | + </dtypes> | ||
| 14 | + <dhost>localhost</dhost> | ||
| 15 | + <dport>3306</dport> | ||
| 16 | + <dname>dms</dname> | ||
| 17 | + <duname>root</duname> | ||
| 18 | + <dmsadminuser>dmsadmin</dmsadminuser> | ||
| 19 | + <dmsaupass>js9281djw</dmsaupass> | ||
| 20 | + <dmsuser>dms</dmsuser> | ||
| 21 | + <dmsupass>djw9281js</dmsupass> | ||
| 22 | +</database> |
setup/upgrade/session.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | +* Session Controller. | ||
| 4 | +* | ||
| 5 | +* KnowledgeTree Community Edition | ||
| 6 | +* Document Management Made Simple | ||
| 7 | +* Copyright(C) 2008,2009 KnowledgeTree Inc. | ||
| 8 | +* Portions copyright The Jam Warehouse Software(Pty) Limited | ||
| 9 | +* | ||
| 10 | +* This program is free software; you can redistribute it and/or modify it under | ||
| 11 | +* the terms of the GNU General Public License version 3 as published by the | ||
| 12 | +* Free Software Foundation. | ||
| 13 | +* | ||
| 14 | +* This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 15 | +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
| 16 | +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | ||
| 17 | +* details. | ||
| 18 | +* | ||
| 19 | +* You should have received a copy of the GNU General Public License | ||
| 20 | +* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 21 | +* | ||
| 22 | +* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | ||
| 23 | +* California 94120-7775, or email info@knowledgetree.com. | ||
| 24 | +* | ||
| 25 | +* The interactive user interfaces in modified source and object code versions | ||
| 26 | +* of this program must display Appropriate Legal Notices, as required under | ||
| 27 | +* Section 5 of the GNU General Public License version 3. | ||
| 28 | +* | ||
| 29 | +* In accordance with Section 7(b) of the GNU General Public License version 3, | ||
| 30 | +* these Appropriate Legal Notices must retain the display of the "Powered by | ||
| 31 | +* KnowledgeTree" logo and retain the original copyright notice. If the display of the | ||
| 32 | +* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | ||
| 33 | +* must display the words "Powered by KnowledgeTree" and retain the original | ||
| 34 | +* copyright notice. | ||
| 35 | +* | ||
| 36 | +* @copyright 2008-2009, KnowledgeTree Inc. | ||
| 37 | +* @license GNU General Public License version 3 | ||
| 38 | +* @author KnowledgeTree Team | ||
| 39 | +* @package Upgrader | ||
| 40 | +* @version Version 0.1 | ||
| 41 | +*/ | ||
| 42 | +class session | ||
| 43 | +{ | ||
| 44 | + private $salt = 'upgrade'; | ||
| 45 | + /** | ||
| 46 | + * Constructs session object | ||
| 47 | + * | ||
| 48 | + * @author KnowledgeTree Team | ||
| 49 | + * @access public | ||
| 50 | + * @param none | ||
| 51 | + */ | ||
| 52 | + public function __construct() { | ||
| 53 | + $this->startSession(); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * Starts a session if one does not exist | ||
| 58 | + * | ||
| 59 | + * @author KnowledgeTree Team | ||
| 60 | + * @param none | ||
| 61 | + * @access public | ||
| 62 | + * @return void | ||
| 63 | + */ | ||
| 64 | + public function startSession() { | ||
| 65 | + if(!isset($_SESSION[$this->salt]['ready'])) { | ||
| 66 | +// session_start(); | ||
| 67 | + $_SESSION[$this->salt] ['ready'] = TRUE; | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * Sets a value key pair in session | ||
| 73 | + * | ||
| 74 | + * @author KnowledgeTree Team | ||
| 75 | + * @param string $fld | ||
| 76 | + * @param string $val | ||
| 77 | + * @access public | ||
| 78 | + * @return void | ||
| 79 | + */ | ||
| 80 | + public function set($fld, $val) { | ||
| 81 | + $this->startSession(); | ||
| 82 | + $_SESSION[$this->salt] [$fld] = $val; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + /** | ||
| 86 | + * Sets a value key pair in a class in session | ||
| 87 | + * | ||
| 88 | + * @author KnowledgeTree Team | ||
| 89 | + * @param string $class | ||
| 90 | + * @param string $fld | ||
| 91 | + * @param string $val | ||
| 92 | + * @access public | ||
| 93 | + * @return void | ||
| 94 | + */ | ||
| 95 | + public function setClass($class , $k, $v) { | ||
| 96 | + $this->startSession(); | ||
| 97 | + $classArray = $this->get($class); | ||
| 98 | + if(isset($classArray[$k])) { | ||
| 99 | + $classArray[$k] = $v; | ||
| 100 | + } else { | ||
| 101 | + $classArray[$k] = $v; | ||
| 102 | + } | ||
| 103 | + $_SESSION[$this->salt] [ $class] = $classArray; | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + /** | ||
| 107 | + * Sets a error value key pair in a class in session | ||
| 108 | + * | ||
| 109 | + * @author KnowledgeTree Team | ||
| 110 | + * @param string $class | ||
| 111 | + * @param string $fld | ||
| 112 | + * @param string $val | ||
| 113 | + * @access public | ||
| 114 | + * @return void | ||
| 115 | + */ | ||
| 116 | + public function setClassError($class, $k, $v) { | ||
| 117 | + $this->startSession(); | ||
| 118 | + $classArray = $this->get($class); | ||
| 119 | + if(isset($classArray[$k])) { | ||
| 120 | + $classArray[$k] = $v; | ||
| 121 | + } else { | ||
| 122 | + $classArray[$k] = $v; | ||
| 123 | + } | ||
| 124 | + $_SESSION[$this->salt] [ $class] = $classArray; | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + /** | ||
| 128 | + * Clear error values in a class session | ||
| 129 | + * | ||
| 130 | + * @author KnowledgeTree Team | ||
| 131 | + * @param string $class | ||
| 132 | + * @param string $fld | ||
| 133 | + * @param string $val | ||
| 134 | + * @access public | ||
| 135 | + * @return void | ||
| 136 | + */ | ||
| 137 | + public function clearErrors($class) { | ||
| 138 | + $classArray = $this->get($class); | ||
| 139 | + unset($classArray['errors']); | ||
| 140 | + $_SESSION[$this->salt] [ $class] = $classArray; | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + /** | ||
| 144 | + * Unset a value in session | ||
| 145 | + * | ||
| 146 | + * @author KnowledgeTree Team | ||
| 147 | + * @param string $fld | ||
| 148 | + * @access public | ||
| 149 | + * @return void | ||
| 150 | + */ | ||
| 151 | + public function un_set($fld) { | ||
| 152 | + $this->startSession(); | ||
| 153 | + unset($_SESSION[$this->salt] [$fld]); | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + /** | ||
| 157 | + * Unset a class value in session | ||
| 158 | + * | ||
| 159 | + * @author KnowledgeTree Team | ||
| 160 | + * @param string $class | ||
| 161 | + * @access public | ||
| 162 | + * @return void | ||
| 163 | + */ | ||
| 164 | + public function un_setClass($class) { | ||
| 165 | + $this->startSession(); | ||
| 166 | + if(isset($_SESSION[$this->salt] [$class])) | ||
| 167 | + unset($_SESSION[$this->salt] [$class]); | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + /** | ||
| 171 | + * Destroy the session | ||
| 172 | + * | ||
| 173 | + * @author KnowledgeTree Team | ||
| 174 | + * @param none | ||
| 175 | + * @access public | ||
| 176 | + * @return void | ||
| 177 | + */ | ||
| 178 | + public function destroy() { | ||
| 179 | + $this->startSession(); | ||
| 180 | + unset($_SESSION[$this->salt]); | ||
| 181 | + session_destroy(); | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + /** | ||
| 185 | + * Get a session value | ||
| 186 | + * | ||
| 187 | + * @author KnowledgeTree Team | ||
| 188 | + * @param string $fld | ||
| 189 | + * @access public | ||
| 190 | + * @return string | ||
| 191 | + */ | ||
| 192 | + public function get($fld) { | ||
| 193 | + $this->startSession(); | ||
| 194 | + if(isset($_SESSION[$this->salt] [$fld])) | ||
| 195 | + return $_SESSION[$this->salt] [$fld]; | ||
| 196 | + return false; | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + /** | ||
| 200 | + * Check if a field exists in session | ||
| 201 | + * | ||
| 202 | + * @author KnowledgeTree Team | ||
| 203 | + * @param string $fld | ||
| 204 | + * @access public | ||
| 205 | + * @return string | ||
| 206 | + */ | ||
| 207 | + public function is_set($fld) { | ||
| 208 | + $this->startSession(); | ||
| 209 | + return isset($_SESSION[$this->salt] [$fld]); | ||
| 210 | + } | ||
| 211 | + | ||
| 212 | + /** | ||
| 213 | + * Return a class from session | ||
| 214 | + * | ||
| 215 | + * @author KnowledgeTree Team | ||
| 216 | + * @param string $fld | ||
| 217 | + * @access public | ||
| 218 | + * @return string | ||
| 219 | + */ | ||
| 220 | + public function getClass($class) { | ||
| 221 | + return $_SESSION[$this->salt][$class]; | ||
| 222 | + } | ||
| 223 | +} | ||
| 224 | +?> | ||
| 0 | \ No newline at end of file | 225 | \ No newline at end of file |
setup/upgrade/steps/upgradeBackup.php
| @@ -40,7 +40,7 @@ | @@ -40,7 +40,7 @@ | ||
| 40 | * @version Version 0.1 | 40 | * @version Version 0.1 |
| 41 | */ | 41 | */ |
| 42 | 42 | ||
| 43 | -require_once('../../config/dmsDefaults.php'); | 43 | +//require_once('../../config/dmsDefaults.php'); |
| 44 | 44 | ||
| 45 | class upgradeBackup extends Step { | 45 | class upgradeBackup extends Step { |
| 46 | protected $silent = false; | 46 | protected $silent = false; |
setup/upgrade/steps/upgradeComplete.php
setup/upgrade/steps/upgradeDatabase.php
| @@ -40,10 +40,10 @@ | @@ -40,10 +40,10 @@ | ||
| 40 | * @version Version 0.1 | 40 | * @version Version 0.1 |
| 41 | */ | 41 | */ |
| 42 | 42 | ||
| 43 | -require_once('../../config/dmsDefaults.php'); | ||
| 44 | -require_once(KT_LIB_DIR . '/config/config.inc.php'); | ||
| 45 | -require_once(KT_LIB_DIR . '/plugins/pluginutil.inc.php'); | ||
| 46 | -require_once(KT_LIB_DIR . '/upgrades/upgrade.inc.php'); | 43 | +//require_once('../../config/dmsDefaults.php'); |
| 44 | +//require_once(KT_LIB_DIR . '/config/config.inc.php'); | ||
| 45 | +//require_once(KT_LIB_DIR . '/plugins/pluginutil.inc.php'); | ||
| 46 | +//require_once(KT_LIB_DIR . '/upgrades/upgrade.inc.php'); | ||
| 47 | 47 | ||
| 48 | class upgradeDatabase extends Step | 48 | class upgradeDatabase extends Step |
| 49 | { | 49 | { |
setup/upgrade/steps/upgradeRestore.php
setup/upgrade/steps/upgradeWelcome.php
| @@ -40,14 +40,12 @@ | @@ -40,14 +40,12 @@ | ||
| 40 | * @version Version 0.1 | 40 | * @version Version 0.1 |
| 41 | */ | 41 | */ |
| 42 | 42 | ||
| 43 | -require_once('../../config/dmsDefaults.php'); | ||
| 44 | -require_once KT_LIB_DIR . '/authentication/authenticationutil.inc.php'; | ||
| 45 | - | ||
| 46 | class upgradeWelcome extends step { | 43 | class upgradeWelcome extends step { |
| 47 | 44 | ||
| 48 | protected $silent = false; | 45 | protected $silent = false; |
| 49 | protected $temp_variables = array(); | 46 | protected $temp_variables = array(); |
| 50 | - | 47 | + protected $error = array() ; |
| 48 | + | ||
| 51 | public function doStep() { | 49 | public function doStep() { |
| 52 | $this->temp_variables = array("step_name"=>"welcome"); | 50 | $this->temp_variables = array("step_name"=>"welcome"); |
| 53 | if($this->next()) { | 51 | if($this->next()) { |
| @@ -81,9 +79,18 @@ class upgradeWelcome extends step { | @@ -81,9 +79,18 @@ class upgradeWelcome extends step { | ||
| 81 | } | 79 | } |
| 82 | 80 | ||
| 83 | private function checkPassword($username, $password) { | 81 | private function checkPassword($username, $password) { |
| 84 | -/* | ||
| 85 | - $dconf = $this->getDataFromPackage('installers', 'database'); | ||
| 86 | - $this->dbhandler->load($dconf['dhost'], $dconf['duname'], $dconf['dpassword'], $dconf['dname']); | 82 | + $dconf = $this->getDataFromPackage('installers', 'database'); // Use info from install |
| 83 | + if($dconf) { | ||
| 84 | + $this->dbhandler->load($dconf['dhost'], $dconf['duname'], $dconf['dpassword'], $dconf['dname']); | ||
| 85 | + } else { | ||
| 86 | + require_once("../wizard/iniUtilities.php"); // ini to read the ini content | ||
| 87 | + require_once("../wizard/steps/configuration.php"); // configuration to read the ini path | ||
| 88 | + $wizConfigHandler = new configuration(); | ||
| 89 | + $configPath = $wizConfigHandler->readConfigPathIni(); | ||
| 90 | + $ini = new iniUtilities($configPath); | ||
| 91 | + $dconf = $ini->getSection('db'); | ||
| 92 | + $this->dbhandler->load($dconf['dbHost'], $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']); | ||
| 93 | + } | ||
| 87 | $sQuery = "SELECT count(*) AS match_count FROM users WHERE username = '$username' AND password = '".md5($password)."'"; | 94 | $sQuery = "SELECT count(*) AS match_count FROM users WHERE username = '$username' AND password = '".md5($password)."'"; |
| 88 | $res = $this->dbhandler->query($sQuery); | 95 | $res = $this->dbhandler->query($sQuery); |
| 89 | $ass = $this->dbhandler->fetchAssoc($res); | 96 | $ass = $this->dbhandler->fetchAssoc($res); |
| @@ -91,28 +98,15 @@ class upgradeWelcome extends step { | @@ -91,28 +98,15 @@ class upgradeWelcome extends step { | ||
| 91 | if($ass[0]['match_count']) | 98 | if($ass[0]['match_count']) |
| 92 | return true; | 99 | return true; |
| 93 | } | 100 | } |
| 101 | + $this->error[] = 'Could Not Authenticate User'; | ||
| 94 | return false; | 102 | return false; |
| 95 | - */ | ||
| 96 | - | ||
| 97 | - global $default; | ||
| 98 | - | ||
| 99 | - $sTable = KTUtil::getTableName('users'); | ||
| 100 | - $sQuery = "SELECT count(*) AS match_count FROM $sTable WHERE username = ? AND password = ?"; | ||
| 101 | - $aParams = array($username, md5($password)); | ||
| 102 | - $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'match_count'); | ||
| 103 | - if (PEAR::isError($res)) { return false; } | ||
| 104 | - else { | ||
| 105 | - $sTable = KTUtil::getTableName('users_groups_link'); | ||
| 106 | - $sQuery = "SELECT count(*) AS match_count FROM $sTable WHERE user_id = ? AND group_id = 1"; | ||
| 107 | - $aParams = array($res); | ||
| 108 | - $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'match_count'); | ||
| 109 | - if (PEAR::isError($res)) { return false; } | ||
| 110 | - else { | ||
| 111 | - return ($res == 1); | ||
| 112 | - } | ||
| 113 | - } | ||
| 114 | } | 103 | } |
| 115 | 104 | ||
| 105 | + public function getErrors() { | ||
| 106 | + return $this->error; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + | ||
| 116 | } | 110 | } |
| 117 | 111 | ||
| 118 | ?> | 112 | ?> |
| 119 | \ No newline at end of file | 113 | \ No newline at end of file |
setup/upgrade/templates/welcome.tpl
| @@ -9,9 +9,14 @@ | @@ -9,9 +9,14 @@ | ||
| 9 | <p class="empty_space"> Only administrator users may access the upgrade wizard. </p> | 9 | <p class="empty_space"> Only administrator users may access the upgrade wizard. </p> |
| 10 | <div class="demo"> | 10 | <div class="demo"> |
| 11 | <table> | 11 | <table> |
| 12 | - <tr><td>Username<td><input name=username> | ||
| 13 | - <tr><td>Password<td><input name=password type="password"> | 12 | + <tr><td>Username</td><td><input name=username></td></tr> |
| 13 | + <tr><td>Password</td><td><input name=password type="password"></td></tr> | ||
| 14 | + <?php if (!empty($errors)) { ?><tr><td></td><td><span class="error">Could Not Authenticate User</span></td></tr> <?php } ?> | ||
| 15 | + <?php | ||
| 16 | +// print_r($errors); | ||
| 17 | + ?> | ||
| 14 | </table> | 18 | </table> |
| 19 | + | ||
| 15 | </div> | 20 | </div> |
| 16 | </div> | 21 | </div> |
| 17 | <?php | 22 | <?php |
setup/upgrade/upgradeUtil.php
| @@ -40,7 +40,7 @@ | @@ -40,7 +40,7 @@ | ||
| 40 | * @version Version 0.1 | 40 | * @version Version 0.1 |
| 41 | */ | 41 | */ |
| 42 | 42 | ||
| 43 | -require_once('../../config/dmsDefaults.php'); | 43 | +//require_once('../../config/dmsDefaults.php'); |
| 44 | require_once("../wizard/installUtil.php"); | 44 | require_once("../wizard/installUtil.php"); |
| 45 | 45 | ||
| 46 | class UpgradeUtil extends InstallUtil { | 46 | class UpgradeUtil extends InstallUtil { |
setup/upgrade/upgradeWizard.php
| @@ -117,7 +117,7 @@ class UpgradeWizard { | @@ -117,7 +117,7 @@ class UpgradeWizard { | ||
| 117 | $ins = new Upgrader(); // Instantiate the upgrader | 117 | $ins = new Upgrader(); // Instantiate the upgrader |
| 118 | $ins->resolveErrors($response); // Run step | 118 | $ins->resolveErrors($response); // Run step |
| 119 | } else { | 119 | } else { |
| 120 | - $ins = new Upgrader(new UpgradeSession()); // Instantiate the upgrader and pass the session class | 120 | + $ins = new Upgrader(new session()); // Instantiate the upgrader and pass the session class |
| 121 | $ins->step(); // Run step | 121 | $ins->step(); // Run step |
| 122 | } | 122 | } |
| 123 | } | 123 | } |
setup/wizard/steps/configuration.php
| @@ -576,7 +576,7 @@ class configuration extends Step | @@ -576,7 +576,7 @@ class configuration extends Step | ||
| 576 | return true; | 576 | return true; |
| 577 | } | 577 | } |
| 578 | 578 | ||
| 579 | - private function readConfigPathIni() { | 579 | + public function readConfigPathIni() { |
| 580 | if(isset($this->temp_variables['paths']['configFile']['path'])) { | 580 | if(isset($this->temp_variables['paths']['configFile']['path'])) { |
| 581 | return $this->temp_variables['paths']['configFile']['path']; | 581 | return $this->temp_variables['paths']['configFile']['path']; |
| 582 | } | 582 | } |
setup/wizard/steps/database.php
| @@ -441,6 +441,8 @@ class database extends Step | @@ -441,6 +441,8 @@ class database extends Step | ||
| 441 | $this->temp_variables['tprefix'] = ''; | 441 | $this->temp_variables['tprefix'] = ''; |
| 442 | $this->temp_variables['ddrop'] = false; | 442 | $this->temp_variables['ddrop'] = false; |
| 443 | } | 443 | } |
| 444 | + | ||
| 445 | + return $this->temp_variables; | ||
| 444 | } | 446 | } |
| 445 | 447 | ||
| 446 | /** | 448 | /** |
| @@ -493,11 +495,12 @@ class database extends Step | @@ -493,11 +495,12 @@ class database extends Step | ||
| 493 | * Read xml config file | 495 | * Read xml config file |
| 494 | * | 496 | * |
| 495 | * @author KnowledgeTree Team | 497 | * @author KnowledgeTree Team |
| 496 | - * @access private | 498 | + * @access public |
| 497 | * @params none | 499 | * @params none |
| 498 | * @return object SimpleXmlObject | 500 | * @return object SimpleXmlObject |
| 499 | */ | 501 | */ |
| 500 | - private function readXml() { | 502 | + public function readXml() { |
| 503 | +// echo CONF_DIR."databases.xml"; | ||
| 501 | $simplexml = simplexml_load_file(CONF_DIR."databases.xml"); | 504 | $simplexml = simplexml_load_file(CONF_DIR."databases.xml"); |
| 502 | 505 | ||
| 503 | return $simplexml; | 506 | return $simplexml; |