Commit 8591accd3debbe5b84d2dcdc8544c7103c7289f9

Authored by jarrett
1 parent 3a6dd0a9

Merge Work/Home

Commited By: Jarrett Jordaan

Reviewed By: Megan Watson
setup/migrate/migrateUtil.php
... ... @@ -62,15 +62,15 @@ class MigrateUtil extends InstallUtil {
62 62 public function error($error) {
63 63 $template_vars['error'] = $error;
64 64 $file = "templates/error.tpl";
65   - if (!file_exists($file)) {
66   - return false;
  65 + if (file_exists($file)) {
  66 + extract($template_vars); // Extract the vars to local namespace
  67 + ob_start();
  68 + include($file);
  69 + $contents = ob_get_contents();
  70 + ob_end_clean();
  71 + echo $contents;
67 72 }
68   - extract($template_vars); // Extract the vars to local namespace
69   - ob_start();
70   - include($file);
71   - $contents = ob_get_contents();
72   - ob_end_clean();
73   - echo $contents;
  73 + return false;
74 74 }
75 75  
76 76 /**
... ...
setup/migrate/migrateWizard.php
... ... @@ -52,17 +52,17 @@ function __autoload($class) { // Attempt and autoload classes
52 52 if ($class == "template") { // Load existing templating classes
53 53 require_once("../wizard/template.php");
54 54 require_once("../wizard/lib/helpers/htmlHelper.php");
55   - return ;
56   - }
57   - if(file_exists(WIZARD_DIR."$class.php")) {
58   - require_once(WIZARD_DIR."$class.php");
59   - } elseif (file_exists(STEP_DIR."$class.php")) {
60   - require_once(STEP_DIR."$class.php");
61   - } elseif (file_exists(WIZARD_LIB."$class.php")) {
62   - require_once(WIZARD_LIB."$class.php");
  55 +
63 56 } else {
64   - return null;
  57 + if(file_exists(WIZARD_DIR."$class.php")) {
  58 + require_once(WIZARD_DIR."$class.php");
  59 + } elseif (file_exists(STEP_DIR."$class.php")) {
  60 + require_once(STEP_DIR."$class.php");
  61 + } elseif (file_exists(WIZARD_LIB."$class.php")) {
  62 + require_once(WIZARD_LIB."$class.php");
  63 + }
65 64 }
  65 + return true;
66 66 }
67 67  
68 68 class MigrateWizard {
... ... @@ -233,8 +233,6 @@ class MigrateWizard {
233 233 return true;
234 234 break;
235 235 }
236   -
237   - return $res;
238 236 }
239 237  
240 238 /**
... ...
setup/migrate/migrater.php
... ... @@ -157,7 +157,7 @@ class Migrater {
157 157 $this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name);
158 158 } catch (Exception $e) {
159 159 $util = new MigrateUtil();
160   - $util->error("Error reading configuration file: $name");
  160 + $util->error("Error reading configuration file: $e");
161 161 exit();
162 162 }
163 163 }
... ... @@ -431,8 +431,7 @@ class Migrater {
431 431 if($class->runMigrate()) { // Check if step needs to be migrated
432 432 $class->setDataFromSession($className); // Set Session Information
433 433 $class->setPostConfig(); // Set any posted variables
434   - $response = $class->migrateStep(); // Run migrate step
435   - // TODO : Break on error response
  434 + $class->migrateStep(); // Run migrate step
436 435 }
437 436 } else {
438 437 $util = new MigrateUtil();
... ...
setup/migrate/step.php
... ... @@ -186,30 +186,6 @@ class Step
186 186 }
187 187  
188 188 /**
189   - * Load default step values
190   - *
191   - * @author KnowledgeTree Team
192   - * @param none
193   - * @access public
194   - * @return void
195   - */
196   - public function loadDefaults() {
197   -
198   - }
199   -
200   - /**
201   - * Return default step values
202   - *
203   - * @author KnowledgeTree Team
204   - * @param none
205   - * @access public
206   - * @return array
207   - */
208   - public function getDefaults() {
209   - return array();
210   - }
211   -
212   - /**
213 189 * Checks if edit button has been clicked
214 190 *
215 191 * @author KnowledgeTree Team
... ...
setup/migrate/stepAction.php
... ... @@ -229,12 +229,14 @@ class stepAction {
229 229 } else {
230 230 $this->_clearErrors($this->stepName); // Send Errors to session
231 231 }
232   - return $response;
233 232 } else {
234 233 $this->stepName = 'errors';
235 234 $this->action = $this->createStep();
236 235 $this->action->error = array('Class File Missing in Step Directory');
  236 + $response = '';
237 237 }
  238 +
  239 + return $response;
238 240 }
239 241  
240 242 /**
... ... @@ -308,7 +310,7 @@ class stepAction {
308 310 $menu = '';
309 311 $active = false;
310 312 if($this->stepClassNames) {
311   - foreach ($this->stepClassNames as $k=>$step) {
  313 + foreach ($this->stepClassNames as $step) {
312 314 if($this->step_names[$step] != '') {
313 315 $item = $this->step_names[$step];
314 316 } else {
... ... @@ -452,7 +454,7 @@ class stepAction {
452 454 * @access private
453 455 * @return void
454 456 */
455   - private function _loadValueToSession($class, $k, $v, $overwrite = false) {
  457 + private function _loadValueToSession($class, $k, $v) {
456 458 if($this->session != null) {
457 459 $this->session->setClass($class, $k, $v);
458 460 } else {
... ... @@ -502,8 +504,7 @@ class stepAction {
502 504 * @access private
503 505 * @return void
504 506 */
505   - private function _loadErrorToSession($class, $k, $v, $overwrite = false) {
506   - $k = "errors";
  507 + private function _loadErrorToSession($class, $k = "errors", $v) {
507 508 if($this->session != null) {
508 509 $this->session->setClassError($class, $k, $v);
509 510 } else {
... ...
setup/migrate/steps/migrateDatabase.php
... ... @@ -122,19 +122,17 @@ class migrateDatabase extends Step
122 122 $manual = false; // If file was exported manually
123 123 $dbSettings = $installation['dbSettings'];
124 124 $location = $installation['location'];
125   - $uname = $this->temp_variables['duname'];
126   - $pwrd = $this->temp_variables['dpassword'];
127 125 $port = $this->util->getPort($location);
128 126 $tmpFolder = $this->resolveTempDir();
129 127 if(WINDOWS_OS) {
130 128 $termOrBash = "command prompt window";
131   - $exe = "\"$location\mysql\bin\mysqldump.exe\""; // Location of dump
  129 + $exe = "\"$location".DS."mysql".DS."bin".DS."mysqldump.exe\""; // Location of dump
132 130 } else {
133 131 $termOrBash = "terminal window";
134 132 $exe = "'$location/mysql/bin/mysqldump'"; // Location of dump
135 133 }
136 134 $date = date('Y-m-d-H-i-s');
137   - if(isset($database)) {
  135 + if(isset($database['manual_export'])) {
138 136 $sqlFile = $database['manual_export'];
139 137 if(file_exists($sqlFile)) {
140 138 $manual = true;
... ... @@ -147,7 +145,7 @@ class migrateDatabase extends Step
147 145 if(!$manual) { // Try to export database
148 146 $sqlFile = $tmpFolder."/kt-backup-$date.sql";
149 147 $cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.$dbName.' > '.$sqlFile;
150   -// $response = $this->util->pexec($cmd);
  148 + $this->util->pexec($cmd);
151 149 }
152 150 if(file_exists($sqlFile)) {
153 151 $fileContents = file_get_contents($sqlFile);
... ... @@ -157,10 +155,14 @@ class migrateDatabase extends Step
157 155 }
158 156 }
159 157 // Handle failed dump
160   - $sqlFile = "/tmp/kt-backup-$date.sql"; // Use tmp instead due to permissions
  158 + if(WINDOWS_OS) {
  159 + $sqlFile = "\"C:\kt-backup-$date.sql\""; // Use tmp instead due to permissions
  160 + } else {
  161 + $sqlFile = "/tmp/kt-backup-$date.sql"; // Use tmp instead due to permissions
  162 + }
161 163 $cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.$dbName.' > '.$sqlFile;
162   - $this->error[]['error'] = "Could not export database:";
163   - $this->error[]['msg'] = "Execute the following command in a $termOrBash.";
  164 + $this->error[]['error'] = "Could not export database";
  165 + $this->error[]['msg'] = "Execute the following command in a $termOrBash:";
164 166 $this->error[]['cmd'] = $cmd;
165 167 $this->temp_variables['manual_export'] = $sqlFile;
166 168  
... ...
setup/migrate/steps/migrateInstallation.php
... ... @@ -162,6 +162,7 @@ class migrateInstallation extends step
162 162 if($this->foundVersion < $this->supportedVersion) {
163 163 $this->versionError = true;
164 164 $this->error[] = "KT installation needs to be 3.6.1 or higher";
  165 + return false;
165 166 } else {
166 167 return true;
167 168 }
... ... @@ -222,6 +223,8 @@ class migrateInstallation extends step
222 223 } else {
223 224 $this->error[] = "Please Enter a Location";
224 225 }
  226 +
  227 + return false;
225 228 }
226 229  
227 230 private function loadConfig($path) {
... ... @@ -242,7 +245,6 @@ class migrateInstallation extends step
242 245 }
243 246 $this->ktSettings = array('fileSystemRoot'=> $froot,
244 247 );
245   - $urlPaths = $ini->getSection('urls');
246 248 $varDir = $froot.DS.'var';
247 249 $this->urlPaths = array(array('name'=> 'Var Directory', 'path'=> $varDir),
248 250 array('name'=> 'Log Directory', 'path'=> $varDir.DS.'log'),
... ...
setup/migrate/steps/migrateServices.php
... ... @@ -202,11 +202,11 @@ class migrateServices extends Step
202 202 */
203 203 public function unixStop() {
204 204 $cmd = $this->conf['location']."/dmsctl.sh stop lucene";
205   - $res = $this->util->pexec($cmd);
  205 + $this->util->pexec($cmd);
206 206 $cmd = $this->conf['location']."/dmsctl.sh stop scheduler";
207   - $res = $this->util->pexec($cmd);
  207 + $this->util->pexec($cmd);
208 208 $cmd = $this->conf['location']."/dmsctl.sh stop soffice";
209   - $res = $this->util->pexec($cmd);
  209 + $this->util->pexec($cmd);
210 210 }
211 211  
212 212 /**
... ... @@ -215,11 +215,11 @@ class migrateServices extends Step
215 215 */
216 216 public function windowsStop() {
217 217 $cmd = "sc delete KTLucene";
218   - $res = $this->util->pexec($cmd);
  218 + $this->util->pexec($cmd);
219 219 $cmd = "sc delete KTScheduler";
220   - $res = $this->util->pexec($cmd);
  220 + $this->util->pexec($cmd);
221 221 $cmd = "sc delete KTOpenoffice";
222   - $res = $this->util->pexec($cmd);
  222 + $this->util->pexec($cmd);
223 223 }
224 224  
225 225 /**
... ... @@ -233,7 +233,7 @@ class migrateServices extends Step
233 233 $serv->load();
234 234 $sStatus = $serv->status();
235 235 if($sStatus != '') {
236   - $res = $serv->uninstall();
  236 + $serv->uninstall();
237 237 }
238 238 }
239 239 }
... ...
setup/upgrade/step.php
... ... @@ -172,30 +172,6 @@ class Step
172 172 public function getWarnings() {
173 173 return $this->warnings;
174 174 }
175   -
176   - /**
177   - * Load default step values
178   - *
179   - * @author KnowledgeTree Team
180   - * @param none
181   - * @access public
182   - * @return void
183   - */
184   - public function loadDefaults() {
185   -
186   - }
187   -
188   - /**
189   - * Return default step values
190   - *
191   - * @author KnowledgeTree Team
192   - * @param none
193   - * @access public
194   - * @return array
195   - */
196   - public function getDefaults() {
197   - return array();
198   - }
199 175  
200 176 /**
201 177 * Checks if edit button has been clicked
... ...
setup/upgrade/stepAction.php
... ... @@ -229,12 +229,14 @@ class stepAction {
229 229 } else {
230 230 $this->_clearErrors($this->stepName); // Send Errors to session
231 231 }
232   - return $response;
233 232 } else {
234 233 $this->stepName = 'errors';
235 234 $this->action = $this->createStep();
236 235 $this->action->error = array('Class File Missing in Step Directory');
  236 + $response = '';
237 237 }
  238 +
  239 + return $response;
238 240 }
239 241  
240 242 /**
... ... @@ -308,7 +310,7 @@ class stepAction {
308 310 $menu = '';
309 311 $active = false;
310 312 if($this->stepClassNames) {
311   - foreach ($this->stepClassNames as $k=>$step) {
  313 + foreach ($this->stepClassNames as $step) {
312 314 if($this->step_names[$step] != '') {
313 315 $item = $this->step_names[$step];
314 316 } else {
... ... @@ -452,7 +454,7 @@ class stepAction {
452 454 * @access private
453 455 * @return void
454 456 */
455   - private function _loadValueToSession($class, $k, $v, $overwrite = false) {
  457 + private function _loadValueToSession($class, $k, $v) {
456 458 if($this->session != null) {
457 459 $this->session->setClass($class, $k, $v);
458 460 } else {
... ... @@ -502,8 +504,7 @@ class stepAction {
502 504 * @access private
503 505 * @return void
504 506 */
505   - private function _loadErrorToSession($class, $k, $v, $overwrite = false) {
506   - $k = "errors";
  507 + private function _loadErrorToSession($class, $k = "errors", $v) {
507 508 if($this->session != null) {
508 509 $this->session->setClassError($class, $k, $v);
509 510 } else {
... ...
setup/upgrade/steps/upgradeBackup.php
... ... @@ -120,7 +120,7 @@ class upgradeBackup extends Step {
120 120  
121 121 if (is_file($dir . '/mysqladmin') || is_file($dir . '/mysqladmin.exe'))
122 122 {
123   - $curdir=getcwd();
  123 +// $curdir=getcwd();
124 124 chdir($dir);
125 125  
126 126 $handle = popen($stmt['cmd'], 'r');
... ... @@ -198,7 +198,7 @@ class upgradeBackup extends Step {
198 198  
199 199 $adminUser = $oKTConfig->get('db/dbAdminUser');
200 200 $adminPwd = $oKTConfig->get('db/dbAdminPass');
201   - $dbHost = $oKTConfig->get('db/dbHost');
  201 +// $dbHost = $oKTConfig->get('db/dbHost');
202 202 $dbName = $oKTConfig->get('db/dbName');
203 203  
204 204 $dbPort = trim($oKTConfig->get('db/dbPort'));
... ...
setup/upgrade/steps/upgradeDatabase.php
... ... @@ -144,10 +144,10 @@ class upgradeDatabase extends Step
144 144 $this->readConfig(KTConfig::getConfigFilename());
145 145  
146 146 if($this->dbSettings['dbPort'] == '') {
147   - $con = $this->dbhandler->load($this->dbSettings['dbHost'], $this->dbSettings['dbUser'],
  147 + $this->dbhandler->load($this->dbSettings['dbHost'], $this->dbSettings['dbUser'],
148 148 $this->dbSettings['dbPass'], $this->dbSettings['dbName']);
149 149 } else {
150   - $con = $this->dbhandler->load($this->dbSettings['dbHost'].":".$this->dbSettings['dbPort'], $this->dbSettings['dbUser'],
  150 + $this->dbhandler->load($this->dbSettings['dbHost'].":".$this->dbSettings['dbPort'], $this->dbSettings['dbUser'],
151 151 $this->dbSettings['dbPass'], $this->dbSettings['dbName']);
152 152 }
153 153  
... ... @@ -285,7 +285,8 @@ class upgradeDatabase extends Step
285 285 }
286 286  
287 287 $res = $this->performAllUpgrades();
288   - if (PEAR::isError($res) || PEAR::isError($pres)) {
  288 +// if (PEAR::isError($res) || PEAR::isError($pres)) {
  289 + if (PEAR::isError($res)) {
289 290 $errors = true;
290 291 // TODO instantiate error details hideable section?
291 292 $this->temp_variables['upgradeStatus'] = '<font color="red">Database upgrade failed</font>
... ... @@ -300,7 +301,8 @@ class upgradeDatabase extends Step
300 301 }
301 302  
302 303 $post_pres = $this->performPostUpgradeActions();
303   - if (PEAR::isError($post_res)) {
  304 +// if (PEAR::isError($post_res)) {
  305 + if (PEAR::isError($post_pres)) {
304 306 $errors = true;
305 307 $this->temp_variables['postUpgrade'] = '<font color="red">Post-Upgrade actions failed.</font>';
306 308 }
... ... @@ -334,7 +336,7 @@ class upgradeDatabase extends Step
334 336  
335 337 // Ensure all plugins are re-registered.
336 338 $sql = "TRUNCATE plugin_helper";
337   - $res = DBUtil::runQuery($sql);
  339 + DBUtil::runQuery($sql);
338 340  
339 341 // Clear out all caches and proxies - they need to be regenerated with the new code
340 342 $proxyDir = $default->proxyCacheDirectory;
... ...
setup/upgrade/steps/upgradeRestore.php
... ... @@ -111,14 +111,14 @@ class upgradeRestore extends Step {
111 111 private function restoreDatabase()
112 112 {
113 113 $this->temp_variables['restore'] = true;
114   - $status = $_SESSION['backupStatus'];
  114 +// $status = $_SESSION['backupStatus'];
115 115 $filename = $_SESSION['backupFile'];
116 116 $stmt = $this->util->create_restore_stmt($filename);
117 117 $dir = $stmt['dir'];
118 118  
119 119 if (is_file($dir . '/mysql') || is_file($dir . '/mysql.exe'))
120 120 {
121   - $curdir=getcwd();
  121 +// $curdir=getcwd();
122 122 chdir($dir);
123 123  
124 124 $ok=true;
... ... @@ -181,9 +181,11 @@ class upgradeRestore extends Step {
181 181 $dir = $this->util->resolveTempDir();
182 182  
183 183 $files = array();
184   - if ($dh = opendir($dir))
  184 + $dh = opendir($dir);
  185 + if ($dh)
185 186 {
186   - while (($file = readdir($dh)) !== false)
  187 + $file = readdir($dh);
  188 + while ($file !== false)
187 189 {
188 190 if (!preg_match('/kt-backup.+\.sql/',$file)) {
189 191 continue;
... ... @@ -217,7 +219,7 @@ class upgradeRestore extends Step {
217 219 return;
218 220 }
219 221  
220   - $status = $_SESSION['backupStatus'];
  222 +// $status = $_SESSION['backupStatus'];
221 223 $filename = $_SESSION['backupFile'];
222 224 $stmt = $this->util->create_restore_stmt($filename);
223 225  
... ...
setup/upgrade/steps/upgradeWelcome.php
... ... @@ -81,7 +81,7 @@ class upgradeWelcome extends step {
81 81 }
82 82  
83 83 private function checkPassword($username, $password) {
84   - global $default;
  84 +// global $default;
85 85  
86 86 $sTable = KTUtil::getTableName('users');
87 87 $sQuery = "SELECT count(*) AS match_count FROM $sTable WHERE username = ? AND password = ?";
... ...
setup/upgrade/upgradeUtil.php
... ... @@ -64,15 +64,16 @@ class UpgradeUtil extends InstallUtil {
64 64 public function error($error) {
65 65 $template_vars['error'] = $error;
66 66 $file = "templates/error.tpl";
67   - if (!file_exists($file)) {
68   - return false;
  67 + if (file_exists($file)) {
  68 + extract($template_vars); // Extract the vars to local namespace
  69 + ob_start();
  70 + include($file);
  71 + $contents = ob_get_contents();
  72 + ob_end_clean();
  73 + echo $contents;
69 74 }
70   - extract($template_vars); // Extract the vars to local namespace
71   - ob_start();
72   - include($file);
73   - $contents = ob_get_contents();
74   - ob_end_clean();
75   - echo $contents;
  75 +
  76 + return false;
76 77 }
77 78  
78 79 public function loadInstallIni($path) {
... ... @@ -99,15 +100,16 @@ class UpgradeUtil extends InstallUtil {
99 100 }
100 101 }
101 102 $file = "templates/" . $template;
102   - if (!file_exists($file)) {
103   - return false;
  103 + if (file_exists($file)) {
  104 + extract($template_vars); // Extract the vars to local namespace
  105 + ob_start();
  106 + include($file);
  107 + $contents = ob_get_contents();
  108 + ob_end_clean();
  109 + echo $contents;
104 110 }
105   - extract($template_vars); // Extract the vars to local namespace
106   - ob_start();
107   - include($file);
108   - $contents = ob_get_contents();
109   - ob_end_clean();
110   - echo $contents;
  111 +
  112 + return false;
111 113 }
112 114  
113 115 /**
... ... @@ -133,7 +135,7 @@ class UpgradeUtil extends InstallUtil {
133 135  
134 136 $adminUser = $oKTConfig->get('db/dbAdminUser');
135 137 $adminPwd = $oKTConfig->get('db/dbAdminPass');
136   - $dbHost = $oKTConfig->get('db/dbHost');
  138 +// $dbHost = $oKTConfig->get('db/dbHost');
137 139 $dbName = $oKTConfig->get('db/dbName');
138 140 $dbPort = trim($oKTConfig->get('db/dbPort'));
139 141 if ($dbPort=='' || $dbPort=='default')$dbPort = get_cfg_var('mysql.default_port');
... ... @@ -158,7 +160,7 @@ class UpgradeUtil extends InstallUtil {
158 160 $mechanism="--port=\"$dbPort\"";
159 161 }
160 162  
161   - $tmpdir = $this->resolveTempDir();
  163 +// $tmpdir = $this->resolveTempDir();
162 164  
163 165 $stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"<br/>";
164 166 $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"<br/>";
... ... @@ -193,11 +195,13 @@ class UpgradeUtil extends InstallUtil {
193 195 }
194 196  
195 197 $oKTConfig =& KTConfig::getSingleton();
196   - $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir);
  198 +// $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir);
  199 + $mysqldir = $oKTConfig->get('backup/mysqlDirectory');
197 200 $dirs[] = $mysqldir;
198 201  
199 202 if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false) {
200   - $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin');
  203 +// $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin');
  204 + $dirs [] = realpath('/../../mysql/bin');
201 205 }
202 206  
203 207 foreach($dirs as $dir)
... ...
setup/upgrade/upgradeWizard.php
... ... @@ -52,17 +52,17 @@ function __autoload($class) { // Attempt and autoload classes
52 52 if ($class == "template") { // Load existing templating classes
53 53 require_once("../wizard/template.php");
54 54 require_once("../wizard/lib/helpers/htmlHelper.php");
55   - return ;
56   - }
57   - if(file_exists(WIZARD_DIR."$class.php")) {
58   - require_once(WIZARD_DIR."$class.php");
59   - } elseif (file_exists(STEP_DIR."$class.php")) {
60   - require_once(STEP_DIR."$class.php");
61   - } elseif (file_exists(WIZARD_LIB."$class.php")) {
62   - require_once(WIZARD_LIB."$class.php");
63 55 } else {
64   - return null;
  56 + if(file_exists(WIZARD_DIR."$class.php")) {
  57 + require_once(WIZARD_DIR."$class.php");
  58 + } elseif (file_exists(STEP_DIR."$class.php")) {
  59 + require_once(STEP_DIR."$class.php");
  60 + } elseif (file_exists(WIZARD_LIB."$class.php")) {
  61 + require_once(WIZARD_LIB."$class.php");
  62 + }
65 63 }
  64 +
  65 + return true;
66 66 }
67 67  
68 68 class UpgradeWizard {
... ... @@ -191,26 +191,7 @@ class UpgradeWizard {
191 191 * @return mixed
192 192 */
193 193 public function systemChecks() {
194   - // for now we don't write to any of these locations
195   - return true;
196   -
197   - $res = $this->util->checkStructurePermissions();
198   - if($res === true) return $res;
199   - switch ($res) {
200   - case "wizard":
201   - $this->util->error("Upgrader directory is not writable (KT_Installation_Directory/setup/upgrade/)");
202   - return 'Upgrader directory is not writable (KT_Installation_Directory/setup/upgrade/)';
203   - break;
204   - case "/":
205   - $this->util->error("System root is not writable (KT_Installation_Directory/)");
206   - return "System root is not writable (KT_Installation_Directory/)";
207   - break;
208   - default:
209   - return true;
210   - break;
211   - }
212   -
213   - return $res;
  194 + return true; // for now we don't write to any locations
214 195 }
215 196  
216 197 /**
... ...
setup/upgrade/upgrader.php
... ... @@ -157,7 +157,7 @@ class Upgrader {
157 157 $this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name);
158 158 } catch (Exception $e) {
159 159 $util = new UpgradeUtil();
160   - $util->error("Error reading configuration file: $name");
  160 + $util->error("Error reading configuration file: $e");
161 161 exit();
162 162 }
163 163 }
... ... @@ -431,8 +431,7 @@ class Upgrader {
431 431 if($class->runUpgrade()) { // Check if step needs to be upgraded
432 432 $class->setDataFromSession($className); // Set Session Information
433 433 $class->setPostConfig(); // Set any posted variables
434   - $response = $class->upgradeStep(); // Run upgrade step
435   - // TODO : Break on error response
  434 + $class->upgradeStep(); // Run upgrade step
436 435 }
437 436 } else {
438 437 $util = new UpgradeUtil();
... ...
setup/wizard/iniUtilities.php
... ... @@ -63,11 +63,12 @@ class iniUtilities {
63 63 return false;
64 64 }
65 65 $date = date('YmdHis');
66   -
67 66 $backupFile = $iniFile . '.' .$date;
68 67 if (is_writeable($backupFile)) {
69 68 file_put_contents($backupFile, $content);
70 69 }
  70 +
  71 + return true;
71 72 }
72 73  
73 74 function read($iniFile) {
... ... @@ -153,13 +154,20 @@ class iniUtilities {
153 154 }
154 155  
155 156 function itemExists($checkSection, $checkItem) {
156   -
  157 +/*
  158 + foreach ($items as $key => $value) {
  159 + if($key == $checkItem) {
  160 + return true;
  161 + }
  162 + }
  163 +*/
157 164 $this->exists = '';
158 165 foreach($this->cleanArray as $section => $items) {
159 166 if($section == $checkSection) {
160 167 $this->exists = 'section';
161   - foreach ($items as $key => $value) {
162   - if($key == $checkItem) {
  168 + $items = array_flip($items);
  169 + foreach ($items as $value) {
  170 + if($value == $checkItem) {
163 171 return true;
164 172 }
165 173 }
... ...
setup/wizard/installUtil.php
... ... @@ -70,15 +70,16 @@ class InstallUtil {
70 70 public function error($error) {
71 71 $template_vars['error'] = $error;
72 72 $file = "templates/error.tpl";
73   - if (!file_exists($file)) {
74   - return false;
  73 + if (file_exists($file)) {
  74 + extract($template_vars); // Extract the vars to local namespace
  75 + ob_start();
  76 + include($file);
  77 + $contents = ob_get_contents();
  78 + ob_end_clean();
  79 + echo $contents;
75 80 }
76   - extract($template_vars); // Extract the vars to local namespace
77   - ob_start();
78   - include($file);
79   - $contents = ob_get_contents();
80   - ob_end_clean();
81   - echo $contents;
  81 +
  82 + return false;
82 83 }
83 84 /**
84 85 * Check if system needs to be installed
... ... @@ -165,7 +166,8 @@ class InstallUtil {
165 166 return $url;
166 167 }
167 168 if (!empty($protocol)) {
168   - $url = $protocol .':'. end($array = explode(':', $url, 2));
  169 + $array = explode(':', $url, 2);
  170 + $url = $protocol .':'. end($array);
169 171 }
170 172 if (!empty($port)) {
171 173 $url = preg_replace('!^(([a-z0-9]+)://[^/:]+)(:[\d]+)?!i',
... ... @@ -321,13 +323,15 @@ class InstallUtil {
321 323 while (($file = readdir($dh)) !== false) {
322 324 if($file != '.' && $file != '..') {
323 325 $fullpath = $path.'/'.$file;
324   - if(is_link($fullpath))
  326 + if(is_link($fullpath)) {
325 327 return false;
326   - elseif(!is_dir($fullpath)) {
  328 + } elseif(!is_dir($fullpath)) {
327 329 $perms = substr(sprintf('%o', fileperms($fullpath)), -4);
328   - if($perms != $filemode)
329   - if (!chmod($fullpath, $filemode))
  330 + if($perms != $filemode) {
  331 + if (!chmod($fullpath, $filemode)) {
330 332 return false;
  333 + }
  334 + }
331 335 } elseif(!$this->chmodRecursive($fullpath, $filemode))
332 336 return false;
333 337 }
... ... @@ -354,7 +358,8 @@ class InstallUtil {
354 358 */
355 359 public function canWriteFile($filename) {
356 360 $fh = fopen($filename, "w+");
357   - if($fr = fwrite($fh, 'test') === false) {
  361 + $fr = fwrite($fh, 'test');
  362 + if($fr === false) {
358 363 return false;
359 364 }
360 365  
... ... @@ -372,9 +377,9 @@ class InstallUtil {
372 377 */
373 378 public function javaBridge() {
374 379 try {
375   - $javaSystem = new Java('java.lang.System');
  380 + new Java('java.lang.System');
376 381 } catch (JavaException $e) {
377   - return false;
  382 + return $e;
378 383 }
379 384 return true;
380 385 }
... ... @@ -763,6 +768,7 @@ class InstallUtil {
763 768 * @return string
764 769 */
765 770 public function installEnvironment() {
  771 + $matches = false;
766 772 preg_match('/Zend/', SYSTEM_DIR, $matches); // Install Type
767 773 if($matches) {
768 774 return 'Zend';
... ... @@ -792,7 +798,7 @@ class InstallUtil {
792 798 array_pop($sysdir);
793 799 array_pop($sysdir);
794 800 $zendsys = '';
795   - foreach ($sysdir as $k=>$v) {
  801 + foreach ($sysdir as $v) {
796 802 $zendsys .= $v.DS;
797 803 }
798 804 return $zendsys."ZendServer".DS."bin".DS;
... ... @@ -815,15 +821,16 @@ class InstallUtil {
815 821 if(WINDOWS_OS) { // Mysql bin [Windows]
816 822 $serverPaths = explode(';',$_SERVER['PATH']);
817 823 foreach ($serverPaths as $apath) {
  824 + $matches = false;
818 825 preg_match('/mysql/i', $apath, $matches);
819 826 if($matches) {
820 827 return $apath.DS;
821 828 break;
822 829 }
823 830 }
824   - } else {
825   - return "mysql"; // Assume its linux and can be executed from command line
826 831 }
  832 +
  833 + return "mysql"; // Assume its linux and can be executed from command line
827 834 }
828 835  
829 836 public function sqlInstallDir() {
... ...
setup/wizard/installWizard.php
... ... @@ -62,9 +62,13 @@ function __autoload($class) { // Attempt and autoload classes
62 62 } else {
63 63 if(preg_match('/Helper/', $class)) {
64 64 require_once(HELPER_DIR."$class.php");
  65 + } else if(preg_match('/Test/i', $class)) {
  66 + if($_GET['step'] != '') {
  67 + require_once(TEST_DIR."$class.php");
  68 + }
65 69 }
66   - return null;
67 70 }
  71 + return true;
68 72 }
69 73  
70 74 class InstallWizard {
... ... @@ -96,6 +100,15 @@ class InstallWizard {
96 100 protected $util = null;
97 101  
98 102 /**
  103 + * Step name
  104 + *
  105 + * @author KnowledgeTree Team
  106 + * @access protected
  107 + * @var mixed
  108 + */
  109 + protected $stepName = '';
  110 +
  111 + /**
99 112 * Constructs installation wizard object
100 113 *
101 114 * @author KnowledgeTree Team
... ... @@ -183,15 +196,27 @@ class InstallWizard {
183 196 }
184 197  
185 198 /**
186   - * Bypass and force an install
  199 + * Is the step being accessed directly
187 200 *
188 201 * @author KnowledgeTree Team
189   - * @access private
  202 + * @access public
190 203 * @param none
191 204 * @return boolean
192 205 */
193   - private function bypass() {
194   -
  206 + public function isActionOnStep() {
  207 + return $this->stepName;
  208 + }
  209 +
  210 + /**
  211 + * Set step being accessed directly
  212 + *
  213 + * @author KnowledgeTree Team
  214 + * @access public
  215 + * @param none
  216 + * @return boolean
  217 + */
  218 + private function setStep($stepName) {
  219 + $this->stepName = $stepName;
195 220 }
196 221  
197 222 /**
... ... @@ -231,6 +256,9 @@ class InstallWizard {
231 256 if(isset($_GET['bypass'])) {
232 257 $this->setBypass($_GET['bypass']);
233 258 }
  259 + if(isset($_GET['step'])) {
  260 + $this->setStep($_GET['step']);
  261 + }
234 262 if(isset($_GET['debug'])) {
235 263 $this->setDebugLevel($_GET['debug']);
236 264 } else {
... ... @@ -263,8 +291,6 @@ class InstallWizard {
263 291 return true;
264 292 break;
265 293 }
266   -
267   - return $res;
268 294 }
269 295  
270 296 /**
... ... @@ -278,10 +304,14 @@ class InstallWizard {
278 304 public function dispatch() {
279 305 $this->load();
280 306 if($this->getBypass() === "1") { // Helper to force install
281   - $this->removeInstallFile(); // TODO: Remove
  307 + $this->removeInstallFile();
282 308 } elseif ($this->getBypass() === "0") {
283 309 $this->createInstallFile();
284 310 }
  311 + if($this->isActionOnStep()) { // Testing purposes
  312 + $testStepClass = $this->stepName."Test";
  313 + new $testStepClass();
  314 + }
285 315 if(!$this->isSystemInstalled()) { // Check if the systems not installed
286 316 if($this->util->migrationSpecified()) { // Check if the migrator needs to be accessed
287 317 $this->util->redirect('../migrate');
... ...
setup/wizard/installer.php
... ... @@ -157,7 +157,7 @@ class Installer {
157 157 $this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name);
158 158 } catch (Exception $e) {
159 159 $util = new InstallUtil();
160   - $util->error("Error reading configuration file: $name");
  160 + $util->error("Error reading configuration file: $e");
161 161 exit();
162 162 }
163 163 }
... ... @@ -431,8 +431,7 @@ class Installer {
431 431 if($class->runInstall()) { // Check if step needs to be installed
432 432 $class->setDataFromSession($className); // Set Session Information
433 433 $class->setPostConfig(); // Set any posted variables
434   - $response = $class->installStep(); // Run install step
435   - // TODO : Break on error response
  434 + $class->installStep(); // Run install step
436 435 }
437 436 } else {
438 437 $util = new InstallUtil();
... ...
setup/wizard/lib/helpers/htmlHelper.php
... ... @@ -41,7 +41,7 @@
41 41 */
42 42 class htmlHelper {
43 43  
44   - var $tags = array(
  44 + private $tags = array(
45 45 'meta' => '<meta%s/>',
46 46 'metalink' => '<link href="%s"%s/>',
47 47 'link' => '<a href="%s"%s>%s</a>',
... ... @@ -96,76 +96,76 @@ class htmlHelper {
96 96 'error' => '<div%s>%s</div>'
97 97 );
98 98  
99   - function __construct() {
100   - }
  99 + public function __construct() {
  100 + }
  101 +
  102 + public function js($name) {
  103 + return "<script type=\"text/javascript\" src=\"../wizard/resources/js/$name\"></script>";
  104 + }
  105 +
  106 + public function css($name) {
  107 + return "<link rel=\"stylesheet\" type=\"text/css\" href=\"../wizard/resources/css/$name\" />";
  108 + }
  109 +
  110 + public function image($name, $options = array()) {
  111 + $path = "../wizard/resources/graphics/$name";
  112 + $image = sprintf($this->tags['image'], $path, $this->_parseAttributes($options, null, '', ' '));
101 113  
102   - function js($name) {
103   - return "<script type=\"text/javascript\" src=\"../wizard/resources/js/$name\"></script>";
104   - }
  114 + return $image;
  115 + }
  116 +
  117 + public function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) {
  118 + if (is_array($options)) {
  119 + $options = array_merge(array('escape' => true), $options);
105 120  
106   - function css($name) {
107   - return "<link rel=\"stylesheet\" type=\"text/css\" href=\"../wizard/resources/css/$name\" />";
  121 + if (!is_array($exclude)) {
  122 + $exclude = array();
108 123 }
  124 + $keys = array_diff(array_keys($options), array_merge((array)$exclude, array('escape')));
  125 + $values = array_intersect_key(array_values($options), $keys);
  126 + $escape = $options['escape'];
  127 + $attributes = array();
109 128  
110   - function image($name, $options = array()) {
111   - $path = "../wizard/resources/graphics/$name";
112   - $image = sprintf($this->tags['image'], $path, $this->_parseAttributes($options, null, '', ' '));
113   -
114   - return $image;
  129 + foreach ($keys as $index => $key) {
  130 + $attributes[] = $this->__formatAttribute($key, $values[$index], $escape);
115 131 }
116   -
117   - function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) {
118   - if (is_array($options)) {
119   - $options = array_merge(array('escape' => true), $options);
120   -
121   - if (!is_array($exclude)) {
122   - $exclude = array();
123   - }
124   - $keys = array_diff(array_keys($options), array_merge((array)$exclude, array('escape')));
125   - $values = array_intersect_key(array_values($options), $keys);
126   - $escape = $options['escape'];
127   - $attributes = array();
128   -
129   - foreach ($keys as $index => $key) {
130   - $attributes[] = $this->__formatAttribute($key, $values[$index], $escape);
131   - }
132   - $out = implode(' ', $attributes);
133   - } else {
134   - $out = $options;
135   - }
136   - return $out ? $insertBefore . $out . $insertAfter : '';
  132 + $out = implode(' ', $attributes);
  133 + } else {
  134 + $out = $options;
137 135 }
138   -
139   - function __formatAttribute($key, $value, $escape = true) {
  136 + return $out ? $insertBefore . $out . $insertAfter : '';
  137 + }
  138 +
  139 + public function __formatAttribute($key, $value, $escape = true) {
140 140 $attribute = '';
141 141 $attributeFormat = '%s="%s"';
142 142 $minimizedAttributes = array('compact', 'checked', 'declare', 'readonly', 'disabled', 'selected', 'defer', 'ismap', 'nohref', 'noshade', 'nowrap', 'multiple', 'noresize');
143 143 if (is_array($value)) {
144   - $value = '';
  144 + $value = '';
145 145 }
146   -
  146 +
147 147 if (in_array($key, $minimizedAttributes)) {
148   - if ($value === 1 || $value === true || $value === 'true' || $value == $key) {
149   - $attribute = sprintf($attributeFormat, $key, $key);
150   - }
  148 + if ($value === 1 || $value === true || $value === 'true' || $value == $key) {
  149 + $attribute = sprintf($attributeFormat, $key, $key);
  150 + }
151 151 } else {
152   - $attribute = sprintf($attributeFormat, $key, $this->ife($escape, $this->h($value), $value));
  152 + $attribute = sprintf($attributeFormat, $key, $this->ife($escape, $this->h($value), $value));
153 153 }
154 154 return $attribute;
155 155 }
156 156  
157   - function ife($condition, $val1 = null, $val2 = null) {
  157 + public function ife($condition, $val1 = null, $val2 = null) {
158 158 if (!empty($condition)) {
159   - return $val1;
  159 + return $val1;
160 160 }
161 161 return $val2;
162 162 }
163 163  
164   - function h($text, $charset = 'UTF-8') {
  164 + public function h($text, $charset = 'UTF-8') {
165 165 if (is_array($text)) {
166   - return array_map('h', $text);
  166 + return array_map('h', $text);
167 167 }
168 168 return htmlspecialchars($text, ENT_QUOTES, $charset);
169   -}
  169 + }
170 170 }
171 171 ?>
172 172 \ No newline at end of file
... ...
setup/wizard/lib/services/unixLucene.php
... ... @@ -59,7 +59,7 @@ class unixLucene extends unixService {
59 59 * @param string
60 60 * @return void
61 61 */
62   - public function load($options = null) {
  62 + public function load() {
63 63 $this->setLuceneSource("ktlucene.jar");
64 64 $this->setLuceneDir(SYSTEM_DIR."bin".DS."luceneserver".DS);
65 65 $this->setIndexerDir(SYSTEM_DIR."search2".DS."indexing".DS."bin".DS);
... ... @@ -155,7 +155,8 @@ class unixLucene extends unixService {
155 155 $response = $this->util->pexec($cmd);
156 156 return $response;
157 157 }
158   -
  158 +
  159 + return $state;
159 160 }
160 161  
161 162 public function install() {
... ... @@ -173,6 +174,7 @@ class unixLucene extends unixService {
173 174 if(is_array($response['out'])) {
174 175 if(count($response['out']) > 1) {
175 176 foreach ($response['out'] as $r) {
  177 + $matches = false;
176 178 preg_match('/grep/', $r, $matches); // Ignore grep
177 179 if(!$matches) {
178 180 return 'STARTED';
... ... @@ -207,20 +209,14 @@ class unixLucene extends unixService {
207 209 $cmd .= "nohup java {$this->getJavaXmx()} {$this->getJavaXmx()} -jar ".$this->getLuceneSource()." > ".$logFile." 2>&1 & echo $!";
208 210 if(DEBUG) {
209 211 echo "Command : $cmd<br/>";
210   - return ;
  212 + return true;
211 213 }
212 214 $response = $this->util->pexec($cmd);
213 215  
214 216 return $response;
215   - } elseif ($state == '') {
216   - // Start Service
217   - return true;
218   - } else {
219   - // Service Running Already
220   - return true;
221 217 }
222 218  
223   - return false;
  219 + return true;
224 220 }
225 221  
226 222 public function getName() {
... ...
setup/wizard/lib/services/unixOpenOffice.php
... ... @@ -106,13 +106,14 @@ class unixOpenOffice extends unixService {
106 106 }
107 107 }
108 108  
109   - public function status($updrade = false) {
  109 + public function status() {
110 110 sleep(1);
111 111 $cmd = "ps ax | grep soffice";
112 112 $response = $this->util->pexec($cmd);
113 113 if(is_array($response['out'])) {
114 114 if(count($response['out']) > 1) {
115 115 foreach ($response['out'] as $r) {
  116 + $matches = false;
116 117 preg_match('/grep/', $r, $matches); // Ignore grep
117 118 if(!$matches) {
118 119 return 'STARTED';
... ... @@ -138,29 +139,16 @@ class unixOpenOffice extends unixService {
138 139 $state = $this->status();
139 140 if($state != 'STARTED') {
140 141 $cmd = "nohup ".$this->getBin().' -nofirststartwizard -nologo -headless -accept="socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" '." &1> /dev/null &";
141   -// $cmd = "\"{$this->util->getJava()}\" -cp \"".SYS_DIR."\" openOffice ".$this->getBin();
142   -
143 142 if(DEBUG) {
144 143 echo "Command : $cmd<br/>";
145   - return ;
  144 + return true;
146 145 }
147   -// $cmd = 'nohup /usr/lib/openoffice/program/soffice -nofirststartwizard -nologo -headless -accept="socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" &> /dev/null &';
148   -// $cmd = 'nohup /usr/lib/openoffice/program/soffice -nofirststartwizard -nologo -headless -accept="socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" &1> /dev/null &';
149   -// $cmd = '/usr/lib/openoffice/program/soffice -nofirststartwizard -nologo -headless -accept="socket,host=localhost,port=8100;urp;StarOffice.ServiceManager"';
150   -// $cmd = '/usr/lib/openoffice/program/soffice.bin -nofirststartwizard -nologo -headless -accept="socket,host=localhost,port=8100;urp;StarOffice.ServiceManager"';
151   -// $cmd = '/usr/lib/openoffice/program/soffice.bin -nofirststartwizard -nologo -headless -accept="socket,host=localhost,port=8100;urp;StarOffice.ServiceManager"';
152 146 $response = $this->util->pexec($cmd);
153 147  
154 148 return $response;
155   - } elseif ($state == '') {
156   - // Start Service
157   - return true;
158   - } else {
159   - // Service Running Already
160   - return true;
161 149 }
162 150  
163   - return false;
  151 + return true;
164 152 }
165 153  
166 154 /**
... ...
setup/wizard/lib/services/unixScheduler.php
... ... @@ -57,7 +57,7 @@ class unixScheduler extends unixService {
57 57 * @param string
58 58 * @return void
59 59 */
60   - public function load($options = null) {
  60 + public function load() {
61 61 $this->setPhpCli();
62 62 $this->scheduler = 'scheduler';
63 63 $this->setSchedulerSource('schedulerTask.sh');
... ... @@ -155,6 +155,7 @@ class unixScheduler extends unixService {
155 155 if(is_array($response['out'])) {
156 156 if(count($response['out']) > 1) {
157 157 foreach ($response['out'] as $r) {
  158 + $matches = false;
158 159 preg_match('/grep/', $r, $matches); // Ignore grep
159 160 if(!$matches) {
160 161 return 'STARTED';
... ... @@ -190,7 +191,7 @@ class unixScheduler extends unixService {
190 191 }
191 192 if(DEBUG) {
192 193 echo "Command : $cmd<br/>";
193   - return ;
  194 + return true;
194 195 }
195 196 $response = $this->util->pexec($cmd);
196 197  
... ...
setup/wizard/lib/services/windowsLucene.php
... ... @@ -140,8 +140,8 @@ class windowsLucene extends windowsService {
140 140 * @param string
141 141 * @return void
142 142 */
143   - public function load($options = null) {
144   - $this->setJavaBin();
  143 + public function load() {
  144 + $this->findJavaBin();
145 145 $this->setLuceneDIR(SYSTEM_DIR."bin".DS."luceneserver");
146 146 $this->setLuceneExe("KTLuceneService.exe");
147 147 $this->setJavaJVM();
... ... @@ -172,14 +172,14 @@ class windowsLucene extends windowsService {
172 172 }
173 173  
174 174 /**
175   - * Set Java Directory path
  175 + * Dind Java Directory path
176 176 *
177 177 * @author KnowledgeTree Team
178 178 * @access private
179 179 * @param string
180 180 * @return void
181 181 */
182   - private function setJavaBin($javaBin = '') {
  182 + private function findJavaBin() {
183 183 if($this->util->zendBridge()) {
184 184 if($this->util->javaBridge()) {
185 185 $this->javaSystem = new Java('java.lang.System');
... ... @@ -379,6 +379,8 @@ class windowsLucene extends windowsService {
379 379 } else {
380 380 return false;
381 381 }
  382 +
  383 + return true;
382 384 }
383 385  
384 386 /**
... ... @@ -407,12 +409,11 @@ class windowsLucene extends windowsService {
407 409 $luceneExe = $this->getLuceneExe();
408 410 $luceneSource = $this->getLuceneSource();
409 411 $luceneDir = $this->getluceneDir();
410   - $javaJVM = $this->getJavaJVM();
411 412 if($luceneExe && $luceneSource && $luceneDir) {
412 413 $cmd = "\"{$luceneExe}\""." -install \"".$this->getName()."\" \"".$this->getJavaJVM(). "\" -Djava.class.path=\"".$luceneSource."\"". " -start ".$this->getLuceneServer(). " -out \"".$this->getLuceneOut()."\" -err \"".$this->getLuceneError()."\" -current \"".$luceneDir."\" -auto";
413 414 if(DEBUG) {
414 415 echo "Command : $cmd<br/>";
415   - return ;
  416 + return true;
416 417 }
417 418 $response = $this->util->pexec($cmd);
418 419 return $response;
... ...
setup/wizard/lib/services/windowsOpenOffice.php
... ... @@ -183,10 +183,11 @@ class windowsOpenOffice extends windowsService {
183 183 }
184 184  
185 185 private function setWinservice($winservice = "winserv.exe") {
186   - if(file_exists(SYS_BIN_DIR . $winservice))
  186 + if(file_exists(SYS_BIN_DIR . $winservice)) {
187 187 $this->winservice = SYS_BIN_DIR . $winservice;
188   - else if(file_exists(SYS_BIN_DIR . "win32" . DS. $winservice))
  188 + } else if(file_exists(SYS_BIN_DIR . "win32" . DS. $winservice)) {
189 189 $this->winservice = SYS_BIN_DIR . "win32" . DS. $winservice;
  190 + }
190 191 }
191 192  
192 193 public function getWinservice() {
... ... @@ -206,7 +207,7 @@ class windowsOpenOffice extends windowsService {
206 207 $cmd = "\"{$this->winservice}\" install $this->name "."-displayname {$this->name} -start auto \"".$binary."\" -headless -invisible -accept=socket,host={$this->host},port={$this->port};urp;";;
207 208 if(DEBUG) {
208 209 echo "Command : $cmd<br/>";
209   - return ;
  210 + return true;
210 211 }
211 212 $response = $this->util->pexec($cmd);
212 213 return $response;
... ...
setup/wizard/lib/services/windowsScheduler.php
... ... @@ -85,7 +85,7 @@ class windowsScheduler extends windowsService {
85 85 * @param string
86 86 * @return void
87 87 */
88   - function load($options = null) {
  88 + function load() {
89 89 $this->setSchedulerDIR($this->varDir."bin");
90 90 $this->setSchedulerScriptPath("taskrunner.bat");
91 91 $this->setSchedulerSource("schedulerService.php");
... ... @@ -209,7 +209,7 @@ class windowsScheduler extends windowsService {
209 209 echo '<pre>';
210 210 print_r(array('service' => $this->name, 'display' => $this->name, 'path' => $this->getSchedulerScriptPath()));
211 211 echo '</pre>';
212   - return ;
  212 + return true;
213 213 }
214 214 $response = win32_create_service(array(
215 215 'service' => $this->name,
... ... @@ -224,7 +224,7 @@ class windowsScheduler extends windowsService {
224 224 $cmd = "\"{$this->winservice}\" install $this->name $this->options";
225 225 if(DEBUG) {
226 226 echo "Command : $cmd<br/>";
227   - return ;
  227 + return true;
228 228 }
229 229 $response = $this->util->pexec($cmd);
230 230 return $response;
... ...
setup/wizard/lib/services/windowsService.php
... ... @@ -163,7 +163,7 @@ class windowsService extends Service {
163 163 * @return array
164 164 */
165 165 public function restart() {
166   - $response = $this->stop();
  166 + $this->stop();
167 167 sleep(1);
168 168 $this->start();
169 169 }
... ...
setup/wizard/lib/validation/luceneValidation.php
... ... @@ -264,7 +264,7 @@ class luceneValidation extends serviceValidation {
264 264 public function binaryChecks() {
265 265 if($this->util->javaSpecified()) {
266 266 $this->disableExtension = true; // Disable the use of the php bridge extension
267   - if($this->detSettings(true)) { // AutoDetect java settings
  267 + if($this->detSettings()) { // AutoDetect java settings
268 268 return true;
269 269 } else {
270 270 $this->specifyJava(); // Ask for settings
... ... @@ -274,16 +274,16 @@ class luceneValidation extends serviceValidation {
274 274 if($auto) {
275 275 return $auto;
276 276 } else {
277   - $auto = $this->useDetected(); // Check if auto detected java works
  277 + $auto = $this->detSettings(); // Check if auto detected java works
278 278 if($auto) {
279 279 $this->disableExtension = true; // Disable the use of the php bridge extension
280   - return $auto;
281 280 } else {
282 281 $this->specifyJava(); // Ask for settings
283 282 }
284 283 }
285 284 return $auto;
286 285 }
  286 + return false;
287 287 }
288 288  
289 289 /**
... ... @@ -363,7 +363,7 @@ class luceneValidation extends serviceValidation {
363 363 * @access private
364 364 * @return boolean
365 365 */
366   - private function detSettings($attempt = false) {
  366 + private function detSettings() {
367 367 $javaExecutable = $this->util->javaSpecified();// Retrieve java bin
368 368 if($javaExecutable == '') {
369 369 if($this->java == '') {
... ... @@ -388,7 +388,7 @@ class luceneValidation extends serviceValidation {
388 388 }
389 389  
390 390 function windowsReadJVFromFile($cmd) {
391   - $response = $this->util->pexec($cmd);
  391 + $this->util->pexec($cmd);
392 392 if(file_exists($this->outputDir.'outJV')) {
393 393 $version = file_get_contents($this->outputDir.'outJV');
394 394 if($version != '') {
... ... @@ -409,21 +409,23 @@ class luceneValidation extends serviceValidation {
409 409 } else {
410 410 $this->javaVersionWarning();
411 411 $this->javaCheck = 'cross_orange';
412   - if($attempt) {
  412 +// if($attempt) {
413 413 $this->javaExeMessage = "Incorrect java path specified";
414 414 $this->javaExeError = true;
415 415 $this->error[] = "Requires Java 1.5+ to be installed";
416   - }
  416 +// }
417 417  
418 418 return false;
419 419 }
420 420 }
  421 + return false;
421 422 }
422 423  
423 424 function unixReadJVFromFile($cmd) {
424   - $response = $this->util->pexec($cmd);
  425 + $this->util->pexec($cmd);
425 426 if(file_exists($this->outputDir.'outJV')) {
426 427 $tmp = file_get_contents($this->outputDir.'outJV');
  428 + $matches = false;
427 429 preg_match('/"(.*)"/',$tmp, $matches);
428 430 if($matches) {
429 431 if($matches[1] < $this->javaVersion) { // Check Version of java
... ... @@ -443,27 +445,17 @@ class luceneValidation extends serviceValidation {
443 445 } else {
444 446 $this->javaVersionWarning();
445 447 $this->javaCheck = 'cross_orange';
446   - if($attempt) {
  448 +// if($attempt) {
447 449 $this->javaExeMessage = "Incorrect java path specified";
448 450 $this->javaExeError = true;
449 451 $this->error[] = "Requires Java 1.5+ to be installed";
450   - }
  452 +// }
451 453  
452 454 return false;
453 455 }
454 456 }
455   - }
456   -
457   - /**
458   - * Attempt detection without logging errors
459   - *
460   - * @author KnowledgeTree Team
461   - * @param none
462   - * @access private
463   - * @return boolean
464   - */
465   - private function useDetected() {
466   - return $this->detSettings();
  457 +
  458 + return false;
467 459 }
468 460  
469 461 /**
... ...
setup/wizard/lib/validation/openofficeValidation.php
... ... @@ -92,7 +92,7 @@ class openofficeValidation extends serviceValidation {
92 92 * @access private
93 93 * @var mixed
94 94 */
95   - private $windowsLocations = array("C:\Program Files\OpenOffice.org 3\program", "C:\OpenOffice.org 3\program");
  95 + private $windowsLocations = array("\"C:\Program Files\OpenOffice.org 3\program\"", "\"C:\OpenOffice.org 3\program\"");
96 96  
97 97 /**
98 98 * Open Office unix locations
... ... @@ -103,7 +103,7 @@ class openofficeValidation extends serviceValidation {
103 103 */
104 104 private $unixLocations = array("/usr/bin/");
105 105  
106   - public function preset($options = null) {
  106 + public function preset() {
107 107 $this->specifyOpenOffice();
108 108 }
109 109  
... ...
setup/wizard/lib/validation/schedulerValidation.php
... ... @@ -92,36 +92,37 @@ class schedulerValidation extends serviceValidation {
92 92 public function binaryChecks() {
93 93 // TODO: Better detection
94 94 return true;
95   - $this->setPhp();
96   - if($this->util->phpSpecified()) {
97   - return $this->detPhpSettings();
98   - } else {
99   - $this->specifyPhp();// Ask for settings
100   - return false;
101   - }
  95 +// $this->setPhp();
  96 +// if($this->util->phpSpecified()) {
  97 +// return $this->detPhpSettings();
  98 +// } else {
  99 +// $this->specifyPhp();// Ask for settings
  100 +// return false;
  101 +// }
102 102 }
103 103  
104 104 function detPhpSettings() {
105 105 // TODO: Better php handling
106 106 return true;
107   - $phpExecutable = $this->util->phpSpecified();// Retrieve java bin
108   - $cmd = "$phpExecutable -version > ".$this->outputDir."/outPHP 2>&1 echo $!";
109   - $response = $this->util->pexec($cmd);
110   - if(file_exists($this->outputDir.'outPHP')) {
111   - $tmp = file_get_contents($this->outputDir.'outPHP');
112   - preg_match('/PHP/',$tmp, $matches);
113   - if($matches) {
114   - $this->phpCheck = 'tick';
115   -
116   - return true;
117   - } else {
118   - $this->phpCheck = 'cross_orange';
119   - $this->phpExeError = "PHP : Incorrect path specified";
120   - $this->error[] = "PHP executable required";
121   -
122   - return false;
123   - }
124   - }
  107 +// $phpExecutable = $this->util->phpSpecified();// Retrieve java bin
  108 +// $cmd = "$phpExecutable -version > ".$this->outputDir."/outPHP 2>&1 echo $!";
  109 +// $this->util->pexec($cmd);
  110 +// if(file_exists($this->outputDir.'outPHP')) {
  111 +// $tmp = file_get_contents($this->outputDir.'outPHP');
  112 +// $matches = false;
  113 +// preg_match('/PHP/',$tmp, $matches);
  114 +// if($matches) {
  115 +// $this->phpCheck = 'tick';
  116 +//
  117 +// return true;
  118 +// } else {
  119 +// $this->phpCheck = 'cross_orange';
  120 +// $this->phpExeError = "PHP : Incorrect path specified";
  121 +// $this->error[] = "PHP executable required";
  122 +//
  123 +// return false;
  124 +// }
  125 +// }
125 126 }
126 127  
127 128 /**
... ... @@ -137,13 +138,13 @@ class schedulerValidation extends serviceValidation {
137 138 }
138 139  
139 140 private function setPhp() {
  141 + $phpDir = $this->util->useZendPhp();
140 142 if($this->php != '') { // PHP Found
141 143 $this->phpCheck = 'tick';
142   - } elseif ($phpDir = $this->util->useZendPhp()) { // Use System Defined Settings
  144 + } elseif ($phpDir) { // Use System Defined Settings
143 145 $this->php = $phpDir;
144   - } else {
145   -
146 146 }
  147 +
147 148 $this->temp_variables['php']['location'] = $this->php;
148 149 }
149 150  
... ...
setup/wizard/lib/validation/steps/databaseTest.php 0 โ†’ 100644
  1 +<?php
  2 +
  3 +class databaseTest extends Test {
  4 + private $stepName = "database";
  5 + private $params = array();
  6 +
  7 + public function __construct() {
  8 + require_once(WIZARD_DIR."step.php");
  9 + require_once(WIZARD_DIR."installUtil.php");
  10 + require_once(WIZARD_DIR."path.php");
  11 + require_once(WIZARD_DIR."dbUtilities.php");
  12 + require_once(STEP_DIR."$this->stepName.php");
  13 + }
  14 +
  15 + /**
  16 + * Test database connectivity
  17 + *
  18 + * @author KnowledgeTree Team
  19 + * @param none
  20 + * @access public
  21 + * @return boolean
  22 + */
  23 + public function doAjaxTest($host, $uname, $dname) {
  24 + echo "$host, $uname, $dname";
  25 + die;
  26 + }
  27 +
  28 + public function doCreateSchema() {
  29 + $this->dhost = '127.0.0.1';
  30 + $this->duname = 'root';
  31 + $this->dpassword = 'root';
  32 + $this->dname = 'dms_install';
  33 + $this->dbbinary = 'mysql';
  34 + $this->dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname);
  35 + $this->createSchema();
  36 + echo 'Schema loaded<br>';
  37 + }
  38 +}
  39 +
  40 +
  41 +?>
0 42 \ No newline at end of file
... ...
setup/wizard/lib/validation/steps/test.php 0 โ†’ 100644
  1 +<?php
  2 +class Test {
  3 + private $ignore = array('action', 'step', 'type');
  4 +
  5 + function __construct() {
  6 +
  7 + }
  8 +
  9 +// function dispatch() {
  10 + /*
  11 + if(isset($_GET['action'])) {
  12 + $class = $_GET['step']."Test";
  13 + $func = $_GET['action'];
  14 + if($func != '') {
  15 + foreach ($_GET as $k=>$v) {
  16 + if(in_array($k, $this->ignore)) {
  17 + $temp[] = $_GET[$k];
  18 + unset($_GET[$k]);
  19 + }
  20 + }
  21 + $funcargs = array_slice($_GET,0);
  22 + require_once("$class.php");
  23 + $Test = new $class();
  24 + $func_call = strtoupper(substr($func,0,1)).substr($func,1);
  25 + $method = "do$func_call";
  26 + call_user_func_array(array($Test, $method), $funcargs);
  27 + }
  28 + }
  29 + */
  30 +// }
  31 +}
  32 +
  33 +?>
0 34 \ No newline at end of file
... ...
setup/wizard/path.php
... ... @@ -114,6 +114,7 @@
114 114 define('SYS_DIR', WIZARD_LIB."system".DS);
115 115 define('HELPER_DIR', WIZARD_LIB."helpers".DS);
116 116 define('VALID_DIR', WIZARD_LIB."validation".DS);
  117 + define('TEST_DIR', VALID_DIR."steps".DS);
117 118 // Define paths to system webroot
118 119 define('SYSTEM_DIR', $sys);
119 120 define('SYS_VAR_DIR', SYSTEM_DIR."var".DS);
... ...
setup/wizard/session.php
... ... @@ -228,13 +228,4 @@ class Session
228 228 }
229 229  
230 230 }
231   -
232   -if(isset($_GET['action'])) {
233   - $func = $_GET['action'];
234   - if($func != '') {
235   - $ses = new Session();
236   - $method = "$func";
237   - $ses->$method();
238   - }
239   -}
240 231 ?>
241 232 \ No newline at end of file
... ...
setup/wizard/step.php
... ... @@ -42,6 +42,15 @@
42 42 class Step
43 43 {
44 44 /**
  45 + * Salt to use in session
  46 + *
  47 + * @author KnowledgeTree Team
  48 + * @access private
  49 + * @var string
  50 + */
  51 + private $salt = 'installers';
  52 +
  53 + /**
45 54 * List of variables to be loaded to template
46 55 *
47 56 * @author KnowledgeTree Team
... ... @@ -73,7 +82,7 @@ class Step
73 82 *
74 83 * @author KnowledgeTree Team
75 84 * @access public
76   - * @var array
  85 + * @var boolean
77 86 */
78 87 protected $storeInSession = false;
79 88  
... ... @@ -82,7 +91,7 @@ class Step
82 91 *
83 92 * @author KnowledgeTree Team
84 93 * @access public
85   - * @var array
  94 + * @var boolean
86 95 */
87 96 protected $runInstall = false;
88 97  
... ... @@ -91,7 +100,7 @@ class Step
91 100 *
92 101 * @author KnowledgeTree Team
93 102 * @access public
94   - * @var string
  103 + * @var boolean
95 104 */
96 105 protected $order = false;
97 106  
... ... @@ -104,10 +113,15 @@ class Step
104 113 */
105 114 protected $silent = false;
106 115  
  116 + /**
  117 + * Display the confirmation page first
  118 + *
  119 + * @author KnowledgeTree Team
  120 + * @access public
  121 + * @var boolean
  122 + */
107 123 public $displayFirst = false;
108 124  
109   - private $salt = 'installers';
110   -
111 125 /**
112 126 * Reference to utility object
113 127 *
... ... @@ -115,7 +129,7 @@ class Step
115 129 * @access protected
116 130 * @var object
117 131 */
118   - public $util;
  132 + public $util = null;
119 133  
120 134 /**
121 135 * Reference to utility object
... ... @@ -124,12 +138,20 @@ class Step
124 138 * @access protected
125 139 * @var object
126 140 */
127   - public $dbhandler;
  141 + public $dbhandler = null;
128 142  
  143 + /**
  144 + * Constructs step object
  145 + *
  146 + * @author KnowledgeTree Team
  147 + * @access public
  148 + * @param none
  149 + */
129 150 public function __construct() {
130 151 $this->dbhandler = new dbUtilities();
131 152 $this->util = new InstallUtil();
132 153 }
  154 +
133 155 /**
134 156 * Returns step state
135 157 *
... ... @@ -142,6 +164,13 @@ class Step
142 164 return '';
143 165 }
144 166  
  167 + /**
  168 + * Returns display flag
  169 + *
  170 + * @author KnowledgeTree Team
  171 + * @access public
  172 + * @var boolean
  173 + */
145 174 public function displayFirst() {
146 175 return $this->displayFirst;
147 176 }
... ... @@ -183,30 +212,6 @@ class Step
183 212 }
184 213  
185 214 /**
186   - * Load default step values
187   - *
188   - * @author KnowledgeTree Team
189   - * @param none
190   - * @access public
191   - * @return void
192   - */
193   - public function loadDefaults() {
194   -
195   - }
196   -
197   - /**
198   - * Return default step values
199   - *
200   - * @author KnowledgeTree Team
201   - * @param none
202   - * @access public
203   - * @return array
204   - */
205   - public function getDefaults() {
206   - return array();
207   - }
208   -
209   - /**
210 215 * Checks if edit button has been clicked
211 216 *
212 217 * @author KnowledgeTree Team
... ...
setup/wizard/stepAction.php
... ... @@ -472,7 +472,7 @@ class stepAction {
472 472 * @access private
473 473 * @return void
474 474 */
475   - private function _loadValueToSession($class, $k, $v, $overwrite = false) {
  475 + private function _loadValueToSession($class, $k, $v) {
476 476 if($this->session != null) {
477 477 $this->session->setClass($class, $k, $v);
478 478 } else {
... ...
setup/wizard/steps/database.php
... ... @@ -40,16 +40,6 @@
40 40 * @version Version 0.1
41 41 */
42 42  
43   -if(isset($_GET['action'])) {
44   - $func = $_GET['action'];
45   - if($func != '') {
46   - require_once("../step.php");
47   - require_once("../installUtil.php");
48   - require_once("../path.php");
49   - require_once("../dbUtilities.php");
50   - }
51   -}
52   -
53 43 class database extends Step
54 44 {
55 45 /**
... ... @@ -719,9 +709,16 @@ class database extends Step
719 709 * @return boolean
720 710 */
721 711 private function createDmsUser() {
722   - return $this->parse_mysql_dump($this->util->sqlInstallDir()."user.sql");
723   - }
724   -
  712 + $user1 = "GRANT SELECT, INSERT, UPDATE, DELETE ON {$this->dname}.* TO {$this->dmsusername}@{$this->dhost} IDENTIFIED BY \"{$this->dmsuserpassword}\";";
  713 + $user2 = "GRANT ALL PRIVILEGES ON {$this->dname}.* TO {$this->dmsname}@{$this->dhost} IDENTIFIED BY \"{$this->dmspassword}\";";
  714 + if ($this->dbhandler->execute($user1) && $this->dbhandler->execute($user2)) {
  715 + return true;
  716 + } else {
  717 + $this->error['con'] = "Could not create users for database: {$this->dname}";
  718 + return false;
  719 + }
  720 + }
  721 +
725 722 /**
726 723 * Create schema
727 724 *
... ... @@ -803,17 +800,7 @@ class database extends Step
803 800 return $this->error;
804 801 }
805 802  
806   - /**
807   - * Test database connectivity
808   - *
809   - * @author KnowledgeTree Team
810   - * @param none
811   - * @access public
812   - * @return boolean
813   - */
814   - public function doAjaxTest($host, $uname, $dname) {
815   -
816   - }
  803 +
817 804  
818 805 /**
819 806 * Initialize errors to false
... ... @@ -829,25 +816,8 @@ class database extends Step
829 816 }
830 817 }
831 818  
832   - public function doCreateSchema() {
833   - $this->dhost = '127.0.0.1';
834   - $this->duname = 'root';
835   - $this->dpassword = 'root';
836   - $this->dname = 'dms_install';
837   - $this->dbbinary = 'mysql';
838   - $this->dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname);
839   - $this->createSchema();
840   - echo 'Schema loaded<br>';
841   - }
842   -}
843 819  
844   -if(isset($_GET['action'])) {
845   - $func = $_GET['action'];
846   - if($func != '') {
847   - $serv = new database();
848   - $func_call = strtoupper(substr($func,0,1)).substr($func,1);
849   - $method = "do$func_call";
850   - $serv->$method();
851   - }
852 820 }
  821 +
  822 +
853 823 ?>
854 824 \ No newline at end of file
... ...