Commit 6a895397aeea30c870e41258e6c0577ec9f18efc

Authored by Jarrett Jordaan
1 parent adf1a089

Daily Commit

Committed by: Jarrett Jordaan

Reviewed by: Paul Barrett
setup/migrate/config/commercial_config.xml
... ... @@ -10,8 +10,8 @@
10 10 <migrate version="3.7" type="Community Edition">
11 11 <steps>
12 12 <step name="Current Installation">installation</step>
13   - <step name="Deactivate Services">services</step>
14 13 <step name="Database Migration">database</step>
  14 + <step name="Deactivate Services">services</step>
15 15 <step name="Complete">complete</step>
16 16 </steps>
17 17 </migrate>
18 18 \ No newline at end of file
... ...
setup/migrate/config/community_config.xml
... ... @@ -10,8 +10,8 @@
10 10 <migrate version="3.7" type="Community Edition">
11 11 <steps>
12 12 <step name="Current Installation">installation</step>
13   - <step name="Deactivate Services">services</step>
14 13 <step name="Database Migration">database</step>
  14 + <step name="Deactivate Services">services</step>
15 15 <step name="Complete">complete</step>
16 16 </steps>
17 17 </migrate>
18 18 \ No newline at end of file
... ...
setup/migrate/migrateUtil.php
... ... @@ -50,7 +50,7 @@ class MigrateUtil extends InstallUtil {
50 50 * @param none
51 51 * @return boolean
52 52 */
53   - public function isSystemMigrateed() {
  53 + public function isSystemMigrated() {
54 54 if (file_exists(dirname(__FILE__)."/migrate")) {
55 55  
56 56 return true;
... ...
setup/migrate/migrateWizard.php
... ... @@ -5,7 +5,7 @@
5 5 * KnowledgeTree Community Edition
6 6 * Document Management Made Simple
7 7 * Copyright (C) 2008,2009 KnowledgeTree Inc.
8   -*
  8 +*
9 9 *
10 10 * This program is free software; you can redistribute it and/or modify it under
11 11 * the terms of the GNU General Public License version 3 as published by the
... ... @@ -98,10 +98,10 @@ class MigrateWizard {
98 98 * @param none
99 99 * @return boolean
100 100 */
101   - private function isSystemMigrateed() {
102   - return $this->util->isSystemMigrateed();
  101 + private function isSystemMigrated() {
  102 + return $this->util->isSystemMigrated();
103 103 }
104   -
  104 +
105 105 /**
106 106 * Display the wizard
107 107 *
... ... @@ -119,7 +119,7 @@ class MigrateWizard {
119 119 $ins->step(); // Run step
120 120 }
121 121 }
122   -
  122 +
123 123 /**
124 124 * Set bypass flag
125 125 *
... ... @@ -131,7 +131,7 @@ class MigrateWizard {
131 131 private function setBypass($bypass) {
132 132 $this->bypass = $bypass;
133 133 }
134   -
  134 +
135 135 /**
136 136 * Set util reference
137 137 *
... ... @@ -143,7 +143,7 @@ class MigrateWizard {
143 143 private function setIUtil($util) {
144 144 $this->util = $util;
145 145 }
146   -
  146 +
147 147 /**
148 148 * Get bypass flag
149 149 *
... ... @@ -155,7 +155,7 @@ class MigrateWizard {
155 155 public function getBypass() {
156 156 return $this->bypass;
157 157 }
158   -
  158 +
159 159 /**
160 160 * Bypass and force an migrate
161 161 *
... ... @@ -165,9 +165,9 @@ class MigrateWizard {
165 165 * @return boolean
166 166 */
167 167 private function bypass() {
168   -
  168 +
169 169 }
170   -
  170 +
171 171 /**
172 172 * Create migrate file
173 173 *
... ... @@ -179,7 +179,7 @@ class MigrateWizard {
179 179 private function createMigrateFile() {
180 180 @touch("migrate");
181 181 }
182   -
  182 +
183 183 /**
184 184 * Remove migrate file
185 185 *
... ... @@ -191,7 +191,7 @@ class MigrateWizard {
191 191 private function removeMigrateFile() {
192 192 @unlink("migrate");
193 193 }
194   -
  194 +
195 195 /**
196 196 * Load default values
197 197 *
... ... @@ -206,7 +206,7 @@ class MigrateWizard {
206 206 }
207 207 $this->setIUtil(new MigrateUtil());
208 208 }
209   -
  209 +
210 210 /**
211 211 * Run pre-migrateation system checks
212 212 *
... ... @@ -232,7 +232,7 @@ class MigrateWizard {
232 232 break;
233 233 }
234 234 }
235   -
  235 +
236 236 /**
237 237 * Control all requests to wizard
238 238 *
... ... @@ -248,7 +248,7 @@ class MigrateWizard {
248 248 } elseif ($this->getBypass() === "0") {
249 249 $this->createMigrateFile();
250 250 }
251   - if(!$this->isSystemMigrateed()) { // Check if the systems not migrated
  251 + if(!$this->isSystemMigrated()) { // Check if the systems not migrated
252 252 $response = $this->systemChecks();
253 253 if($response === true) {
254 254 $this->displayMigrater();
... ...
setup/migrate/steps/migrateDatabase.php
1 1 <?php
2 2 /**
3   -* Database Step Controller.
  3 +* Database Step Controller.
4 4 *
5 5 * KnowledgeTree Community Edition
6 6 * Document Management Made Simple
... ... @@ -40,7 +40,7 @@
40 40 * @version Version 0.1
41 41 */
42 42  
43   -class migrateDatabase extends Step
  43 +class migrateDatabase extends Step
44 44 {
45 45 /**
46 46 * List of errors encountered
... ... @@ -50,7 +50,7 @@ class migrateDatabase extends Step
50 50 * @var array
51 51 */
52 52 public $error = array();
53   -
  53 +
54 54 /**
55 55 * Flag to store class information in session
56 56 *
... ... @@ -59,7 +59,7 @@ class migrateDatabase extends Step
59 59 * @var array
60 60 */
61 61 public $storeInSession = true;
62   -
  62 +
63 63 /**
64 64 * Flag if step needs to be migrated
65 65 *
... ... @@ -68,7 +68,7 @@ class migrateDatabase extends Step
68 68 * @var array
69 69 */
70 70 protected $runMigrate = true;
71   -
  71 +
72 72 /**
73 73 * Flag if step needs to run silently
74 74 *
... ... @@ -112,7 +112,7 @@ class migrateDatabase extends Step
112 112 } else if($this->previous()) {
113 113 return 'previous';
114 114 }
115   -
  115 +
116 116 return 'landing';
117 117 }
118 118  
... ... @@ -145,7 +145,7 @@ class migrateDatabase extends Step
145 145 if(!$manual) { // Try to export database
146 146 $sqlFile = $tmpFolder."/kt-backup-$date.sql";
147 147 $cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.$dbName.' > '.$sqlFile;
148   - $this->util->pexec($cmd);
  148 + $response = $this->util->pexec($cmd);
149 149 }
150 150 if(file_exists($sqlFile)) {
151 151 $fileContents = file_get_contents($sqlFile);
... ... @@ -156,19 +156,35 @@ class migrateDatabase extends Step
156 156 }
157 157 // Handle failed dump
158 158 if(WINDOWS_OS) {
159   - $sqlFile = "C:\\kt-backup-$date.sql"; // Use tmp instead due to permissions
  159 + // Could be permissions, check error code.
  160 + if($response['ret'] == 2) {
  161 +
  162 + } else {
  163 + $sqlFile = "C:\\kt-backup-$date.sql"; // Use tmp instead due to permissions
  164 + }
160 165 } else {
161   - $sqlFile = "/tmp/kt-backup-$date.sql"; // Use tmp instead due to permissions
  166 + if($response['ret'] == 2) {
  167 +
  168 + } else {
  169 + $sqlFile = "/tmp/kt-backup-$date.sql"; // Use tmp instead due to permissions
  170 + }
162 171 }
163 172 $cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.$dbName.' > '.$sqlFile;
164   - $this->error[]['error'] = "Could not export database:";
165   - $this->error[]['msg'] = "Execute the following command in a $termOrBash.";
166   - $this->error[]['cmd'] = $cmd;
167   - $this->temp_variables['manual_export'] = $sqlFile;
168   -
  173 + if($response['ret'] == 2) {
  174 + $this->error[]['error'] = "Could not connect to KnowledgeTree Database";
  175 + $this->error[]['msg'] = "Make sure all KnowledgeTree Services are running.";
  176 + $this->error[]['cmd'] = "<p class=\"description\">Click <b>Next</b> after resolving the above errors.</p>";
  177 + $this->temp_variables['manual_export'] = "a";
  178 + } else {
  179 + $this->error[]['error'] = "Could not export database:";
  180 + $this->error[]['msg'] = "Execute the following command in a $termOrBash.";
  181 + $this->error[]['cmd'] = $cmd;
  182 + $this->temp_variables['manual_export'] = $sqlFile;
  183 + }
  184 +
169 185 return false;
170 186 }
171   -
  187 +
172 188 // TODO
173 189 function resolveTempDir() {
174 190 if (!WINDOWS_OS) {
... ... @@ -179,7 +195,7 @@ class migrateDatabase extends Step
179 195 if (!is_dir($dir)) {
180 196 mkdir($dir);
181 197 }
182   -
  198 +
183 199 return $dir;
184 200 }
185 201  
... ... @@ -197,10 +213,10 @@ class migrateDatabase extends Step
197 213 $this->temp_variables['dumpLocation'] = $this->getPostSafe('dumpLocation');
198 214 $this->createMigrateFile(); // create lock file to indicate migration mode
199 215 }
200   -
  216 +
201 217 /**
202 218 * Creates migration lock file so that system knows it is supposed to run an upgrade installation
203   - *
  219 + *
204 220 * @author KnowledgeTree Team
205 221 * @access private
206 222 * @return void
... ... @@ -208,7 +224,7 @@ class migrateDatabase extends Step
208 224 private function createMigrateFile() {
209 225 @touch(SYSTEM_DIR.'var'.DS.'bin'.DS."migrate.lock");
210 226 }
211   -
  227 +
212 228 /**
213 229 * Safer way to return post data
214 230 *
... ... @@ -220,7 +236,7 @@ class migrateDatabase extends Step
220 236 public function getPostSafe($key) {
221 237 return isset($_POST[$key]) ? $_POST[$key] : "";
222 238 }
223   -
  239 +
224 240 /**
225 241 * Stores varibles used by template
226 242 *
... ... @@ -244,7 +260,7 @@ class migrateDatabase extends Step
244 260 public function getErrors() {
245 261 return $this->error;
246 262 }
247   -
  263 +
248 264 /**
249 265 * Initialize errors to false
250 266 *
... ... @@ -258,12 +274,12 @@ class migrateDatabase extends Step
258 274 $this->error[$e] = false;
259 275 }
260 276 }
261   -
  277 +
262 278 private function storeSilent() {
263 279 // TODO
264 280 $_SESSION['migrate']['database']['dumpLocation'] = $this->sqlDumpFile;
265 281 $this->temp_variables['dumpLocation'] = $this->sqlDumpFile;
266 282 }
267   -
  283 +
268 284 }
269 285 ?>
270 286 \ No newline at end of file
... ...
setup/migrate/steps/migrateInstallation.php
1 1 <?php
2 2 /**
3   -* Migrate Step Controller.
  3 +* Migrate Step Controller.
4 4 *
5 5 * KnowledgeTree Community Edition
6 6 * Document Management Made Simple
... ... @@ -40,7 +40,7 @@
40 40 * @version Version 0.1
41 41 */
42 42  
43   -class migrateInstallation extends step
  43 +class migrateInstallation extends step
44 44 {
45 45 /**
46 46 * Flag to display confirmation page first
... ... @@ -50,7 +50,7 @@ class migrateInstallation extends step
50 50 * @var array
51 51 */
52 52 public $displayFirst = false;
53   -
  53 +
54 54 /**
55 55 * Flag to store class information in session
56 56 *
... ... @@ -77,13 +77,13 @@ class migrateInstallation extends step
77 77 * @var array
78 78 */
79 79 protected $silent = false;
80   -
  80 +
81 81 private $location = '';
82   -
  82 +
83 83 private $dbSettings = array();
84   -
  84 +
85 85 private $ktSettings = array();
86   -
  86 +
87 87 private $urlPaths = array();
88 88  
89 89 /**
... ... @@ -92,15 +92,15 @@ class migrateInstallation extends step
92 92 * @author KnowledgeTree Team
93 93 * @access public
94 94 * @var object
95   - */
  95 + */
96 96 private $settings = array();
97   -
  97 +
98 98 private $supportedVersion = '3.6.1';
99   -
  99 +
100 100 private $foundVersion = 'Unknown';
101   -
  101 +
102 102 private $versionError = false;
103   -
  103 +
104 104 public function doStep() {
105 105 $this->temp_variables = array("step_name"=>"installation", "silent"=>$this->silent);
106 106 $this->detectInstallation();
... ... @@ -122,8 +122,8 @@ class migrateInstallation extends step
122 122 return 'next';
123 123 }
124 124 $this->doRun();
125   -
126   - return 'landing';
  125 +
  126 + return 'landing';
127 127 }
128 128  
129 129 public function detectInstallation() {
... ... @@ -141,7 +141,7 @@ class migrateInstallation extends step
141 141 }
142 142 }
143 143 }
144   -
  144 +
145 145 public function doRun() {
146 146 if(!$this->readConfig()) {
147 147 $this->storeSilent();
... ... @@ -154,7 +154,7 @@ class migrateInstallation extends step
154 154 $this->storeSilent();
155 155 return true;
156 156 }
157   -
  157 +
158 158 }
159 159  
160 160 public function checkVersion() {
... ... @@ -163,10 +163,10 @@ class migrateInstallation extends step
163 163 $this->error[] = "KT installation needs to be 3.6.1 or higher";
164 164 return false;
165 165 }
166   -
  166 +
167 167 return true;
168 168 }
169   -
  169 +
170 170 public function readVersion() {
171 171 $verFile = $this->location."/knowledgeTree/docs/VERSION.txt";
172 172 if(file_exists($verFile)) {
... ... @@ -176,25 +176,25 @@ class migrateInstallation extends step
176 176 $this->error[] = "KT installation version not found";
177 177 }
178 178  
179   - return false;
  179 + return false;
180 180 }
181   -
  181 +
182 182 public function readConfig() {
183 183 if(isset($_POST['location'])) {
184 184 $ktInstallPath = $_POST['location'];
185 185 if($ktInstallPath != '' || strlen($ktInstallPath) == 0) {
186 186 $this->location = $ktInstallPath;
187   -
  187 +
188 188 return $this->configExists($ktInstallPath);
189   - }
  189 + }
190 190 } else {
191   -
  191 +
192 192 return false;
193 193 }
194 194  
195 195 return false;
196 196 }
197   -
  197 +
198 198 private function configExists($ktInstallPath) {
199 199 if(file_exists($ktInstallPath)) {
200 200 $configPath = $ktInstallPath.DS."knowledgeTree".DS."config".DS."config-path";
... ... @@ -203,7 +203,7 @@ class migrateInstallation extends step
203 203 if(file_exists($configFilePath)) { // For 3.7 and after
204 204 $this->loadConfig($configFilePath);
205 205 $this->storeSilent();
206   -
  206 +
207 207 return true;
208 208 } else {
209 209 $configFilePath = $ktInstallPath.DS."knowledgeTree".DS.$configFilePath; // For older than 3.6.2
... ... @@ -211,7 +211,7 @@ class migrateInstallation extends step
211 211 if(file_exists($configFilePath)) {
212 212 $this->loadConfig($configFilePath);
213 213 $this->storeSilent();
214   -
  214 +
215 215 return true;
216 216 }
217 217 $this->error[] = "KT installation configuration file empty";
... ... @@ -222,10 +222,10 @@ class migrateInstallation extends step
222 222 } else {
223 223 $this->error[] = "Please Enter a Location";
224 224 }
225   -
  225 +
226 226 return false;
227 227 }
228   -
  228 +
229 229 private function loadConfig($path) {
230 230 $this->util->iniUtilities->load($path);
231 231 $dbSettings = $this->util->iniUtilities->getSection('db');
... ... @@ -233,7 +233,6 @@ class migrateInstallation extends step
233 233 'dbName'=> $dbSettings['dbName'],
234 234 'dbUser'=> $dbSettings['dbUser'],
235 235 'dbPass'=> $dbSettings['dbPass'],
236   - 'dbPort'=> $this->util->getPort($this->location),
237 236 'dbAdminUser'=> $dbSettings['dbAdminUser'],
238 237 'dbAdminPass'=> $dbSettings['dbAdminPass'],
239 238 );
... ... @@ -253,11 +252,12 @@ class migrateInstallation extends step
253 252 array('name'=> 'Cache Directory', 'path'=> $varDir.DS.'cache'),
254 253 array('name'=> 'Upload Directory', 'path'=> $varDir.DS.'uploads'),
255 254 );
  255 + $this->dbSettings['dbPort'] = $this->util->getPort($this->location); // Add Port
256 256 $this->temp_variables['urlPaths'] = $this->urlPaths;
257 257 $this->temp_variables['ktSettings'] = $this->ktSettings;
258 258 $this->temp_variables['dbSettings'] = $this->dbSettings;
259 259 }
260   -
  260 +
261 261 private function setDetails() {
262 262 $inst = $this->getDataFromSession("installation");
263 263 if ($inst) {
... ... @@ -266,7 +266,7 @@ class migrateInstallation extends step
266 266 }
267 267 }
268 268 }
269   -
  269 +
270 270 public function getStepVars() {
271 271 return $this->temp_variables;
272 272 }
... ... @@ -274,13 +274,13 @@ class migrateInstallation extends step
274 274 public function getErrors() {
275 275 return $this->error;
276 276 }
277   -
  277 +
278 278 public function storeSilent() {
279 279 if($this->location==1) { $this->location = '';}
280 280 $this->temp_variables['location'] = $this->location;
281 281 $this->temp_variables['foundVersion'] = $this->foundVersion;
282 282 $this->temp_variables['versionError'] = $this->versionError;
283 283 $this->temp_variables['settings'] = $this->settings;
284   - }
  284 + }
