Commit 347ab714fa27aa955281a1f21c3ab82f44354445

Authored by Paul Barrett
2 parents 9ba18b37 713eeb8b

Merge branch 'edge' of github.com:ktgit/knowledgetree into edge

setup/migrate/migrateWizard.php
... ... @@ -177,7 +177,7 @@ class MigrateWizard {
177 177 * @return void
178 178 */
179 179 private function createMigrateFile() {
180   - @touch("migrate");
  180 + touch("migrate");
181 181 }
182 182  
183 183 /**
... ... @@ -189,7 +189,7 @@ class MigrateWizard {
189 189 * @return void
190 190 */
191 191 private function removeMigrateFile() {
192   - @unlink("migrate");
  192 + unlink("migrate");
193 193 }
194 194  
195 195 /**
... ...
setup/migrate/migrater.php
... ... @@ -413,7 +413,7 @@ class Migrater {
413 413 * @return void
414 414 */
415 415 private function _completeMigrate() {
416   - @touch("migrate");
  416 + touch("migrate");
417 417 }
418 418  
419 419 /**
... ...
setup/migrate/steps/migrateDatabase.php
... ... @@ -117,6 +117,7 @@ class migrateDatabase extends Step
117 117 }
118 118 }
119 119 }
  120 + $noFile = false;
120 121 $installation = $this->getDataFromSession("installation"); // Get installation directory
121 122 $manual = false; // If file was exported manually
122 123 $dbSettings = $installation['dbSettings'];
... ... @@ -125,7 +126,7 @@ class migrateDatabase extends Step
125 126 $tmpFolder = $this->resolveTempDir();
126 127 if(WINDOWS_OS) {
127 128 $termOrBash = "command prompt window";
128   - $exe = "$location".DS."mysql".DS."bin".DS."mysqldump.exe".DS;
  129 + $exe = "\"$location".DS."mysql".DS."bin".DS."mysqldump.exe\"";
129 130 } else {
130 131 $termOrBash = "terminal window";
131 132 $exe = "\"$location".DS."mysql".DS."bin".DS."mysqldump\""; // Location of dump
... ... @@ -153,23 +154,20 @@ class migrateDatabase extends Step
153 154 return true;
154 155 }
155 156 }
  157 + $noFile = true;
156 158 // Handle failed dump
157 159 if(WINDOWS_OS) {
158 160 // Could be permissions, check error code.
159   - if($response['ret'] == 2) {
160   -
161   - } else {
  161 + if(!$noFile) {
162 162 $sqlFile = "C:\\kt-backup-$date.sql"; // Use tmp instead due to permissions
163 163 }
164 164 } else {
165   - if($response['ret'] == 2) {
166   -
167   - } else {
  165 + if(!$noFile) {
168 166 $sqlFile = "/tmp/kt-backup-$date.sql"; // Use tmp instead due to permissions
169 167 }
170 168 }
171 169 $cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.$dbName.' > '.$sqlFile;
172   - if($response['ret'] == 2) {
  170 + if($noFile) {
173 171 $this->error[]['error'] = "Could not connect to the KnowledgeTree Database";
174 172 $this->error[]['msg'] = "Make sure all KnowledgeTree Services are running.";
175 173 $this->error[]['cmd'] = "<p class=\"description\">Click <b>Next</b> after resolving the above errors.</p>";
... ... @@ -207,6 +205,7 @@ class migrateDatabase extends Step
207 205 * @return void
208 206 */
209 207 private function setDetails() {
  208 + $this->createMigrateFile(); // create lock file to indicate migration mode
210 209 $database = $this->getDataFromSession("database");
211 210 if(isset($database['dumpLocation'])) {
212 211 if(!empty($database['dumpLocation'])) {
... ... @@ -219,7 +218,7 @@ class migrateDatabase extends Step
219 218 $this->temp_variables['duname'] = $this->getPostSafe('duname');
220 219 $this->temp_variables['dpassword'] = $this->getPostSafe('dpassword');
221 220 $this->temp_variables['dumpLocation'] = $this->getPostSafe('dumpLocation');
222   - $this->createMigrateFile(); // create lock file to indicate migration mode
  221 +
223 222 return true;
224 223 }
225 224  
... ... @@ -231,7 +230,7 @@ class migrateDatabase extends Step
231 230 * @return void
232 231 */
233 232 private function createMigrateFile() {
234   - @touch(SYSTEM_DIR.'var'.DS.'bin'.DS."migrate.lock");
  233 + touch(SYSTEM_DIR.'var'.DS.'bin'.DS."migrate.lock");
235 234 }
236 235  
237 236 /**
... ...
setup/migrate/steps/migrateServices.php
... ... @@ -272,7 +272,9 @@ class migrateServices extends Step
272 272 $this->temp_variables['services'][$serv->getName()]['class'] = $state;
273 273 $this->temp_variables['services'][$serv->getName()]['name'] = $serv->getName();
274 274 }
275   - $this->checkMysql();
  275 + if(!$this->checkMysql()) {
  276 + return false;
  277 + }
276 278 if ($this->serviceCheck != 'tick') {
277 279 return false;
278 280 }
... ... @@ -292,10 +294,12 @@ class migrateServices extends Step
292 294 $this->temp_variables['services']['KTMysql']['name'] = "KTMysql";
293 295 $this->temp_variables['services']['KTMysql']['msg'] = "Service Running";
294 296 $this->error[] = "Service : KTMysql running.<br/>";
  297 + return false;
295 298 } else {
296 299 $this->temp_variables['services']['KTMysql']['class'] = "tick";
297 300 $this->temp_variables['services']['KTMysql']['name'] = "KTMysql";
298 301 $this->temp_variables['services']['KTMysql']['msg'] = "Service has been uninstalled";
  302 + return true;
299 303 }
300 304 }
301 305  
... ...
setup/migrate/templates/installation.tpl
... ... @@ -33,7 +33,7 @@
33 33 </p>
34 34 <p class="empty_space">
35 35 <small>
36   - Make sure that the services are running for that installation.
  36 + Make sure that the KnowledgeTree services are running.
37 37 </small>
38 38 </p>
39 39 <br/>
... ...
setup/migrate/templates/services.tpl
... ... @@ -74,8 +74,10 @@
74 74 }
75 75 ?>
76 76 </table>
77   - <br/>
78   - <p class=\"description\">Click <b>Next</b> after deactivating the above services.</p>
  77 + <?php if ($serviceCheck != 'tick') { ?>
  78 + <br/>
  79 + <p class=\"description\">Click <b>Next</b> if deactivating the above services.</p>
  80 + <?php } ?>
79 81 <?php if($silent) { ?>
80 82 </div>
81 83 <?php } ?>
... ...
setup/upgrade/steps/upgradeDatabase.php
... ... @@ -268,7 +268,7 @@ class upgradeDatabase extends Step
268 268 // It should idealy work the same as the upgrades.
269 269 // Lock the scheduler
270 270 $lockFile = $this->cachePath . DIRECTORY_SEPARATOR . 'scheduler.lock';
271   - @touch($lockFile);
  271 + touch($lockFile);
272 272 return true;
273 273  
274 274 }
... ... @@ -287,7 +287,7 @@ class upgradeDatabase extends Step
287 287 // things up a bit
288 288 exec("del /q /s " . escapeshellarg($sPath));
289 289 }
290   - $hPath = @opendir($sPath);
  290 + $hPath = opendir($sPath);
291 291 while (($sFilename = readdir($hPath)) !== false) {
292 292 if (in_array($sFilename, array('.', '..'))) {
293 293 continue;
... ... @@ -297,11 +297,11 @@ class upgradeDatabase extends Step
297 297 $this->deleteDirectory($sFullFilename);
298 298 continue;
299 299 }
300   - @chmod($sFullFilename, 0666);
301   - @unlink($sFullFilename);
  300 + chmod($sFullFilename, 0666);
  301 + unlink($sFullFilename);
302 302 }
303 303 closedir($hPath);
304   - @rmdir($sPath);
  304 + rmdir($sPath);
305 305 }
306 306  
307 307 private function performPostUpgradeActions() {
... ... @@ -320,7 +320,7 @@ class upgradeDatabase extends Step
320 320 // Unlock the scheduler
321 321 $lockFile = $this->cachePath . DIRECTORY_SEPARATOR . 'scheduler.lock';
322 322 if(file_exists($lockFile)){
323   - @unlink($lockFile);
  323 + unlink($lockFile);
324 324 }
325 325  
326 326 return true;
... ...
setup/upgrade/steps/upgradeWelcome.php
... ... @@ -92,19 +92,12 @@ class upgradeWelcome extends step {
92 92 $dconf = $this->getDataFromPackage('installers', 'database'); // Use info from install
93 93 if($dconf) { // From Install
94 94 $this->util->dbUtilities->load($dconf['dhost'], $dconf['dport'], $dconf['duname'], $dconf['dpassword'], $dconf['dname']);
95   - } elseif($upgradeOnly) {
96   - require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
97   - $wizConfigHandler = new configuration();
98   - $configPath = $wizConfigHandler->readConfigPathIni();
99   - $this->util->iniUtilities->load($configPath);
100   - $dconf = $this->util->iniUtilities->getSection('db');
101   - $this->util->dbUtilities->load($dconf['dbHost'],$dconf['dbPort'], $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']);
102 95 $sQuery = "SELECT count(*) AS match_count FROM users WHERE username = '$username' AND password = '".md5($password)."'";
103 96 $res = $this->util->dbUtilities->query($sQuery);
104 97 $ass = $this->util->dbUtilities->fetchAssoc($res);
105 98 if($ass[0]['match_count'] == 1)
106 99 return true;
107   - } else { // Upgrade
  100 + } elseif($upgradeOnly) {
108 101 require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
109 102 $wizConfigHandler = new configuration();
110 103 $configPath = $wizConfigHandler->readConfigPathIni();
... ... @@ -116,6 +109,20 @@ class upgradeWelcome extends step {
116 109 $ass = $this->util->dbUtilities->fetchAssoc($res);
117 110 if($ass[0]['match_count'] == 1)
118 111 return true;
  112 + } else { // Upgrade
  113 + require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
  114 + $wizConfigHandler = new configuration();
  115 + $configPath = $wizConfigHandler->readConfigPathIni();
  116 + if($configPath) {
  117 + $this->util->iniUtilities->load($configPath);
  118 + $dconf = $this->util->iniUtilities->getSection('db');
  119 + $this->util->dbUtilities->load($dconf['dbHost'],$dconf['dbPort'], $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']);
  120 + $sQuery = "SELECT count(*) AS match_count FROM users WHERE username = '$username' AND password = '".md5($password)."'";
  121 + $res = $this->util->dbUtilities->query($sQuery);
  122 + $ass = $this->util->dbUtilities->fetchAssoc($res);
  123 + if($ass[0]['match_count'] == 1)
  124 + return true;
  125 + }
119 126 }
120 127 $this->error[] = 'Could Not Authenticate User';
121 128 return false;
... ...
setup/upgrade/templates/complete.tpl
... ... @@ -10,57 +10,28 @@
10 10 </div>
11 11 <br/><br/>
12 12 <?php if($migrateCheck) { ?>
13   - <div>
14   - <h3><?php echo "<span class='{$servicesCheck}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Services</h3>
15   - <?php if($silent) { ?>
16   - <div id="option2" class="onclick notop" onclick="javascript:{w.toggleClass('services_check', 'option2');}">Show Details</div>
17   - <div class="services_check" style="display:none">
18   - <?php } ?>
19   - <table style="width:755px;">
20   - <tr>
21   - <td style="width:15px;"> <?php echo "<span class='{$LuceneStatus}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?> </td>
22   - <td style="width:640px;"> Lucene Service <?php if ($LuceneStatus != 'tick') { ?> Could not be started <?php } else { ?> Started <?php } ?></td>
23   - <?php if ($LuceneStatus != 'tick') { ?>
24   - <td>
25   - <?php if (AJAX) { ?>
26   -<!-- <a href="#" class="refresh" onclick="w.refresh('complete')">Refresh</a>-->
27   - <?php } else { ?>
28   -<!-- <a href="javascript:this.location.reload();" class="refresh">Refresh</a>-->
29   - <?php } ?>
30   - </td>
31   - <?php } ?>
32   - </tr>
33   - <tr>
34   - <td> <?php echo "<span class='{$SchedulerStatus}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?> </td>
35   - <td> Scheduler Service <?php if ($SchedulerStatus != 'tick') { ?> Could not be started <?php } else { ?> Started <?php } ?></td>
36   - <?php if ($SchedulerStatus != 'tick') { ?>
37   - <td>
38   - <?php if (AJAX) { ?>
39   -<!-- <a href="#" class="refresh" onclick="w.refresh('complete')">Refresh</a>-->
40   - <?php } else { ?>
41   -<!-- <a href="javascript:this.location.reload();" class="refresh">Refresh</a>-->
42   - <?php } ?>
43   - </td>
44   - <?php } ?>
45   - </tr>
46   - <tr>
47   - <td> <?php echo "<span class='{$OpenOfficeStatus}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?> </td>
48   - <td> OpenOffice Service <?php if ($OpenOfficeStatus != 'tick') { ?> Could not be started <?php } else { ?> Started <?php } ?></td>
49   - <?php if ($OpenOfficeStatus != 'tick') { ?>
50   - <td>
51   - <?php if (AJAX) { ?>
52   -<!-- <a href="#" class="refresh" onclick="w.refresh('complete')">Refresh</a>-->
53   - <?php } else { ?>
54   -<!-- <a href="javascript:this.location.reload();" class="refresh">Refresh</a>-->
55   - <?php } ?>
56   - </td>
57   - <?php } ?>
58   - </tr>
59   - </table>
60   - <?php if($silent) { ?>
61   - </div>
62   - <?php } ?>
63   - </div>
  13 + <h3>Services</h3>
  14 + The KnowledgeTree services need to be started to allow for optimal functioning of the search, indexing and pdf generation.
  15 + <?php if(!WINDOWS_OS) { ?>
  16 + To start the services, execute the dmsctl.sh shell script in the KnowledgeTree directory from a terminal.
  17 + <br/>
  18 + <br/>
  19 + <?php } else { ?>
  20 + To start the services, execute the dmsctl.bat batch file in the KnowledgeTree directory from a command prompt, run as administrator.
  21 + <br/>
  22 + <br/>
  23 + <?php } ?>
  24 + <p class="disclaimer">
  25 + <?php if(WINDOWS_OS) { ?>
  26 + cd <?php echo "\"".SYSTEM_ROOT."\""; ?> <br/>
  27 + dmsctl.bat install<br/>
  28 + dmsctl.bat start
  29 + <?php } else { ?>
  30 + cd /usr/share/knowledgetree-ce<br/>
  31 + sudo ./dmsctl.sh start
  32 + <?php } ?>
  33 + </p>
  34 + <br/>
64 35 <?php } ?>
65 36 </div>
66 37 <a href="../../login.php" class="back button_next" style="width:50px;" onclick="javascript:{w.clearSessions();}">Finish</a>
... ...
setup/upgrade/upgradeWizard.php
... ... @@ -52,7 +52,6 @@ function __autoload($class) { // Attempt and autoload classes
52 52 if ($class == "template") { // Load existing templating classes
53 53 require_once(WIZARD_DIR."../wizard/template.php");
54 54 require_once(WIZARD_DIR."../wizard/lib/helpers/htmlHelper.php");
55   - return ;
56 55 }
57 56 if(file_exists(WIZARD_DIR."$class.php")) {
58 57 require_once(WIZARD_DIR."$class.php");
... ... @@ -155,7 +154,7 @@ class UpgradeWizard {
155 154 * @return void
156 155 */
157 156 private function createUpgradeFile() {
158   - @touch(SYSTEM_DIR.'var'.DS.'bin'.DS."upgrade.lock");
  157 + touch(SYSTEM_DIR.'var'.DS.'bin'.DS."upgrade.lock");
159 158 }
160 159  
161 160 /**
... ... @@ -167,7 +166,7 @@ class UpgradeWizard {
167 166 * @return void
168 167 */
169 168 private function removeUpgradeFile() {
170   - @unlink(SYSTEM_DIR.'var'.DS.'bin'.DS."upgrade.lock");
  169 + unlink(SYSTEM_DIR.'var'.DS.'bin'.DS."upgrade.lock");
171 170 }
172 171  
173 172 /**
... ...
setup/upgrade/upgrader.php
... ... @@ -413,7 +413,7 @@ class Upgrader {
413 413 * @return void
414 414 */
415 415 private function _completeUpgrade() {
416   - @touch("upgrade");
  416 + touch("upgrade");
417 417 }
418 418  
419 419 /**
... ...
setup/wizard/installUtil.php
... ... @@ -712,7 +712,7 @@ class InstallUtil {
712 712 */
713 713 function deleteMigrateFile() {
714 714 if(file_exists(SYSTEM_DIR.'var'.DS.'bin'.DS."migrate.lock"))
715   - @unlink(SYSTEM_DIR.'var'.DS.'bin'.DS."migrate.lock");
  715 + unlink(SYSTEM_DIR.'var'.DS.'bin'.DS."migrate.lock");
716 716 }
717 717  
718 718 /**
... ...
setup/wizard/installWizard.php
... ... @@ -203,7 +203,7 @@ class InstallWizard {
203 203 * @return void
204 204 */
205 205 private function createInstallFile() {
206   - @touch(SYSTEM_DIR.'var'.DS.'bin'.DS."install.lock");
  206 + touch(SYSTEM_DIR.'var'.DS.'bin'.DS."install.lock");
207 207 }
208 208  
209 209 /**
... ... @@ -216,7 +216,7 @@ class InstallWizard {
216 216 */
217 217 private function removeInstallFile() {
218 218 if(file_exists(SYSTEM_DIR.'var'.DS.'bin'.DS."install.lock"))
219   - @unlink(SYSTEM_DIR.'var'.DS.'bin'.DS."install.lock");
  219 + unlink(SYSTEM_DIR.'var'.DS.'bin'.DS."install.lock");
220 220 }
221 221  
222 222 /**
... ...
setup/wizard/path.php
... ... @@ -126,7 +126,7 @@
126 126 $type = file_get_contents($verType);
127 127 }
128 128 if($type) {
129   - define('INSTALL_TYPE', $type);
  129 + define('INSTALL_TYPE', trim($type));
130 130 } else {
131 131 define('INSTALL_TYPE', 'community');
132 132 }
... ...
setup/wizard/steps/database.php
... ... @@ -768,13 +768,14 @@ class database extends Step
768 768 $dbMigrate = $this->util->getDataFromPackage('migrate', 'database');
769 769 $sqlFile = $dbMigrate['dumpLocation'];
770 770 $this->parse_mysql_dump($sqlFile);
771   - $dropPluginHelper = "TRUNCATE plugin_helper;";
  771 + $dropPluginHelper = "TRUNCATE plugin_helper;"; // Remove plugin helper table
772 772 $this->util->dbUtilities->query($dropPluginHelper);
773   - $updateUrls = 'UPDATE config_settings c SET c.value = "default" where c.group_name = "urls";';
  773 + $updateUrls = 'UPDATE config_settings c SET c.value = "default" where c.group_name = "urls";'; // Remove references to old paths
774 774 $this->util->dbUtilities->query($updateUrls);
775   - $this->writeBinaries();
776   - // ensure a guid was generated and is stored
777   - $this->util->getSystemIdentifier();
  775 + $updateExternalBinaries = 'UPDATE config_settings c SET c.value = "default" where c.group_name = "externalBinary";'; // Remove references to old paths
  776 + $this->util->dbUtilities->query($updateExternalBinaries);
  777 + $this->writeBinaries(); // Rebuild some of the binaries
  778 + $this->util->getSystemIdentifier(); // ensure a guid was generated and is stored
778 779  
779 780 return true;
780 781 }
... ... @@ -793,7 +794,6 @@ class database extends Step
793 794 {
794 795 // continue without attempting to set the path if we can't find the file in the specified location
795 796 if (!file_exists($bin[1])) continue;
796   -
797 797 $updateBin = 'UPDATE config_settings c SET c.value = "'. str_replace('\\', '\\\\', $bin[1]) . '" '
798 798 . 'where c.group_name = "' . $bin[0] . '" and c.display_name = "'.$displayName.'";';
799 799 $this->util->dbUtilities->query($updateBin);
... ...
setup/wizard/templates/complete.tpl
... ... @@ -16,28 +16,30 @@
16 16 <br/>
17 17 <div id="step_content_<?php echo $step_name; ?>" class="step">
18 18 <?php if(!$servicesValidation) { ?>
19   - <h3>Services</h3>
20   - The KnowledgeTree services need to be started to allow for optimal functioning of the search, indexing and pdf generation.
21   - <?php if(!WINDOWS_OS) { ?>
22   - To start the services, execute the dmsctl.sh shell script in the KnowledgeTree directory from a terminal.
23   - <br/>
24   - <br/>
25   - <?php } else { ?>
26   - To start the services, execute the dmsctl.bat batch file in the KnowledgeTree directory from a command prompt, run as administrator.
27   - <br/>
28   - <br/>
29   - <?php } ?>
30   - <p class="disclaimer">
31   - <?php if(WINDOWS_OS) { ?>
32   - cd <?php echo "\"".SYSTEM_ROOT."\""; ?> <br/>
33   - dmsctl.bat install<br/>
34   - dmsctl.bat start
35   - <?php } else { ?>
36   - cd /usr/share/knowledgetree-ce<br/>
37   - sudo ./dmsctl.sh start
  19 + <?php if(!$migrate_check) { ?>
  20 + <h3>Services</h3>
  21 + The KnowledgeTree services need to be started to allow for optimal functioning of the search, indexing and pdf generation.
  22 + <?php if(!WINDOWS_OS) { ?>
  23 + To start the services, execute the dmsctl.sh shell script in the KnowledgeTree directory from a terminal.
  24 + <br/>
  25 + <br/>
  26 + <?php } else { ?>
  27 + To start the services, execute the dmsctl.bat batch file in the KnowledgeTree directory from a command prompt, run as administrator.
  28 + <br/>
  29 + <br/>
  30 + <?php } ?>
  31 + <p class="disclaimer">
  32 + <?php if(WINDOWS_OS) { ?>
  33 + cd <?php echo "\"".SYSTEM_ROOT."\""; ?> <br/>
  34 + dmsctl.bat install<br/>
  35 + dmsctl.bat start
  36 + <?php } else { ?>
  37 + cd /usr/share/knowledgetree-ce<br/>
  38 + sudo ./dmsctl.sh start
  39 + <?php } ?>
  40 + </p>
  41 + <br/>
38 42 <?php } ?>
39   - </p>
40   - <br/>
41 43 <?php } ?>
42 44 <!-- Paths and Permissions -->
43 45 <?php
... ...