Commit 0c8d80d8c8309498decdedc97fe222abbfff4a31

Authored by Jarrett Jordaan
1 parent 2dfa9261

Story Id:1166880 Server Testing Updates

Committed by: Jarrett Jordaan

Reviewed by: Paul Barrett
setup/migrate/lib/services/unixService.php
... ... @@ -41,6 +41,8 @@
41 41 */
42 42  
43 43 class unixService extends Service {
  44 + public $name;
  45 +
44 46 /**
45 47 * Retrieve Service name
46 48 *
... ...
setup/migrate/migrateUtil.php
... ... @@ -79,6 +79,7 @@ class MigrateUtil {
79 79 ob_end_clean();
80 80 echo $contents;
81 81 }
  82 +
82 83 /**
83 84 * Check if system needs to be migrated
84 85 *
... ... @@ -89,13 +90,20 @@ class MigrateUtil {
89 90 */
90 91 public function checkStructurePermissions() {
91 92 // Check if Wizard Directory is writable
92   - if(!$this->_checkPermission(WIZARD_DIR)) {
  93 + if(!$this->_checkPermission(MIGRATE_DIR)) {
93 94 return 'wizard';
94 95 }
95 96  
96 97 return true;
97 98 }
98 99  
  100 +
  101 + function getInstallerServices() {
  102 + require_once("../wizard/installUtil.php");
  103 + require_once("../wizard/steps/services.php");
  104 +
  105 + return new services();
  106 + }
99 107 /**
100 108 * Redirect
101 109 *
... ...
setup/migrate/migrateWizard.php
... ... @@ -49,8 +49,8 @@ include("path.php"); // Paths
49 49 */
50 50 function __autoload($class) { // Attempt and autoload classes
51 51 $class = strtolower(substr($class,0,1)).substr($class,1); // Linux Systems.
52   - if(file_exists(WIZARD_DIR."$class.php")) {
53   - require_once(WIZARD_DIR."$class.php");
  52 + if(file_exists(MIGRATE_DIR."$class.php")) {
  53 + require_once(MIGRATE_DIR."$class.php");
54 54 } elseif (file_exists(STEP_DIR."$class.php")) {
55 55 require_once(STEP_DIR."$class.php");
56 56 } elseif (file_exists(WIZARD_LIB."$class.php")) {
... ...
setup/migrate/path.php
... ... @@ -67,21 +67,24 @@
67 67 $sys .= $v.DS;
68 68 }
69 69 // Define paths to wizard
70   - define('WIZARD_DIR', $wizard.DS);
71   - define('WIZARD_LIB', WIZARD_DIR."lib".DS);
  70 + define('MIGRATE_DIR', $wizard.DS);
  71 + define('WIZARD_LIB', MIGRATE_DIR."lib".DS);
72 72 define('SERVICE_LIB', WIZARD_LIB."services".DS);
73   - define('SQL_DIR', WIZARD_DIR."sql".DS);
  73 + define('SQL_DIR', MIGRATE_DIR."sql".DS);
74 74 define('SQL_UPGRADE_DIR', SQL_DIR."upgrades".DS);
75   - define('CONF_DIR', WIZARD_DIR."config".DS);
76   - define('RES_DIR', WIZARD_DIR."resources".DS);
77   - define('STEP_DIR', WIZARD_DIR."steps".DS);
78   - define('TEMP_DIR', WIZARD_DIR."templates".DS);
79   - define('SHELL_DIR', WIZARD_DIR."shells".DS);
80   - define('OUTPUT_DIR', WIZARD_DIR."output".DS);
  75 + define('CONF_DIR', MIGRATE_DIR."config".DS);
  76 + define('RES_DIR', MIGRATE_DIR."resources".DS);
  77 + define('STEP_DIR', MIGRATE_DIR."steps".DS);
  78 + define('TEMP_DIR', MIGRATE_DIR."templates".DS);
  79 + define('SHELL_DIR', MIGRATE_DIR."shells".DS);
  80 + define('OUTPUT_DIR', MIGRATE_DIR."output".DS);
81 81 // Define paths to system webroot
82 82 define('SYSTEM_DIR', $sys);
  83 + define('SYS_VAR_DIR', SYSTEM_DIR."var".DS);
83 84 define('SYS_BIN_DIR', SYSTEM_DIR."bin".DS);
84   - define('SYS_LOG_DIR', SYSTEM_DIR."var".DS."log".DS);
  85 + define('SYS_LOG_DIR', SYS_VAR_DIR."log".DS);
  86 + define('SYS_OUT_DIR', SYS_VAR_DIR);
  87 + define('VAR_BIN_DIR', SYS_VAR_DIR."bin".DS);
85 88 // Define paths to system
86 89 array_pop($xdir);
87 90 $asys = '';
... ...
setup/migrate/stepAction.php
... ... @@ -246,7 +246,8 @@ class stepAction {
246 246 * @return object Step
247 247 */
248 248 public function createStep() {
249   - $step_class = $this->makeCamelCase($this->stepName);
  249 + $step_class = "migrate".$this->makeCamelCase($this->stepName);
  250 +
250 251 return new $step_class();
251 252 }
252 253  
... ...
setup/migrate/steps/migrateComplete.php 0 โ†’ 100644
  1 +<?php
  2 +/**
  3 +* Complete Step 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 Migrater
  40 +* @version Version 0.1
  41 +*/
  42 +
  43 +class migrateComplete extends Step {
  44 +
  45 + /**
  46 + * Reference to Database object
  47 + *
  48 + * @author KnowledgeTree Team
  49 + * @access private
  50 + * @var object
  51 + */
  52 + private $_dbhandler = null;
  53 +
  54 + /**
  55 + * List of services to check
  56 + *
  57 + * @access private
  58 + * @var array
  59 + */
  60 + private $services_check = 'tick';
  61 + private $paths_check = 'tick';
  62 + private $privileges_check = 'tick';
  63 + private $database_check = 'tick';
  64 + protected $silent = true;
  65 +
  66 + protected $util = null;
  67 +
  68 + public function __construct() {
  69 + $this->temp_variables = array("step_name"=>"complete", "silent"=>$this->silent);
  70 + $this->_dbhandler = new dbUtil();
  71 + $this->util = new MigrateUtil();
  72 + }
  73 +
  74 + function doStep() {
  75 + $this->doRun();
  76 + return 'landing';
  77 + }
  78 +
  79 + function doRun() {
  80 + $this->checkServices();
  81 + $this->storeSilent();// Set silent mode variables
  82 + }
  83 +
  84 + private function checkServices()
  85 + {
  86 + $services = new services();
  87 + foreach ($services->getServices() as $serviceName) {
  88 + $this->temp_variables[$serviceName."Status"] = 'tick';
  89 + }
  90 + return true;
  91 + }
  92 +
  93 + /**
  94 + * Set all silent mode varibles
  95 + *
  96 + */
  97 + private function storeSilent() {
  98 + $this->temp_variables['services_check'] = $this->services_check;
  99 + }
  100 +}
  101 +?>
0 102 \ No newline at end of file
... ...
setup/migrate/steps/migrateDatabase.php 0 โ†’ 100644
  1 +<?php
  2 +/**
  3 +* Database Step 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 Migrater
  40 +* @version Version 0.1
  41 +*/
  42 +
  43 +class migrateDatabase extends Step
  44 +{
  45 + /**
  46 + * Reference to Database object
  47 + *
  48 + * @author KnowledgeTree Team
  49 + * @access public
  50 + * @var object
  51 + */
  52 + public $_dbhandler = null;
  53 +
  54 + /**
  55 + * Reference to Database object
  56 + *
  57 + * @author KnowledgeTree Team
  58 + * @access public
  59 + * @var object
  60 + */
  61 + public $_util = null;
  62 +
  63 + /**
  64 + * Database type
  65 + *
  66 + * @author KnowledgeTree Team
  67 + * @access private
  68 + * @var array
  69 + */
  70 + private $dtype = '';
  71 +
  72 + /**
  73 + * Database types
  74 + *
  75 + * @author KnowledgeTree Team
  76 + * @access private
  77 + * @var array
  78 + */
  79 + private $dtypes = array();
  80 +
  81 + /**
  82 + * Database host
  83 + *
  84 + * @author KnowledgeTree Team
  85 + * @access private
  86 + * @var string
  87 + */
  88 + private $dhost = '';
  89 +
  90 + /**
  91 + * Database port
  92 + *
  93 + * @author KnowledgeTree Team
  94 + * @access private
  95 + * @var string
  96 + */
  97 + private $dport = '';
  98 +
  99 + /**
  100 + * Database name
  101 + *
  102 + * @author KnowledgeTree Team
  103 + * @access private
  104 + * @var string
  105 + */
  106 + private $dname = '';
  107 +
  108 + /**
  109 + * Database root username
  110 + *
  111 + * @author KnowledgeTree Team
  112 + * @access private
  113 + * @var string
  114 + */
  115 + private $duname = '';
  116 +
  117 + /**
  118 + * Database root password
  119 + *
  120 + * @author KnowledgeTree Team
  121 + * @access private
  122 + * @var string
  123 + */
  124 + private $dpassword = '';
  125 +
  126 + /**
  127 + * Database dms username
  128 + *
  129 + * @author KnowledgeTree Team
  130 + * @access private
  131 + * @var string
  132 + */
  133 + private $dmsname = '';
  134 +
  135 + /**
  136 + * Database dms password
  137 + *
  138 + * @author KnowledgeTree Team
  139 + * @access private
  140 + * @var string
  141 + */
  142 + private $dmspassword = '';
  143 +
  144 + /**
  145 + * Default dms user username
  146 + *
  147 + * @author KnowledgeTree Team
  148 + * @access private
  149 + * @var boolean
  150 + */
  151 + private $dmsusername = '';
  152 +
  153 + /**
  154 + * Default dms user password
  155 + *
  156 + * @author KnowledgeTree Team
  157 + * @access private
  158 + * @var boolean
  159 + */
  160 + private $dmsuserpassword = '';
  161 +
  162 + /**
  163 + * Location of database binaries.
  164 + *
  165 + * @author KnowledgeTree Team
  166 + * @access private
  167 + * @var string
  168 + */
  169 + private $mysqlDir; // TODO:multiple databases
  170 +
  171 + /**
  172 + * Name of database binary.
  173 + *
  174 + * @author KnowledgeTree Team
  175 + * @access private
  176 + * @var string
  177 + */
  178 + private $dbbinary = ''; // TODO:multiple databases
  179 +
  180 + /**
  181 + * Database table prefix
  182 + *
  183 + * @author KnowledgeTree Team
  184 + * @access private
  185 + * @var string
  186 + */
  187 + private $tprefix = '';
  188 +
  189 + /**
  190 + * Flag to drop database
  191 + *
  192 + * @author KnowledgeTree Team
  193 + * @access private
  194 + * @var boolean
  195 + */
  196 + private $ddrop = false;
  197 +
  198 + /**
  199 + * List of errors encountered
  200 + *
  201 + * @author KnowledgeTree Team
  202 + * @access public
  203 + * @var array
  204 + */
  205 + public $error = array();
  206 +
  207 + /**
  208 + * List of errors used in template
  209 + *
  210 + * @author KnowledgeTree Team
  211 + * @access public
  212 + * @var array
  213 + */
  214 + public $templateErrors = array('dmspassword', 'dmsuserpassword', 'con', 'dname', 'dtype', 'duname', 'dpassword');
  215 +
  216 + /**
  217 + * Flag to store class information in session
  218 + *
  219 + * @author KnowledgeTree Team
  220 + * @access public
  221 + * @var array
  222 + */
  223 + public $storeInSession = true;
  224 +
  225 + /**
  226 + * Flag if step needs to be migrated
  227 + *
  228 + * @author KnowledgeTree Team
  229 + * @access public
  230 + * @var array
  231 + */
  232 + protected $runMigrate = true;
  233 +
  234 + /**
  235 + * Flag if step needs to run silently
  236 + *
  237 + * @author KnowledgeTree Team
  238 + * @access public
  239 + * @var array
  240 + */
  241 + protected $silent = true;
  242 +
  243 + /**
  244 + * Constructs database object
  245 + *
  246 + * @author KnowledgeTree Team
  247 + * @access public
  248 + * @param none
  249 + */
  250 + public function __construct() {
  251 + $this->temp_variables = array("step_name"=>"database", "silent"=>$this->silent);
  252 + $this->_dbhandler = new dbUtil();
  253 + $this->_util = new MigrateUtil();
  254 + if(WINDOWS_OS)
  255 + $this->mysqlDir = MYSQL_BIN;
  256 + }
  257 +
  258 + /**
  259 + * Main control of database setup
  260 + *
  261 + * @author KnowledgeTree Team
  262 + * @param none
  263 + * @access public
  264 + * @return string
  265 + */
  266 + public function doStep() {
  267 + $this->initErrors();
  268 + $this->setDetails(); // Set any posted variables
  269 + if(!$this->inStep("database")) {
  270 + return 'landing';
  271 + }
  272 + if($this->next()) {
  273 + return 'next';
  274 + } else if($this->previous()) {
  275 + return 'previous';
  276 + }
  277 +
  278 + return 'landing';
  279 + }
  280 +
  281 + /**
  282 + * Store options
  283 + *
  284 + * @author KnowledgeTree Team
  285 + * @params object SimpleXmlObject
  286 + * @access private
  287 + * @return void
  288 + */
  289 + private function setDetails() {
  290 + $this->temp_variables['dhost'] = $this->getPostSafe('dhost');
  291 + $this->temp_variables['dport'] = $this->getPostSafe('dport');
  292 + $this->temp_variables['duname'] = $this->getPostSafe('duname');
  293 + $this->temp_variables['dpassword'] = $this->getPostSafe('dpassword');
  294 + $this->temp_variables['dbbinary'] = $this->getPostSafe('dbbinary');
  295 + }
  296 +
  297 + /**
  298 + * Safer way to return post data
  299 + *
  300 + * @author KnowledgeTree Team
  301 + * @params SimpleXmlObject $simplexml
  302 + * @access public
  303 + * @return void
  304 + */
  305 + public function getPostSafe($key) {
  306 + return isset($_POST[$key]) ? $_POST[$key] : "";
  307 + }
  308 +
  309 + /**
  310 + * Stores varibles used by template
  311 + *
  312 + * @author KnowledgeTree Team
  313 + * @params none
  314 + * @access public
  315 + * @return array
  316 + */
  317 + public function getStepVars() {
  318 + return $this->temp_variables;
  319 + }
  320 +
  321 + /**
  322 + * Returns database errors
  323 + *
  324 + * @author KnowledgeTree Team
  325 + * @access public
  326 + * @params none
  327 + * @return array
  328 + */
  329 + public function getErrors() {
  330 +
  331 + return $this->error;
  332 + }
  333 +
  334 + /**
  335 + * Initialize errors to false
  336 + *
  337 + * @author KnowledgeTree Team
  338 + * @param none
  339 + * @access private
  340 + * @return boolean
  341 + */
  342 + private function initErrors() {
  343 + foreach ($this->templateErrors as $e) {
  344 + $this->error[$e] = false;
  345 + }
  346 + }
  347 +}
  348 +?>
0 349 \ No newline at end of file
... ...
setup/migrate/steps/migrateErrors.php 0 โ†’ 100644
  1 +<?php
  2 +/**
  3 +* Error 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 Migrater
  40 +* @version Version 0.1
  41 +*/
  42 +class migrateErrors extends Step {
  43 + public $error = array();
  44 +
  45 + function doStep() {
  46 + return 'landing';
  47 + }
  48 +
  49 + function getErrors() {
  50 + return $this->error;
  51 + }
  52 +
  53 + function getName() {
  54 + return 'error';
  55 + }
  56 +}
  57 +?>
0 58 \ No newline at end of file
... ...
setup/migrate/steps/migrateInstallation.php 0 โ†’ 100644
  1 +<?php
  2 +/**
  3 +* Migrate Step 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 Migrater
  40 +* @version Version 0.1
  41 +*/
  42 +
  43 +class migrateInstallation extends step
  44 +{
  45 + /**
  46 + * Flag to display confirmation page first
  47 + *
  48 + * @author KnowledgeTree Team
  49 + * @access public
  50 + * @var array
  51 + */
  52 + public $displayFirst = false;
  53 +
  54 + /**
  55 + * Flag to store class information in session
  56 + *
  57 + * @author KnowledgeTree Team
  58 + * @access public
  59 + * @var array
  60 + */
  61 + protected $storeInSession = true;
  62 +
  63 + /**
  64 + * List of paths
  65 + *
  66 + * @author KnowledgeTree Team
  67 + * @access public
  68 + * @var array
  69 + */
  70 + protected $paths = array();
  71 +
  72 + /**
  73 + * Flag if step needs to run silently
  74 + *
  75 + * @author KnowledgeTree Team
  76 + * @access public
  77 + * @var array
  78 + */
  79 + protected $silent = false;
  80 +
  81 + private $location = '';
  82 + private $dbSettings = array();
  83 + private $ktSettings = array();
  84 + private $urlPaths = array();
  85 +
  86 + function __construct() {
  87 + $this->temp_variables = array("step_name"=>"installation", "silent"=>$this->silent);
  88 + }
  89 +
  90 + public function doStep() {
  91 + $this->detectInstallation();
  92 + if(!$this->inStep("installation")) {
  93 + $this->setDetails();
  94 + $this->doRun();
  95 + return 'landing';
  96 + }
  97 + if($this->next()) {
  98 + if($this->doRun()) {
  99 + $this->setDetails();
  100 + return 'confirm';
  101 + } else {
  102 + return 'error';
  103 + }
  104 + } else if($this->previous()) {
  105 + return 'previous';
  106 + } else if($this->confirm()) {
  107 + return 'next';
  108 + }
  109 + $this->doRun();
  110 +
  111 + return 'landing';
  112 + }
  113 +
  114 + public function detectInstallation() {
  115 + if(WINDOWS_OS) {
  116 + $path1 = "'C:\\Program Files\ktdms'";
  117 + $path2 = "'C:\\Program Files x86\ktdms'";
  118 + if(file_exists($path1))
  119 + $this->location = "C:\\Program Files\ktdms";
  120 + elseif (file_exists($path2))
  121 + $this->location = "C:\\Program Files x86\ktdms";
  122 + } else {
  123 + $path1 = "/opt/ktdms";
  124 + $path2 = "/var/www/ktdms";
  125 + if(file_exists($path1))
  126 + $this->location = $path1;
  127 + elseif(file_exists($path2))
  128 + $this->location = $path2;
  129 + }
  130 + }
  131 +
  132 + public function doRun() {
  133 + $ktInstallPath = isset($_POST['location']) ? $_POST['location']: '';
  134 + if($ktInstallPath != '') {
  135 + $this->location = $ktInstallPath;
  136 + //echo $ktInstallPath;die;
  137 + if(file_exists($ktInstallPath)) {
  138 + $configPath = $ktInstallPath.DS."knowledgeTree".DS."config".DS."config-path";
  139 + if(file_exists($configPath)) {
  140 + $configFilePath = file_get_contents($configPath);
  141 + if(file_exists($configFilePath)) {
  142 + $this->readConfig($configFilePath);
  143 + $this->storeSilent();
  144 +
  145 + return true;
  146 + } else {
  147 + $this->error[] = "KT installation configuration file empty";
  148 + }
  149 + } else {
  150 + $this->error[] = "KT installation configuration file not found";
  151 + }
  152 + } else {
  153 + $this->error[] = "KT installation not found";
  154 + }
  155 + }
  156 + $this->storeSilent();
  157 +
  158 + return false;
  159 + }
  160 +
  161 + private function readConfig($path) {
  162 + $ini = new Ini($path);
  163 + $dbSettings = $ini->getSection('db');
  164 + $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'],
  165 + 'dbName'=> $dbSettings['dbName'],
  166 + 'dbUser'=> $dbSettings['dbUser'],
  167 + 'dbPass'=> $dbSettings['dbPass'],
  168 + 'dbPort'=> $dbSettings['dbPort'],
  169 + 'dbAdminUser'=> $dbSettings['dbAdminUser'],
  170 + 'dbAdminPass'=> $dbSettings['dbAdminPass'],
  171 + );
  172 + $ktSettings = $ini->getSection('KnowledgeTree');
  173 + $froot = $ktSettings['fileSystemRoot'];
  174 + if ($froot == 'default') {
  175 + $froot = $this->location;
  176 + }
  177 + $this->ktSettings = array('fileSystemRoot'=> $froot,
  178 + );
  179 + $urlPaths = $ini->getSection('urls');
  180 + $this->urlPaths = array(array('name'=> 'Var Directory', 'path'=> $froot.DS.'var'),
  181 + array('name'=> 'Log Directory', 'path'=> $froot.DS.'log'),
  182 + array('name'=> 'Document Root', 'path'=> $froot.DS.'Documents'),
  183 + array('name'=> 'UI Directory', 'path'=> $froot.DS.'presentation'.DS.'lookAndFeel'.DS.'knowledgeTree'),
  184 + array('name'=> 'Temporary Directory', 'path'=> $froot.DS.'tmp'),
  185 + array('name'=> 'Cache Directory', 'path'=> $froot.DS.'cache'),
  186 + );
  187 + $this->temp_variables['urlPaths'] = $this->urlPaths;
  188 + $this->temp_variables['ktSettings'] = $this->ktSettings;
  189 + $this->temp_variables['dbSettings'] = $this->dbSettings;
  190 + }
  191 +
  192 + private function setDetails() {
  193 + $inst = $this->getDataFromSession("installation");
  194 + if ($inst) {
  195 + $this->location = $inst['location'];
  196 + }
  197 + }
  198 +
  199 + public function getStepVars() {
  200 + return $this->temp_variables;
  201 + }
  202 +
  203 + public function getErrors() {
  204 + return $this->error;
  205 + }
  206 +
  207 + public function storeSilent() {
  208 + $this->temp_variables['location'] = $this->location;
  209 +
  210 + }
  211 +
  212 +}
  213 +?>
0 214 \ No newline at end of file
... ...
setup/migrate/steps/migrateServices.php 0 โ†’ 100644
  1 +<?php
  2 +/**
  3 +* Services Step 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 Migrater
  40 +* @version Version 0.1
  41 +*/
  42 +
  43 +class migrateServices extends Step
  44 +{
  45 + /**
  46 + * List of errors encountered
  47 + *
  48 + * @author KnowledgeTree Team
  49 + * @access protected
  50 + * @var array
  51 + */
  52 + protected $error = array();
  53 +
  54 + /**
  55 + * Flag if step needs to be migrated
  56 + *
  57 + * @author KnowledgeTree Team
  58 + * @access protected
  59 + * @var array
  60 + */
  61 + protected $runMigrate = true;
  62 +
  63 + /**
  64 + * List of services to be migrated
  65 + *
  66 + * @author KnowledgeTree Team
  67 + * @access private
  68 + * @var array
  69 + */
  70 + private $services = array();
  71 +
  72 + /**
  73 + * Reference to utility object
  74 + *
  75 + * @author KnowledgeTree Team
  76 + * @access protected
  77 + * @var string
  78 + */
  79 + protected $util;
  80 +
  81 +
  82 + /**
  83 + * Flag if services are already uninstalled
  84 + *
  85 + * @author KnowledgeTree Team
  86 + * @access private
  87 + * @var mixed
  88 + */
  89 + private $alreadyUninstalled = false;
  90 +
  91 + /**
  92 + * Service Migrateed
  93 + *
  94 + * @author KnowledgeTree Team
  95 + * @access private
  96 + * @var array
  97 + */
  98 + private $serviceCheck = 'tick';
  99 +
  100 + /**
  101 + * Flag to store class information in session
  102 + *
  103 + * @author KnowledgeTree Team
  104 + * @access public
  105 + * @var boolean
  106 + */
  107 + protected $storeInSession = true;
  108 +
  109 + /**
  110 + * List of variables to be loaded to template
  111 + *
  112 + * @author KnowledgeTree Team
  113 + * @access public
  114 + * @var array
  115 + */
  116 + protected $temp_variables;
  117 +
  118 + /**
  119 + * Flag if step needs to run silently
  120 + *
  121 + * @author KnowledgeTree Team
  122 + * @access public
  123 + * @var array
  124 + */
  125 + protected $silent = true;
  126 +
  127 + /**
  128 + * Constructs services object
  129 + *
  130 + * @author KnowledgeTree Team
  131 + * @access public
  132 + * @param none
  133 + */
  134 + public function __construct() {
  135 + $this->temp_variables = array("step_name"=>"migrateServices", "silent"=>$this->silent);
  136 + $this->util = new MigrateUtil();
  137 + }
  138 +
  139 + /**
  140 + * Main control of services setup
  141 + *
  142 + * @author KnowledgeTree Team
  143 + * @param none
  144 + * @access public
  145 + * @return string
  146 + */
  147 + public function doStep()
  148 + {
  149 + $this->installServices = $this->util->getInstallerServices();
  150 + $this->services = $this->installServices->migrateGetServices();
  151 + $this->doRun();
  152 + $this->storeSilent();
  153 + if(!$this->inStep("services")) {
  154 + return 'landing';
  155 + }
  156 + if($this->next()) {
  157 + return 'next';
  158 + } else if($this->previous()) {
  159 + return 'previous';
  160 + }
  161 +
  162 + return 'landing';
  163 + }
  164 +
  165 + /**
  166 + * Run step
  167 + *
  168 + * @author KnowledgeTree Team
  169 + * @param none
  170 + * @access private
  171 + * @return boolean
  172 + */
  173 + private function doRun() {
  174 + if(!$this->alreadyUninstalled()) { // Pre-check if services are stopped
  175 + $this->stopServices();
  176 +
  177 + }
  178 +
  179 + return $this->checkServices();
  180 + }
  181 +
  182 + /**
  183 + * Pre-check service status
  184 + *
  185 + * @return boolean If all services are not installed
  186 + */
  187 + public function alreadyUninstalled() {
  188 + $alreadyUninstalled = true;
  189 + foreach ($this->services as $service) {
  190 + $sStatus = $service->status();
  191 + if($sStatus != '') {
  192 + return false;
  193 + }
  194 + }
  195 +
  196 + return $alreadyUninstalled;
  197 + }
  198 +
  199 + /**
  200 + * Attempt to stop services
  201 + *
  202 + */
  203 + private function stopServices() {
  204 + // Try the dmsctl
  205 + $cmd = "./dmsctl.sh stop";
  206 + $this->util->pexec($cmd);
  207 + // probably will not work.
  208 + foreach ($this->services as $service) {
  209 + $sStatus = $service->status();
  210 + if($sStatus != '') {
  211 + $res = $service->uninstall();
  212 + print_r($res);
  213 + }
  214 + }
  215 + }
  216 +
  217 + public function checkServices() {
  218 + foreach ($this->services as $service) {
  219 + $sStatus = $service->status();
  220 + if($sStatus == 'STARTED') {
  221 + $state = 'cross';
  222 + } else {
  223 + $state = 'tick';
  224 + }
  225 + $this->temp_variables['services'][$service->getName()]['class'] = $state;
  226 + $this->temp_variables['services'][$service->getName()]['msg'] = $service->getName();
  227 + }
  228 + }
  229 + /**
  230 + * Returns services errors
  231 + *
  232 + * @author KnowledgeTree Team
  233 + * @access public
  234 + * @params none
  235 + * @return array
  236 + */
  237 + public function getErrors() {
  238 + return $this->error;
  239 + }
  240 +
  241 + /**
  242 + * Returns services warnings
  243 + *
  244 + * @author KnowledgeTree Team
  245 + * @access public
  246 + * @params none
  247 + * @return array
  248 + */
  249 + public function getWarnings() {
  250 + return $this->warnings;
  251 + }
  252 +
  253 + /**
  254 + * Get the variables to be passed to the template
  255 + *
  256 + * @author KnowledgeTree Team
  257 + * @access public
  258 + * @return array
  259 + */
  260 + public function getStepVars()
  261 + {
  262 + return $this->temp_variables;
  263 + }
  264 +
  265 + /**
  266 + * Set all silent mode varibles
  267 + *
  268 + * @author KnowledgeTree Team
  269 + * @param none
  270 + * @access private
  271 + * @return void
  272 + */
  273 + private function storeSilent() {
  274 + $this->temp_variables['alreadyUninstalled'] = $this->alreadyUninstalled;
  275 + $this->temp_variables['serviceCheck'] = $this->serviceCheck;
  276 + }
  277 +}
  278 +?>
0 279 \ No newline at end of file
... ...
setup/migrate/steps/migrateWelcome.php 0 โ†’ 100644
  1 +<?php
  2 +/**
  3 +* Welcome Step 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 Migrater
  40 +* @version Version 0.1
  41 +*/
  42 +
  43 +class migrateWelcome extends step {
  44 +
  45 + protected $silent = true;
  46 +
  47 + function __construct() {
  48 + $this->temp_variables = array("step_name"=>"welcome");
  49 + }
  50 +
  51 + function doStep() {
  52 + if($this->next()) {
  53 + return 'next'; // Just a welcome, so return "next" action
  54 + } elseif ($this->installer()) {
  55 + return 'install'; // Just a welcome, so return "next" action
  56 + }
  57 +
  58 + return 'landing';
  59 + }
  60 +
  61 +}
  62 +
  63 +?>
0 64 \ No newline at end of file
... ...
setup/migrate/templates/services.tpl
... ... @@ -33,15 +33,23 @@
33 33 <?php } ?>
34 34 <!--Content-->
35 35 <div id="step_content_configuration" style="width:755px;" class="step">
36   - <?php if(!$alreadyStopped) { ?>
  36 + <?php if(!$alreadyUninstalled) { ?>
37 37  
38 38 <?php } else { ?>
39   - All services are already shut down.
  39 + All services are uninstalled.
40 40 <?php } ?>
41 41 <h3><?php echo "<span class='{$serviceCheck}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Services Check</h3>
42 42 <?php if($silent) { ?>
43   - <div id="option6" class="onclick" onclick="javascript:{w.toggleClass('service_details', 'option6');}">Show Details</div>
44   - <div class="service_details" style="display:none">
  43 + <?php if($serviceCheck != 'tick') {
  44 + $details = 'Hide Details';
  45 + $display = 'block';
  46 + } else {
  47 + $details = 'Show Details';
  48 + $display = 'none';
  49 + }
  50 + ?>
  51 + <div id="option6" class="onclick" onclick="javascript:{w.toggleClass('service_details', 'option6');}"><?php echo $details; ?></div>
  52 + <div class="service_details" style="display:<?php echo $display; ?>">
45 53 <?php } ?>
46 54 <table>
47 55 <?php
... ...
setup/wizard/lib/services/unixAgent.php
... ... @@ -42,7 +42,7 @@
42 42  
43 43 class unixAgent extends unixService {
44 44  
45   - public $name = "KTAgentTest";
  45 + public $name = "KTAgent";
46 46  
47 47  
48 48 }
... ...
setup/wizard/lib/services/unixLucene.php
... ... @@ -50,7 +50,7 @@ class unixLucene extends unixService {
50 50 private $luceneSourceLoc;
51 51 private $javaXms;
52 52 private $javaXmx;
53   - public $name = "KTLuceneTest";
  53 + public $name = "KTLucene";
54 54  
55 55 public function load() {
56 56 $this->util = new InstallUtil();
... ... @@ -143,7 +143,7 @@ class unixLucene extends unixService {
143 143 }
144 144  
145 145 }
146   -
  146 +
147 147 public function install() {
148 148 $status = $this->status();
149 149 if($status == '') {
... ... @@ -201,6 +201,8 @@ class unixLucene extends unixService {
201 201 return false;
202 202 }
203 203  
204   -
  204 + public function getName() {
  205 + return $this->name;
  206 + }
205 207 }
206 208 ?>
207 209 \ No newline at end of file
... ...
setup/wizard/lib/services/unixOpenOffice.php
... ... @@ -131,16 +131,16 @@ class unixOpenOffice extends unixService {
131 131  
132 132 public function status() {
133 133 sleep(1);
134   - $cmd = "ps ax | grep ".$this->getOfficeName();
  134 + $cmd = "netstat -npa | grep ".$this->getPort();
135 135 $response = $this->util->pexec($cmd);
136 136 if(is_array($response['out'])) {
137   - if(count($response['out']) > 1) {
138   - foreach ($response['out'] as $r) {
139   - preg_match('/grep/', $r, $matches); // Ignore grep
140   - if(!$matches) {
  137 + if(count($response['out']) > 0) {
  138 + preg_match('/8100/', $response['out'][0], $matches); // Ignore grep
  139 + if($matches) {
  140 + if($matches[0] == '8100') {
141 141 return 'STARTED';
142 142 }
143   - }
  143 + }
144 144 } else {
145 145 return '';
146 146 }
... ... @@ -181,5 +181,9 @@ class unixOpenOffice extends unixService {
181 181 function uninstall() {
182 182 $this->stop();
183 183 }
  184 +
  185 + public function getName() {
  186 + return $this->name;
  187 + }
184 188 }
185 189 ?>
186 190 \ No newline at end of file
... ...
setup/wizard/lib/services/unixScheduler.php
... ... @@ -47,7 +47,7 @@ class unixScheduler extends unixService {
47 47 private $systemDir;
48 48 private $scheduler;
49 49 private $phpCli;
50   - public $name = "KTSchedulerTest";
  50 + public $name = "KTScheduler";
51 51  
52 52 public function load() {
53 53 $this->util = new InstallUtil();
... ... @@ -173,6 +173,9 @@ class unixScheduler extends unixService {
173 173  
174 174 return $response;
175 175 }
176   -
  176 +
  177 + public function getName() {
  178 + return $this->name;
  179 + }
177 180 }
178 181 ?>
... ...
setup/wizard/lib/services/windowsAgent.php
... ... @@ -50,7 +50,7 @@ class windowsAgent extends windowsService {
50 50 * @param none
51 51 * @return string
52 52 */
53   - public $name = "KTAgentTest";
  53 + public $name = "KTAgent";
54 54  
55 55  
56 56 }
... ...
setup/wizard/lib/services/windowsLucene.php
... ... @@ -130,7 +130,7 @@ class windowsLucene extends windowsService {
130 130 * @param none
131 131 * @return string
132 132 */
133   - public $name = "KTLuceneTest";
  133 + public $name = "KTLucene";
134 134  
135 135 /**
136 136 * Load defaults needed by service
... ...
setup/wizard/lib/services/windowsOpenOffice.php
... ... @@ -140,7 +140,7 @@ class windowsOpenOffice extends windowsService {
140 140 * @param none
141 141 * @return string
142 142 */
143   - public $name = "KTOpenOfficeTest";
  143 + public $name = "KTOpenOffice";
144 144  
145 145 public function load() {
146 146 // hack for testing
... ...
setup/wizard/lib/services/windowsScheduler.php
... ... @@ -75,7 +75,7 @@ class windowsScheduler extends windowsService {
75 75 * @param none
76 76 * @return string
77 77 */
78   - public $name = "KTSchedulerTest";
  78 + public $name = "KTScheduler";
79 79  
80 80 /**
81 81 * Load defaults needed by service
... ...
setup/wizard/lib/system/config-path-mock
1 1 /var/lib/knowledgetree
2   -/var/www/installers/knowledgetree/config/config.ini
3   -/var/log/knowledgetree
4   -/var/tmp/knowledgetree
5 2 /var/lib/knowledgetree/Documents
6 3 /var/lib/knowledgetree/indexes
7   -/var/lib/knowledgetree/proxies
8   -/var/lib/knowledgetree/uploads
9   -/var/lib/knowledgetree/cache
10 4 \ No newline at end of file
  5 +/etc/knowledgetree/config.ini
  6 +/var/log/knowledgetree
  7 +/var/tmp/knowledgetree
  8 +/var/tmp/knowledgetree/proxies
  9 +/var/tmp/knowledgetree/uploads
  10 +/var/tmp/knowledgetree/cache
11 11 \ No newline at end of file
... ...
setup/wizard/lib/system/javaVersion.java
... ... @@ -3,7 +3,6 @@ import java.lang.System;
3 3 import java.util.Properties;
4 4  
5 5 public class javaVersion {
6   -
7 6 public static void main(String args[]) throws Exception {
8 7 String outJV = args[0];
9 8 String outJVHome = args[1];
... ...
setup/wizard/steps/services.php
... ... @@ -1195,6 +1195,20 @@ class services extends Step
1195 1195 return $this->php;
1196 1196 }
1197 1197  
  1198 + /** Migrate Access **/
  1199 + public function migrateGetServices() {
  1200 + $services = array();
  1201 + foreach ($this->getServices() as $serviceName) {
  1202 + $className = OS.$serviceName;
  1203 + $service = new $className();
  1204 + $service->load();
  1205 + $services[] = $service;
  1206 + }
  1207 +
  1208 + return $services;
  1209 + }
  1210 +
  1211 + /** External Access **/
1198 1212 public function doDeleteAll() {
1199 1213 $serverDetails = $this->getServices();
1200 1214 foreach ($serverDetails as $serviceName) {
... ...
setup/wizard/templates/error.tpl
... ... @@ -20,8 +20,7 @@
20 20 <div id="wrapper">
21 21 <div id="container">
22 22 <div id="sidebar">
23   - <span class='current'>Welcome</span><br /><span class='inactive'>License Agreement</span><br /><span class='inactive'>PHP Dependencies</span><br /><span class='inactive'>System Configuration</span><br /><span class='inactive'>Service Dependency</span><br /><span class='inactive'>Database Configuration</span><br /><span class='inactive'>Registration</span><br /><span class='inactive'>Install</span><br /><span class='inactive'>Complete</span><br /> </div>
24   -
  23 + <span id="welcome" class="current">Welcome</span><br><span id="license" class="inactive">License Agreement</span><br><span id="installtype" class="inactive">Install Type</span><br><span id="dependencies" class="inactive">PHP Dependencies</span><br><span id="configuration" class="inactive">System Configuration</span><br><span id="services" class="inactive">Service Dependency</span><br><span id="database" class="inactive">Database Configuration</span><br><span id="registration" class="inactive">Registration</span><br><span id="install" class="inactive">Install</span><br><span id="complete" class="inactive">Complete</span><br></div>
25 24 <div id="content">
26 25 <div id="content_container">
27 26 <form action="index.php?step_name=welcome" method="post">
... ...