285 285 }
286 286 ?>
287 287 \ No newline at end of file
... ...
setup/migrate/templates/database.tpl
... ... @@ -2,17 +2,20 @@
2 2 <p class="title">Migrate Database</p>
3 3 <div id="database" class="step1" style="display:block;">
4 4 <div class="description">
5   - This step configures the connection to the database server and migrates the database.
  5 + This step configures the connection to the database server and migrates the database.
6 6 <!-- The details for an administrative <br/>-->
7 7 <!-- user on the database server are required in order to be able to configure and migrate the database.-->
8 8 </div>
9 9 <div id="step_content_<?php echo $step_name; ?>" class="step">
  10 + <?php if(empty($errors)) { ?>
10 11 <p class="description">The Setup Wizard will now migrate your existing database to the new Zend Server stack. This process may take
11 12 several minutes to complete.</p><br />
12 13 <span class="error">Please ensure that your database is backed up before proceeding. If you need assistance with backing up see the &nbsp;<a class="description_click" target="_blank" href="http://wiki.knowledgetree.com/Backing_up_and_restoring_KnowledgeTree">'Backing up and restoring KnowledgeTree'</a>&nbsp; wiki entry.
13 14 </span>
14 15 <br /><br />
15 16 <p class="description">Click <b>Next</b> to continue.</p>
  17 + <?php } ?>
  18 +<!--Handle a failed dump-->
