diff --git a/setup/migrate/migrateUtil.php b/setup/migrate/migrateUtil.php
index 28fd474..9f8b573 100644
--- a/setup/migrate/migrateUtil.php
+++ b/setup/migrate/migrateUtil.php
@@ -62,15 +62,15 @@ class MigrateUtil extends InstallUtil {
public function error($error) {
$template_vars['error'] = $error;
$file = "templates/error.tpl";
- if (!file_exists($file)) {
- return false;
+ if (file_exists($file)) {
+ extract($template_vars); // Extract the vars to local namespace
+ ob_start();
+ include($file);
+ $contents = ob_get_contents();
+ ob_end_clean();
+ echo $contents;
}
- extract($template_vars); // Extract the vars to local namespace
- ob_start();
- include($file);
- $contents = ob_get_contents();
- ob_end_clean();
- echo $contents;
+ return false;
}
/**
diff --git a/setup/migrate/migrateWizard.php b/setup/migrate/migrateWizard.php
index 3b7b5bd..a03c2d1 100644
--- a/setup/migrate/migrateWizard.php
+++ b/setup/migrate/migrateWizard.php
@@ -52,17 +52,17 @@ function __autoload($class) { // Attempt and autoload classes
if ($class == "template") { // Load existing templating classes
require_once("../wizard/template.php");
require_once("../wizard/lib/helpers/htmlHelper.php");
- return ;
- }
- if(file_exists(WIZARD_DIR."$class.php")) {
- require_once(WIZARD_DIR."$class.php");
- } elseif (file_exists(STEP_DIR."$class.php")) {
- require_once(STEP_DIR."$class.php");
- } elseif (file_exists(WIZARD_LIB."$class.php")) {
- require_once(WIZARD_LIB."$class.php");
+
} else {
- return null;
+ if(file_exists(WIZARD_DIR."$class.php")) {
+ require_once(WIZARD_DIR."$class.php");
+ } elseif (file_exists(STEP_DIR."$class.php")) {
+ require_once(STEP_DIR."$class.php");
+ } elseif (file_exists(WIZARD_LIB."$class.php")) {
+ require_once(WIZARD_LIB."$class.php");
+ }
}
+ return true;
}
class MigrateWizard {
@@ -233,8 +233,6 @@ class MigrateWizard {
return true;
break;
}
-
- return $res;
}
/**
diff --git a/setup/migrate/migrater.php b/setup/migrate/migrater.php
index 249fa36..86f78f5 100644
--- a/setup/migrate/migrater.php
+++ b/setup/migrate/migrater.php
@@ -157,7 +157,7 @@ class Migrater {
$this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name);
} catch (Exception $e) {
$util = new MigrateUtil();
- $util->error("Error reading configuration file: $name");
+ $util->error("Error reading configuration file: $e");
exit();
}
}
@@ -431,8 +431,7 @@ class Migrater {
if($class->runMigrate()) { // Check if step needs to be migrated
$class->setDataFromSession($className); // Set Session Information
$class->setPostConfig(); // Set any posted variables
- $response = $class->migrateStep(); // Run migrate step
- // TODO : Break on error response
+ $class->migrateStep(); // Run migrate step
}
} else {
$util = new MigrateUtil();
diff --git a/setup/migrate/step.php b/setup/migrate/step.php
index 897b710..9188209 100644
--- a/setup/migrate/step.php
+++ b/setup/migrate/step.php
@@ -186,30 +186,6 @@ class Step
}
/**
- * Load default step values
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return void
- */
- public function loadDefaults() {
-
- }
-
- /**
- * Return default step values
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return array
- */
- public function getDefaults() {
- return array();
- }
-
- /**
* Checks if edit button has been clicked
*
* @author KnowledgeTree Team
diff --git a/setup/migrate/stepAction.php b/setup/migrate/stepAction.php
index 30724ed..e6ac993 100644
--- a/setup/migrate/stepAction.php
+++ b/setup/migrate/stepAction.php
@@ -229,12 +229,14 @@ class stepAction {
} else {
$this->_clearErrors($this->stepName); // Send Errors to session
}
- return $response;
} else {
$this->stepName = 'errors';
$this->action = $this->createStep();
$this->action->error = array('Class File Missing in Step Directory');
+ $response = '';
}
+
+ return $response;
}
/**
@@ -308,7 +310,7 @@ class stepAction {
$menu = '';
$active = false;
if($this->stepClassNames) {
- foreach ($this->stepClassNames as $k=>$step) {
+ foreach ($this->stepClassNames as $step) {
if($this->step_names[$step] != '') {
$item = $this->step_names[$step];
} else {
@@ -452,7 +454,7 @@ class stepAction {
* @access private
* @return void
*/
- private function _loadValueToSession($class, $k, $v, $overwrite = false) {
+ private function _loadValueToSession($class, $k, $v) {
if($this->session != null) {
$this->session->setClass($class, $k, $v);
} else {
@@ -502,8 +504,7 @@ class stepAction {
* @access private
* @return void
*/
- private function _loadErrorToSession($class, $k, $v, $overwrite = false) {
- $k = "errors";
+ private function _loadErrorToSession($class, $k = "errors", $v) {
if($this->session != null) {
$this->session->setClassError($class, $k, $v);
} else {
diff --git a/setup/migrate/steps/migrateDatabase.php b/setup/migrate/steps/migrateDatabase.php
index 9eb236f..d0eaaa3 100644
--- a/setup/migrate/steps/migrateDatabase.php
+++ b/setup/migrate/steps/migrateDatabase.php
@@ -122,19 +122,17 @@ class migrateDatabase extends Step
$manual = false; // If file was exported manually
$dbSettings = $installation['dbSettings'];
$location = $installation['location'];
- $uname = $this->temp_variables['duname'];
- $pwrd = $this->temp_variables['dpassword'];
$port = $this->util->getPort($location);
$tmpFolder = $this->resolveTempDir();
if(WINDOWS_OS) {
$termOrBash = "command prompt window";
- $exe = "\"$location\mysql\bin\mysqldump.exe\""; // Location of dump
+ $exe = "\"$location".DS."mysql".DS."bin".DS."mysqldump.exe\""; // Location of dump
} else {
$termOrBash = "terminal window";
$exe = "'$location/mysql/bin/mysqldump'"; // Location of dump
}
$date = date('Y-m-d-H-i-s');
- if(isset($database)) {
+ if(isset($database['manual_export'])) {
$sqlFile = $database['manual_export'];
if(file_exists($sqlFile)) {
$manual = true;
@@ -147,7 +145,7 @@ class migrateDatabase extends Step
if(!$manual) { // Try to export database
$sqlFile = $tmpFolder."/kt-backup-$date.sql";
$cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.$dbName.' > '.$sqlFile;
-// $response = $this->util->pexec($cmd);
+ $this->util->pexec($cmd);
}
if(file_exists($sqlFile)) {
$fileContents = file_get_contents($sqlFile);
@@ -157,10 +155,14 @@ class migrateDatabase extends Step
}
}
// Handle failed dump
- $sqlFile = "/tmp/kt-backup-$date.sql"; // Use tmp instead due to permissions
+ if(WINDOWS_OS) {
+ $sqlFile = "\"C:\kt-backup-$date.sql\""; // Use tmp instead due to permissions
+ } else {
+ $sqlFile = "/tmp/kt-backup-$date.sql"; // Use tmp instead due to permissions
+ }
$cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.$dbName.' > '.$sqlFile;
- $this->error[]['error'] = "Could not export database:";
- $this->error[]['msg'] = "Execute the following command in a $termOrBash.";
+ $this->error[]['error'] = "Could not export database";
+ $this->error[]['msg'] = "Execute the following command in a $termOrBash:";
$this->error[]['cmd'] = $cmd;
$this->temp_variables['manual_export'] = $sqlFile;
diff --git a/setup/migrate/steps/migrateInstallation.php b/setup/migrate/steps/migrateInstallation.php
index 07230bb..a7cea9b 100644
--- a/setup/migrate/steps/migrateInstallation.php
+++ b/setup/migrate/steps/migrateInstallation.php
@@ -162,6 +162,7 @@ class migrateInstallation extends step
if($this->foundVersion < $this->supportedVersion) {
$this->versionError = true;
$this->error[] = "KT installation needs to be 3.6.1 or higher";
+ return false;
} else {
return true;
}
@@ -222,6 +223,8 @@ class migrateInstallation extends step
} else {
$this->error[] = "Please Enter a Location";
}
+
+ return false;
}
private function loadConfig($path) {
@@ -242,7 +245,6 @@ class migrateInstallation extends step
}
$this->ktSettings = array('fileSystemRoot'=> $froot,
);
- $urlPaths = $ini->getSection('urls');
$varDir = $froot.DS.'var';
$this->urlPaths = array(array('name'=> 'Var Directory', 'path'=> $varDir),
array('name'=> 'Log Directory', 'path'=> $varDir.DS.'log'),
diff --git a/setup/migrate/steps/migrateServices.php b/setup/migrate/steps/migrateServices.php
index b0bc18e..50f9e5b 100644
--- a/setup/migrate/steps/migrateServices.php
+++ b/setup/migrate/steps/migrateServices.php
@@ -202,11 +202,11 @@ class migrateServices extends Step
*/
public function unixStop() {
$cmd = $this->conf['location']."/dmsctl.sh stop lucene";
- $res = $this->util->pexec($cmd);
+ $this->util->pexec($cmd);
$cmd = $this->conf['location']."/dmsctl.sh stop scheduler";
- $res = $this->util->pexec($cmd);
+ $this->util->pexec($cmd);
$cmd = $this->conf['location']."/dmsctl.sh stop soffice";
- $res = $this->util->pexec($cmd);
+ $this->util->pexec($cmd);
}
/**
@@ -215,11 +215,11 @@ class migrateServices extends Step
*/
public function windowsStop() {
$cmd = "sc delete KTLucene";
- $res = $this->util->pexec($cmd);
+ $this->util->pexec($cmd);
$cmd = "sc delete KTScheduler";
- $res = $this->util->pexec($cmd);
+ $this->util->pexec($cmd);
$cmd = "sc delete KTOpenoffice";
- $res = $this->util->pexec($cmd);
+ $this->util->pexec($cmd);
}
/**
@@ -233,7 +233,7 @@ class migrateServices extends Step
$serv->load();
$sStatus = $serv->status();
if($sStatus != '') {
- $res = $serv->uninstall();
+ $serv->uninstall();
}
}
}
diff --git a/setup/upgrade/step.php b/setup/upgrade/step.php
index 49890fd..0b8c103 100644
--- a/setup/upgrade/step.php
+++ b/setup/upgrade/step.php
@@ -172,30 +172,6 @@ class Step
public function getWarnings() {
return $this->warnings;
}
-
- /**
- * Load default step values
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return void
- */
- public function loadDefaults() {
-
- }
-
- /**
- * Return default step values
- *
- * @author KnowledgeTree Team
- * @param none
- * @access public
- * @return array
- */
- public function getDefaults() {
- return array();
- }
/**
* Checks if edit button has been clicked
diff --git a/setup/upgrade/stepAction.php b/setup/upgrade/stepAction.php
index 438df77..48083f0 100644
--- a/setup/upgrade/stepAction.php
+++ b/setup/upgrade/stepAction.php
@@ -229,12 +229,14 @@ class stepAction {
} else {
$this->_clearErrors($this->stepName); // Send Errors to session
}
- return $response;
} else {
$this->stepName = 'errors';
$this->action = $this->createStep();
$this->action->error = array('Class File Missing in Step Directory');
+ $response = '';
}
+
+ return $response;
}
/**
@@ -308,7 +310,7 @@ class stepAction {
$menu = '';
$active = false;
if($this->stepClassNames) {
- foreach ($this->stepClassNames as $k=>$step) {
+ foreach ($this->stepClassNames as $step) {
if($this->step_names[$step] != '') {
$item = $this->step_names[$step];
} else {
@@ -452,7 +454,7 @@ class stepAction {
* @access private
* @return void
*/
- private function _loadValueToSession($class, $k, $v, $overwrite = false) {
+ private function _loadValueToSession($class, $k, $v) {
if($this->session != null) {
$this->session->setClass($class, $k, $v);
} else {
@@ -502,8 +504,7 @@ class stepAction {
* @access private
* @return void
*/
- private function _loadErrorToSession($class, $k, $v, $overwrite = false) {
- $k = "errors";
+ private function _loadErrorToSession($class, $k = "errors", $v) {
if($this->session != null) {
$this->session->setClassError($class, $k, $v);
} else {
diff --git a/setup/upgrade/steps/upgradeBackup.php b/setup/upgrade/steps/upgradeBackup.php
index 6977416..ba5219e 100644
--- a/setup/upgrade/steps/upgradeBackup.php
+++ b/setup/upgrade/steps/upgradeBackup.php
@@ -120,7 +120,7 @@ class upgradeBackup extends Step {
if (is_file($dir . '/mysqladmin') || is_file($dir . '/mysqladmin.exe'))
{
- $curdir=getcwd();
+// $curdir=getcwd();
chdir($dir);
$handle = popen($stmt['cmd'], 'r');
@@ -198,7 +198,7 @@ class upgradeBackup extends Step {
$adminUser = $oKTConfig->get('db/dbAdminUser');
$adminPwd = $oKTConfig->get('db/dbAdminPass');
- $dbHost = $oKTConfig->get('db/dbHost');
+// $dbHost = $oKTConfig->get('db/dbHost');
$dbName = $oKTConfig->get('db/dbName');
$dbPort = trim($oKTConfig->get('db/dbPort'));
diff --git a/setup/upgrade/steps/upgradeDatabase.php b/setup/upgrade/steps/upgradeDatabase.php
index f58f571..945db30 100644
--- a/setup/upgrade/steps/upgradeDatabase.php
+++ b/setup/upgrade/steps/upgradeDatabase.php
@@ -144,10 +144,10 @@ class upgradeDatabase extends Step
$this->readConfig(KTConfig::getConfigFilename());
if($this->dbSettings['dbPort'] == '') {
- $con = $this->dbhandler->load($this->dbSettings['dbHost'], $this->dbSettings['dbUser'],
+ $this->dbhandler->load($this->dbSettings['dbHost'], $this->dbSettings['dbUser'],
$this->dbSettings['dbPass'], $this->dbSettings['dbName']);
} else {
- $con = $this->dbhandler->load($this->dbSettings['dbHost'].":".$this->dbSettings['dbPort'], $this->dbSettings['dbUser'],
+ $this->dbhandler->load($this->dbSettings['dbHost'].":".$this->dbSettings['dbPort'], $this->dbSettings['dbUser'],
$this->dbSettings['dbPass'], $this->dbSettings['dbName']);
}
@@ -285,7 +285,8 @@ class upgradeDatabase extends Step
}
$res = $this->performAllUpgrades();
- if (PEAR::isError($res) || PEAR::isError($pres)) {
+// if (PEAR::isError($res) || PEAR::isError($pres)) {
+ if (PEAR::isError($res)) {
$errors = true;
// TODO instantiate error details hideable section?
$this->temp_variables['upgradeStatus'] = 'Database upgrade failed
@@ -300,7 +301,8 @@ class upgradeDatabase extends Step
}
$post_pres = $this->performPostUpgradeActions();
- if (PEAR::isError($post_res)) {
+// if (PEAR::isError($post_res)) {
+ if (PEAR::isError($post_pres)) {
$errors = true;
$this->temp_variables['postUpgrade'] = 'Post-Upgrade actions failed.';
}
@@ -334,7 +336,7 @@ class upgradeDatabase extends Step
// Ensure all plugins are re-registered.
$sql = "TRUNCATE plugin_helper";
- $res = DBUtil::runQuery($sql);
+ DBUtil::runQuery($sql);
// Clear out all caches and proxies - they need to be regenerated with the new code
$proxyDir = $default->proxyCacheDirectory;
diff --git a/setup/upgrade/steps/upgradeRestore.php b/setup/upgrade/steps/upgradeRestore.php
index 270978f..25a6aa8 100644
--- a/setup/upgrade/steps/upgradeRestore.php
+++ b/setup/upgrade/steps/upgradeRestore.php
@@ -111,14 +111,14 @@ class upgradeRestore extends Step {
private function restoreDatabase()
{
$this->temp_variables['restore'] = true;
- $status = $_SESSION['backupStatus'];
+// $status = $_SESSION['backupStatus'];
$filename = $_SESSION['backupFile'];
$stmt = $this->util->create_restore_stmt($filename);
$dir = $stmt['dir'];
if (is_file($dir . '/mysql') || is_file($dir . '/mysql.exe'))
{
- $curdir=getcwd();
+// $curdir=getcwd();
chdir($dir);
$ok=true;
@@ -181,9 +181,11 @@ class upgradeRestore extends Step {
$dir = $this->util->resolveTempDir();
$files = array();
- if ($dh = opendir($dir))
+ $dh = opendir($dir);
+ if ($dh)
{
- while (($file = readdir($dh)) !== false)
+ $file = readdir($dh);
+ while ($file !== false)
{
if (!preg_match('/kt-backup.+\.sql/',$file)) {
continue;
@@ -217,7 +219,7 @@ class upgradeRestore extends Step {
return;
}
- $status = $_SESSION['backupStatus'];
+// $status = $_SESSION['backupStatus'];
$filename = $_SESSION['backupFile'];
$stmt = $this->util->create_restore_stmt($filename);
diff --git a/setup/upgrade/steps/upgradeWelcome.php b/setup/upgrade/steps/upgradeWelcome.php
index 0082985..c07b07f 100644
--- a/setup/upgrade/steps/upgradeWelcome.php
+++ b/setup/upgrade/steps/upgradeWelcome.php
@@ -81,7 +81,7 @@ class upgradeWelcome extends step {
}
private function checkPassword($username, $password) {
- global $default;
+// global $default;
$sTable = KTUtil::getTableName('users');
$sQuery = "SELECT count(*) AS match_count FROM $sTable WHERE username = ? AND password = ?";
diff --git a/setup/upgrade/upgradeUtil.php b/setup/upgrade/upgradeUtil.php
index 3bc2ea5..a2b571b 100644
--- a/setup/upgrade/upgradeUtil.php
+++ b/setup/upgrade/upgradeUtil.php
@@ -64,15 +64,16 @@ class UpgradeUtil extends InstallUtil {
public function error($error) {
$template_vars['error'] = $error;
$file = "templates/error.tpl";
- if (!file_exists($file)) {
- return false;
+ if (file_exists($file)) {
+ extract($template_vars); // Extract the vars to local namespace
+ ob_start();
+ include($file);
+ $contents = ob_get_contents();
+ ob_end_clean();
+ echo $contents;
}
- extract($template_vars); // Extract the vars to local namespace
- ob_start();
- include($file);
- $contents = ob_get_contents();
- ob_end_clean();
- echo $contents;
+
+ return false;
}
public function loadInstallIni($path) {
@@ -99,15 +100,16 @@ class UpgradeUtil extends InstallUtil {
}
}
$file = "templates/" . $template;
- if (!file_exists($file)) {
- return false;
+ if (file_exists($file)) {
+ extract($template_vars); // Extract the vars to local namespace
+ ob_start();
+ include($file);
+ $contents = ob_get_contents();
+ ob_end_clean();
+ echo $contents;
}
- extract($template_vars); // Extract the vars to local namespace
- ob_start();
- include($file);
- $contents = ob_get_contents();
- ob_end_clean();
- echo $contents;
+
+ return false;
}
/**
@@ -133,7 +135,7 @@ class UpgradeUtil extends InstallUtil {
$adminUser = $oKTConfig->get('db/dbAdminUser');
$adminPwd = $oKTConfig->get('db/dbAdminPass');
- $dbHost = $oKTConfig->get('db/dbHost');
+// $dbHost = $oKTConfig->get('db/dbHost');
$dbName = $oKTConfig->get('db/dbName');
$dbPort = trim($oKTConfig->get('db/dbPort'));
if ($dbPort=='' || $dbPort=='default')$dbPort = get_cfg_var('mysql.default_port');
@@ -158,7 +160,7 @@ class UpgradeUtil extends InstallUtil {
$mechanism="--port=\"$dbPort\"";
}
- $tmpdir = $this->resolveTempDir();
+// $tmpdir = $this->resolveTempDir();
$stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"
";
$stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"
";
@@ -193,11 +195,13 @@ class UpgradeUtil extends InstallUtil {
}
$oKTConfig =& KTConfig::getSingleton();
- $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir);
+// $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir);
+ $mysqldir = $oKTConfig->get('backup/mysqlDirectory');
$dirs[] = $mysqldir;
if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false) {
- $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin');
+// $dirs [] = realpath(dirname($FILE) . '/../../mysql/bin');
+ $dirs [] = realpath('/../../mysql/bin');
}
foreach($dirs as $dir)
diff --git a/setup/upgrade/upgradeWizard.php b/setup/upgrade/upgradeWizard.php
index fa2b6b3..b05ca5c 100644
--- a/setup/upgrade/upgradeWizard.php
+++ b/setup/upgrade/upgradeWizard.php
@@ -52,17 +52,17 @@ function __autoload($class) { // Attempt and autoload classes
if ($class == "template") { // Load existing templating classes
require_once("../wizard/template.php");
require_once("../wizard/lib/helpers/htmlHelper.php");
- return ;
- }
- if(file_exists(WIZARD_DIR."$class.php")) {
- require_once(WIZARD_DIR."$class.php");
- } elseif (file_exists(STEP_DIR."$class.php")) {
- require_once(STEP_DIR."$class.php");
- } elseif (file_exists(WIZARD_LIB."$class.php")) {
- require_once(WIZARD_LIB."$class.php");
} else {
- return null;
+ if(file_exists(WIZARD_DIR."$class.php")) {
+ require_once(WIZARD_DIR."$class.php");
+ } elseif (file_exists(STEP_DIR."$class.php")) {
+ require_once(STEP_DIR."$class.php");
+ } elseif (file_exists(WIZARD_LIB."$class.php")) {
+ require_once(WIZARD_LIB."$class.php");
+ }
}
+
+ return true;
}
class UpgradeWizard {
@@ -191,26 +191,7 @@ class UpgradeWizard {
* @return mixed
*/
public function systemChecks() {
- // for now we don't write to any of these locations
- return true;
-
- $res = $this->util->checkStructurePermissions();
- if($res === true) return $res;
- switch ($res) {
- case "wizard":
- $this->util->error("Upgrader directory is not writable (KT_Installation_Directory/setup/upgrade/)");
- return 'Upgrader directory is not writable (KT_Installation_Directory/setup/upgrade/)';
- break;
- case "/":
- $this->util->error("System root is not writable (KT_Installation_Directory/)");
- return "System root is not writable (KT_Installation_Directory/)";
- break;
- default:
- return true;
- break;
- }
-
- return $res;
+ return true; // for now we don't write to any locations
}
/**
diff --git a/setup/upgrade/upgrader.php b/setup/upgrade/upgrader.php
index 30dedf9..55bdffb 100644
--- a/setup/upgrade/upgrader.php
+++ b/setup/upgrade/upgrader.php
@@ -157,7 +157,7 @@ class Upgrader {
$this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name);
} catch (Exception $e) {
$util = new UpgradeUtil();
- $util->error("Error reading configuration file: $name");
+ $util->error("Error reading configuration file: $e");
exit();
}
}
@@ -431,8 +431,7 @@ class Upgrader {
if($class->runUpgrade()) { // Check if step needs to be upgraded
$class->setDataFromSession($className); // Set Session Information
$class->setPostConfig(); // Set any posted variables
- $response = $class->upgradeStep(); // Run upgrade step
- // TODO : Break on error response
+ $class->upgradeStep(); // Run upgrade step
}
} else {
$util = new UpgradeUtil();
diff --git a/setup/wizard/iniUtilities.php b/setup/wizard/iniUtilities.php
index b036724..c9dc4fa 100644
--- a/setup/wizard/iniUtilities.php
+++ b/setup/wizard/iniUtilities.php
@@ -63,11 +63,12 @@ class iniUtilities {
return false;
}
$date = date('YmdHis');
-
$backupFile = $iniFile . '.' .$date;
if (is_writeable($backupFile)) {
file_put_contents($backupFile, $content);
}
+
+ return true;
}
function read($iniFile) {
@@ -153,13 +154,20 @@ class iniUtilities {
}
function itemExists($checkSection, $checkItem) {
-
+/*
+ foreach ($items as $key => $value) {
+ if($key == $checkItem) {
+ return true;
+ }
+ }
+*/
$this->exists = '';
foreach($this->cleanArray as $section => $items) {
if($section == $checkSection) {
$this->exists = 'section';
- foreach ($items as $key => $value) {
- if($key == $checkItem) {
+ $items = array_flip($items);
+ foreach ($items as $value) {
+ if($value == $checkItem) {
return true;
}
}
diff --git a/setup/wizard/installUtil.php b/setup/wizard/installUtil.php
index 25452f5..2e59356 100644
--- a/setup/wizard/installUtil.php
+++ b/setup/wizard/installUtil.php
@@ -70,15 +70,16 @@ class InstallUtil {
public function error($error) {
$template_vars['error'] = $error;
$file = "templates/error.tpl";
- if (!file_exists($file)) {
- return false;
+ if (file_exists($file)) {
+ extract($template_vars); // Extract the vars to local namespace
+ ob_start();
+ include($file);
+ $contents = ob_get_contents();
+ ob_end_clean();
+ echo $contents;
}
- extract($template_vars); // Extract the vars to local namespace
- ob_start();
- include($file);
- $contents = ob_get_contents();
- ob_end_clean();
- echo $contents;
+
+ return false;
}
/**
* Check if system needs to be installed
@@ -165,7 +166,8 @@ class InstallUtil {
return $url;
}
if (!empty($protocol)) {
- $url = $protocol .':'. end($array = explode(':', $url, 2));
+ $array = explode(':', $url, 2);
+ $url = $protocol .':'. end($array);
}
if (!empty($port)) {
$url = preg_replace('!^(([a-z0-9]+)://[^/:]+)(:[\d]+)?!i',
@@ -321,13 +323,15 @@ class InstallUtil {
while (($file = readdir($dh)) !== false) {
if($file != '.' && $file != '..') {
$fullpath = $path.'/'.$file;
- if(is_link($fullpath))
+ if(is_link($fullpath)) {
return false;
- elseif(!is_dir($fullpath)) {
+ } elseif(!is_dir($fullpath)) {
$perms = substr(sprintf('%o', fileperms($fullpath)), -4);
- if($perms != $filemode)
- if (!chmod($fullpath, $filemode))
+ if($perms != $filemode) {
+ if (!chmod($fullpath, $filemode)) {
return false;
+ }
+ }
} elseif(!$this->chmodRecursive($fullpath, $filemode))
return false;
}
@@ -354,7 +358,8 @@ class InstallUtil {
*/
public function canWriteFile($filename) {
$fh = fopen($filename, "w+");
- if($fr = fwrite($fh, 'test') === false) {
+ $fr = fwrite($fh, 'test');
+ if($fr === false) {
return false;
}
@@ -372,9 +377,9 @@ class InstallUtil {
*/
public function javaBridge() {
try {
- $javaSystem = new Java('java.lang.System');
+ new Java('java.lang.System');
} catch (JavaException $e) {
- return false;
+ return $e;
}
return true;
}
@@ -763,6 +768,7 @@ class InstallUtil {
* @return string
*/
public function installEnvironment() {
+ $matches = false;
preg_match('/Zend/', SYSTEM_DIR, $matches); // Install Type
if($matches) {
return 'Zend';
@@ -792,7 +798,7 @@ class InstallUtil {
array_pop($sysdir);
array_pop($sysdir);
$zendsys = '';
- foreach ($sysdir as $k=>$v) {
+ foreach ($sysdir as $v) {
$zendsys .= $v.DS;
}
return $zendsys."ZendServer".DS."bin".DS;
@@ -815,15 +821,16 @@ class InstallUtil {
if(WINDOWS_OS) { // Mysql bin [Windows]
$serverPaths = explode(';',$_SERVER['PATH']);
foreach ($serverPaths as $apath) {
+ $matches = false;
preg_match('/mysql/i', $apath, $matches);
if($matches) {
return $apath.DS;
break;
}
}
- } else {
- return "mysql"; // Assume its linux and can be executed from command line
}
+
+ return "mysql"; // Assume its linux and can be executed from command line
}
public function sqlInstallDir() {
diff --git a/setup/wizard/installWizard.php b/setup/wizard/installWizard.php
index c48aac0..986d706 100644
--- a/setup/wizard/installWizard.php
+++ b/setup/wizard/installWizard.php
@@ -62,9 +62,13 @@ function __autoload($class) { // Attempt and autoload classes
} else {
if(preg_match('/Helper/', $class)) {
require_once(HELPER_DIR."$class.php");
+ } else if(preg_match('/Test/i', $class)) {
+ if($_GET['step'] != '') {
+ require_once(TEST_DIR."$class.php");
+ }
}
- return null;
}
+ return true;
}
class InstallWizard {
@@ -96,6 +100,15 @@ class InstallWizard {
protected $util = null;
/**
+ * Step name
+ *
+ * @author KnowledgeTree Team
+ * @access protected
+ * @var mixed
+ */
+ protected $stepName = '';
+
+ /**
* Constructs installation wizard object
*
* @author KnowledgeTree Team
@@ -183,15 +196,27 @@ class InstallWizard {
}
/**
- * Bypass and force an install
+ * Is the step being accessed directly
*
* @author KnowledgeTree Team
- * @access private
+ * @access public
* @param none
* @return boolean
*/
- private function bypass() {
-
+ public function isActionOnStep() {
+ return $this->stepName;
+ }
+
+ /**
+ * Set step being accessed directly
+ *
+ * @author KnowledgeTree Team
+ * @access public
+ * @param none
+ * @return boolean
+ */
+ private function setStep($stepName) {
+ $this->stepName = $stepName;
}
/**
@@ -231,6 +256,9 @@ class InstallWizard {
if(isset($_GET['bypass'])) {
$this->setBypass($_GET['bypass']);
}
+ if(isset($_GET['step'])) {
+ $this->setStep($_GET['step']);
+ }
if(isset($_GET['debug'])) {
$this->setDebugLevel($_GET['debug']);
} else {
@@ -263,8 +291,6 @@ class InstallWizard {
return true;
break;
}
-
- return $res;
}
/**
@@ -278,10 +304,14 @@ class InstallWizard {
public function dispatch() {
$this->load();
if($this->getBypass() === "1") { // Helper to force install
- $this->removeInstallFile(); // TODO: Remove
+ $this->removeInstallFile();
} elseif ($this->getBypass() === "0") {
$this->createInstallFile();
}
+ if($this->isActionOnStep()) { // Testing purposes
+ $testStepClass = $this->stepName."Test";
+ new $testStepClass();
+ }
if(!$this->isSystemInstalled()) { // Check if the systems not installed
if($this->util->migrationSpecified()) { // Check if the migrator needs to be accessed
$this->util->redirect('../migrate');
diff --git a/setup/wizard/installer.php b/setup/wizard/installer.php
index e3ae105..aa4e06e 100644
--- a/setup/wizard/installer.php
+++ b/setup/wizard/installer.php
@@ -157,7 +157,7 @@ class Installer {
$this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name);
} catch (Exception $e) {
$util = new InstallUtil();
- $util->error("Error reading configuration file: $name");
+ $util->error("Error reading configuration file: $e");
exit();
}
}
@@ -431,8 +431,7 @@ class Installer {
if($class->runInstall()) { // Check if step needs to be installed
$class->setDataFromSession($className); // Set Session Information
$class->setPostConfig(); // Set any posted variables
- $response = $class->installStep(); // Run install step
- // TODO : Break on error response
+ $class->installStep(); // Run install step
}
} else {
$util = new InstallUtil();
diff --git a/setup/wizard/lib/helpers/htmlHelper.php b/setup/wizard/lib/helpers/htmlHelper.php
index 50150b5..d2a6565 100644
--- a/setup/wizard/lib/helpers/htmlHelper.php
+++ b/setup/wizard/lib/helpers/htmlHelper.php
@@ -41,7 +41,7 @@
*/
class htmlHelper {
- var $tags = array(
+ private $tags = array(
'meta' => '',
'metalink' => '',
'link' => '%s',
@@ -96,76 +96,76 @@ class htmlHelper {
'error' => '
';
print_r(array('service' => $this->name, 'display' => $this->name, 'path' => $this->getSchedulerScriptPath()));
echo '';
- return ;
+ return true;
}
$response = win32_create_service(array(
'service' => $this->name,
@@ -224,7 +224,7 @@ class windowsScheduler extends windowsService {
$cmd = "\"{$this->winservice}\" install $this->name $this->options";
if(DEBUG) {
echo "Command : $cmd