16 19 <?php if(isset($errors)) { ?>
17 20 <?php
18 21 foreach ($errors as $error) {
... ... @@ -35,7 +38,7 @@
35 38 <?php
36 39 }
37 40 ?>
38   -
  41 +
39 42 <?php
40 43 if(isset($error['cmd'])) {
41 44 echo $error['cmd'];
... ...
setup/migrate/templates/services.tpl
1 1 <form action="index.php?step_name=<?php echo $step_name; ?>" method="post" id="<?php echo $step_name; ?>">
2 2 <p class="title">Deactivate Services</p>
3   -
  3 +
4 4 <p class="description">
5 5 All KnowledgeTree services need to be deactivated before the migration takes place.
6 6 </p>
... ... @@ -34,7 +34,7 @@
34 34 <!--Content-->
35 35 <div id="step_content_<?php echo $step_name; ?>" class="step">
36 36 <?php if(!$alreadyUninstalled) { ?>
37   -
  37 +
38 38 <?php } else { ?>
39 39 All services are uninstalled.
40 40 <?php } ?>
... ... @@ -48,7 +48,7 @@
48 48 $display = 'none';
49 49 }
50 50 ?>
51   - <div id="option6" class="onclick" onclick="javascript:{w.toggleClass('service_details', 'option6');}"><?php echo $details; ?></div>
  51 + <div id="option6" class="onclick notop" onclick="javascript:{w.toggleClass('service_details', 'option6');}"><?php echo $details; ?></div>
52 52 <div class="service_details" style="display:<?php echo $display; ?>">
53 53 <?php } ?>
54 54 <table>
... ...
setup/wizard/installUtil.php
... ... @@ -939,7 +939,7 @@ class InstallUtil {
939 939 }
940 940 return join(" ", $aSafeArgs);
941 941 }
942   -
  942 +
943 943 /**
944 944 * The system identifier is a unique ID defined in every installation of KnowledgeTree
945 945 *
... ... @@ -948,14 +948,14 @@ class InstallUtil {
948 948 function getSystemIdentifier($db = true)
949 949 {
950 950 $sIdentifier = null;
951   -
  951 +
952 952 if ($db) {
953 953 $sIdentifier = $this->getSystemSetting('kt_system_identifier');
954 954 }
955   -
  955 +
956 956 if (empty($sIdentifier)) {
957 957 // if we have one from the session, simply return that one
958   - if (isset($_SESSION['installers']['registration']['installation_guid'])
  958 + if (isset($_SESSION['installers']['registration']['installation_guid'])
959 959 && !empty($_SESSION['installers']['registration']['installation_guid'])) {
960 960 $sIdentifier = $_SESSION['installers']['registration']['installation_guid'];
961 961 }
... ... @@ -968,7 +968,7 @@ class InstallUtil {
968 968 }
969 969 return $sIdentifier;
970 970 }
971   -
  971 +
972 972 function setSystemSetting($name, $value)
973 973 {
974 974 // we either need to insert or update:
... ... @@ -982,14 +982,14 @@ class InstallUtil {
982 982 // update
983 983 $query = 'UPDATE ' . $sTable . ' SET value = "' . $value . '" WHERE name = "' . $name . '"';
984 984 }
985   -
  985 +
986 986 $res = $this->dbUtilities->query($query);
987 987 $errors = $this->dbUtilities->getErrors();
988 988 if (count($errors)) { return false; }
989   -
  989 +
990 990 return true;
991 991 }
992   -
  992 +
993 993 function getSystemSetting($name, $default = null)
994 994 {
995 995 // XXX make this use a cache layer?
... ... @@ -1009,7 +1009,7 @@ class InstallUtil {
1009 1009  
1010 1010 return $result[$name];
1011 1011 }
1012   -
  1012 +
1013 1013 // {{{ getTableName
1014 1014 /**
1015 1015 * The one true way to get the correct name for a table whilst
... ... @@ -1024,7 +1024,7 @@ class InstallUtil {
1024 1024 return $sTable;
1025 1025 }
1026 1026 // }}}
1027   -
  1027 +
1028 1028 /*
1029 1029 Just Because.
1030 1030 */
... ...
setup/wizard/resources/css/migrate.css
... ... @@ -25,3 +25,7 @@
25 25 padding: 5px;
26 26 /*min-height:360px;*/min-height:295px;
27 27 }
  28 +
  29 +.notop {
  30 + top:0px;
  31 +}
28 32 \ No newline at end of file
... ...