Commit 932d0d6e1083056273956920f7be1d1901a9e8fa

Authored by Megan Watson
2 parents 3d6b3990 314339bb

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

lib/dispatcher.inc.php
... ... @@ -343,8 +343,8 @@ class KTStandardDispatcher extends KTDispatcher {
343 343 }
344 344  
345 345 function loginRequired() {
346   - $oKTConfig =& KTConfig::getSingleton();
347   - if ($oKTConfig->get('allowAnonymousLogin', false)) {
  346 + $oKTConfig =& KTConfig::getSingleton();
  347 + if ($oKTConfig->get('allowAnonymousLogin', false)) {
348 348 // anonymous logins are now allowed.
349 349 // the anonymous user is -1.
350 350 //
... ... @@ -352,9 +352,9 @@ class KTStandardDispatcher extends KTDispatcher {
352 352  
353 353 $oUser =& User::get(-2);
354 354 if (PEAR::isError($oUser) || ($oUser->getName() != 'Anonymous')) {
355   - ; // do nothing - the database integrity would break if we log the user in now.
  355 + ; // do nothing - the database integrity would break if we log the user in now.
356 356 } else {
357   - $session = new Session();
  357 + $session = new Session();
358 358 $sessionID = $session->create($oUser);
359 359 $this->sessionStatus = $this->session->verify();
360 360 if ($this->sessionStatus === true) {
... ...
lib/session/Session.inc
... ... @@ -228,7 +228,7 @@ class Session {
228 228 // Compare the system version and the database version to determine if the database needs to be upgraded.
229 229 $version = KTUtil::getSystemSetting('databaseVersion');
230 230  
231   - if ($default->systemVersion != $version) {
  231 + if (trim($default->systemVersion) != trim($version)) {
232 232 if (KTLOG_CACHE) $default->log->info("Session::verify : Database not upgraded");
233 233 $_SESSION['errormessage']['login'] = sprintf(_kt('Database incompatibility error: <br> Please ensure that you have completed the database upgrade procedure. <br> Please <a href=%s>click here</a> to complete.'),'setup/upgrade.php');
234 234 return PEAR::raiseError($_SESSION['errormessage']['login']);
... ...
setup/migrate/steps/migrateInstallation.php
... ... @@ -148,7 +148,7 @@ class migrateInstallation extends step
148 148 return false;
149 149 } else {
150 150 $this->foundVersion = $this->readVersion();
151   - if($version) {
  151 + if($this->foundVersion) {
152 152 $this->checkVersion();
153 153 }
154 154 $this->storeSilent();
... ... @@ -239,6 +239,8 @@ class migrateInstallation extends step
239 239 );
240 240 $ktSettings = $this->util->iniUtilities->getSection('KnowledgeTree');
241 241 $froot = $ktSettings['fileSystemRoot'];
  242 +// print_r($ktSettings);
  243 +// die;
242 244 if ($froot == 'default') {
243 245 $froot = $this->location;
244 246 }
... ...
setup/postcheckup.php
... ... @@ -38,7 +38,7 @@
38 38  
39 39 $checkup = true;
40 40 error_reporting(E_ALL);
41   -require_once('../config/dmsDefaults.php');
  41 +//require_once('../config/dmsDefaults.php');
42 42  
43 43 function writablePath($name, $path) {
44 44 $ret = sprintf('<tr><td>%s (%s)</td><td>', $name, $path);
... ...
setup/precheckup.php
... ... @@ -38,7 +38,7 @@
38 38  
39 39 error_reporting(E_ALL);
40 40  
41   -require_once('../config/dmsDefaults.php');
  41 +//require_once('../config/dmsDefaults.php');
42 42  
43 43 function get_php_setting($val) {
44 44 $r = (ini_get($val) == '1' ? 1 : 0);
... ...
setup/upgrade/lib/UpgradeItems.inc.php
... ... @@ -117,7 +117,7 @@ class UpgradeItem extends InstallUtil {
117 117 return $this->type;
118 118 }
119 119  
120   - function runDBQuery($query) {
  120 + function runDBQuery($query, $checkResult = false, $typeCheck = false) {
121 121 require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
122 122 $wizConfigHandler = new configuration();
123 123 $configPath = $wizConfigHandler->readConfigPathIni();
... ... @@ -128,13 +128,36 @@ class UpgradeItem extends InstallUtil {
128 128 $dconf = $this->iniUtilities->getSection('db');
129 129 $this->dbUtilities->load($dconf['dbHost'], '', $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']);
130 130 $result = $this->dbUtilities->query($query);
131   - $assArr = $this->dbUtilities->fetchAssoc($result);
132   - return $assArr;
  131 +// echo "$query<br/>";
  132 +// echo '<pre>';
  133 +// print_r($result);
  134 +// echo '</pre>';
  135 + if($checkResult) {
  136 + $assArr = $this->dbUtilities->fetchAssoc($result);
  137 +// echo '<pre>';
  138 +// print_r($assArr);
  139 +// echo '</pre>';
  140 +// if(is_null($assArr)) {
  141 +// echo '=== null ===<br/>';
  142 +// return false;
  143 +// } else {
  144 +// echo '=== not null ===<br/>';
  145 +// }
  146 + if($typeCheck) {
  147 + return !is_null($assArr);
  148 + } else {
  149 + return is_null($assArr);
  150 + }
  151 + }
  152 +// echo '<pre>';
  153 +// print_r($assArr);
  154 +// echo '</pre>';
  155 + return !is_null($result);
133 156 }
134 157  
135 158 function _upgradeTableInstalled() {
136 159 $query = "SELECT COUNT(id) FROM upgrades";
137   - $res = $this->runDBQuery($query);
  160 + $res = $this->runDBQuery($query, true, true);
138 161 if($res) {
139 162 return true;
140 163 }
... ... @@ -146,8 +169,9 @@ class UpgradeItem extends InstallUtil {
146 169 return false;
147 170 }
148 171 $query = "SELECT id FROM upgrades WHERE descriptor = '".$this->getDescriptor()."' AND result = 1";
149   - $res = $this->runDBQuery($query);
150   - if($res) {
  172 + $res = $this->runDBQuery($query, true, false);
  173 +
  174 + if(!$res) {
151 175 return true;
152 176 }
153 177 return false;
... ... @@ -161,27 +185,30 @@ class UpgradeItem extends InstallUtil {
161 185 return new Upgrade_Already_Applied($this);
162 186 }
163 187 }
164   -// if (PEAR::isError($res)) {
165   -// return $res;
  188 +// if (!$res) {
  189 +// $this->error[] = 'An Error Has Occured';
166 190 // }
167   - $oCache =& KTCache::getSingleton();
168   - $save = $oCache->bEnabled;
169   - $oCache->bEnabled = false;
  191 +// $oCache =& KTCache::getSingleton();
  192 +// $save = $oCache->bEnabled;
  193 +// $oCache->bEnabled = false;
170 194 $res = $this->_performUpgrade();
171   - $oCache->bEnabled = $save;
172   -// if (PEAR::isError($res)) {
173   -// $this->_recordUpgrade(false);
174   -// return $res;
175   -// }
  195 +// $oCache->bEnabled = $save;
  196 + if (!$res) {
  197 + $this->_recordUpgrade(false);
  198 + $this->error[] = $this->dbUtilities->getErrors();
  199 + return false;
  200 + }
176 201 $res = $this->_recordUpgrade(true);
177   -// if (PEAR::isError($res)) {
178   -// return $res;
179   -// }
  202 + if (!$res) {
  203 + $this->error[] = 'An Error Has Occured 1';
  204 + return false;
  205 + }
180 206 return true;
181 207 }
182 208  
183 209 function _performUpgrade() {
184   -// return PEAR::raiseError("Unimplemented");
  210 + $this->error[] = 'Unimplemented';
  211 + return false;
185 212 }
186 213  
187 214 function _recordUpgrade($result) {
... ... @@ -193,17 +220,10 @@ class UpgradeItem extends InstallUtil {
193 220 } else {
194 221 $parentid = null;
195 222 }
196   - //TODO: Where is the code?
197   - exit("add code");
198   - /*return $this->autoInsert();
199   -
200   - DBUtil::autoInsert("upgrades", array(
201   - "descriptor" => $this->getDescriptor(),
202   - "description" => $this->description,
203   - "date_performed" => $this->date,
204   - "result" => $result,
205   - "parent" => $parentid,
206   - ));*/
  223 + $sql = "INSERT INTO upgrades (`id`, `descriptor`, `description`, `date_performed`, `result`, `parent`) VALUES ('', '". $this->getDescriptor()."', '".$this->description."', '".$this->date."', '".$result."', '".$parentid."')";
  224 + $this->dbUtilities->query($sql);
  225 +
  226 + return true;
207 227 }
208 228  
209 229 // STATIC
... ... @@ -249,7 +269,7 @@ class SQLUpgradeItem extends UpgradeItem {
249 269 *
250 270 * STATIC
251 271 */
252   - function getUpgrades($origVersion, $currVersion) {
  272 + public static function getUpgrades($origVersion, $currVersion) {
253 273 // global $default;
254 274  
255 275 // $sqlupgradedir = KT_DIR . '/sql/' . $default->dbType . '/upgrade/';
... ... @@ -323,7 +343,7 @@ class SQLUpgradeItem extends UpgradeItem {
323 343 return $ret;
324 344 }
325 345  
326   - function _getDetailsFromFileName($path) {
  346 + public static function _getDetailsFromFileName($path) {
327 347 // Old format (pre 2.0.6)
328 348 $matched = preg_match('#^([\d.]*)-to-([\d.]*).sql$#', $path, $matches);
329 349 if ($matched != 0) {
... ... @@ -358,15 +378,13 @@ class SQLUpgradeItem extends UpgradeItem {
358 378 }
359 379  
360 380 function _performUpgrade() {
361   -// global $default;
362 381 $dbType = 'mysql';
363 382 $sqlupgradedir = KT_DIR . 'sql/' . $dbType . '/upgrade/';
364 383 $queries = SQLFile::sqlFromFile($sqlupgradedir . $this->name);
365   - exit('add code');
366   -// return DBUtil::runQueries($queries, $default->_admindb);
  384 + return $this->dbUtilities->runQueries($queries);
367 385 }
368 386  
369   -
  387 +
370 388 }
371 389  
372 390 class KTRebuildPermissionObserver {
... ... @@ -426,8 +444,8 @@ class RecordUpgradeItem extends UpgradeItem {
426 444 $query = "UPDATE system_settings SET value = '$systemVersion' WHERE name = 'knowledgetreeVersion'";
427 445 $this->runDBQuery($query);
428 446 $query = "UPDATE system_settings SET value = '{$this->version}' WHERE name = 'databaseVersion'";
429   - $assArray = $this->runDBQuery($query);
430   - return !is_null($assArray);
  447 + $result = $this->runDBQuery($query);
  448 + return $result;
431 449 }
432 450  
433 451 function _deleteSmartyFiles() {
... ...
setup/upgrade/lib/upgrade.inc.php
... ... @@ -92,25 +92,24 @@ function &amp;describeUpgrade ($origVersion, $currVersion) {
92 92 // How to figure out what upgrades to do:
93 93 //
94 94 // 1. Get all SQL upgrades >= origVersion and <= currVersion
95   - // 2. Get all Function upgrades >= origVersion and <= currVersion
96   - // 3. Categorise each into version they upgrade to
97   - // 4. Sort each version subgroup into correct order
  95 + // 2. Categorise each into version they upgrade to
  96 + // 3. Sort each version subgroup into correct order
98 97 // 5. Add "recordSubUpgrade" for each version there.
99   - // 6. Add back into one big list again
100   - // 7. Add "recordUpgrade" for whole thing
  98 + // 5. Add back into one big list again
  99 + // 6. Add "recordUpgrade" for whole thing
101 100  
102 101 // $recordUpgrade = array('upgrade*' . $currVersion, 'Upgrade to ' . $currVersion, null);
103 102  
104 103 $steps = array();
105 104 foreach (array('SQLUpgradeItem') as $itemgen) {
106 105 $f = array($itemgen, 'getUpgrades');
107   - $ssteps =& call_user_func($f, $origVersion, $currVersion);
  106 + $ssteps = call_user_func($f, $origVersion, $currVersion);
108 107 $scount = count($ssteps);
109 108 for ($i = 0; $i < $scount; $i++) {
110 109 $steps[] =& $ssteps[$i];
111 110 }
112 111 }
113   - $upgradestep =& new RecordUpgradeItem($currVersion, $origVersion);
  112 + $upgradestep = new RecordUpgradeItem($currVersion, $origVersion);
114 113 $steps[] =& $upgradestep;
115 114 $stepcount = count($steps);
116 115 for ($i = 0; $i < $stepcount; $i++) {
... ...
setup/upgrade/steps/upgradeComplete.php
... ... @@ -48,6 +48,7 @@ class upgradeComplete extends Step {
48 48  
49 49 public function doStep() {
50 50 $this->temp_variables = array("step_name"=>"complete", "silent"=>$this->silent);
  51 +
51 52 $this->doRun();
52 53 return 'landing';
53 54 }
... ... @@ -61,6 +62,8 @@ class upgradeComplete extends Step {
61 62 *
62 63 */
63 64 private function storeSilent() {
  65 + $v = $this->getDataFromSession('upgradeProperties');
  66 + $this->temp_variables['sysVersion'] = $v['upgrade_version'];
64 67 }
65 68  
66 69 }
... ...
setup/upgrade/steps/upgradeDatabase.php
... ... @@ -42,6 +42,7 @@
42 42  
43 43 define('KT_DIR', SYSTEM_DIR);
44 44 define('KT_LIB_DIR', SYSTEM_DIR.'lib');
  45 +require_once(WIZARD_LIB . 'upgrade.inc.php');
45 46  
46 47 class upgradeDatabase extends Step
47 48 {
... ... @@ -94,8 +95,8 @@ class upgradeDatabase extends Step
94 95 protected $silent = false;
95 96 protected $temp_variables = array();
96 97 public $paths = '';
97   -
98   - /**
  98 +
  99 + /**
99 100 * Main control of database setup
100 101 *
101 102 * @author KnowledgeTree Team
... ... @@ -141,16 +142,8 @@ class upgradeDatabase extends Step
141 142 }
142 143  
143 144 private function doRun($action = null) {
144   -// $this->readConfig(KTConfig::getConfigFilename());
145   -
146 145 $this->readConfig();
147   -// if($this->dbSettings['dbPort'] == '') {
148   -// $con = $this->util->dbUtilities->load($this->dbSettings['dbHost'], '', $this->dbSettings['dbUser'],$this->dbSettings['dbPass'], $this->dbSettings['dbName']);
149   -// } else {
150   - $con = $this->util->dbUtilities->load($this->dbSettings['dbHost'], $this->dbSettings['dbPort'], $this->dbSettings['dbUser'],
151   - $this->dbSettings['dbPass'], $this->dbSettings['dbName']);
152   -// }
153   -
  146 + $con = $this->util->dbUtilities->load($this->dbSettings['dbHost'], $this->dbSettings['dbPort'], $this->dbSettings['dbUser'],$this->dbSettings['dbPass'], $this->dbSettings['dbName']);
154 147 $this->temp_variables['action'] = $action;
155 148 if (is_null($action) || ($action == 'preview')) {
156 149 $this->temp_variables['title'] = 'Preview Upgrade';
... ... @@ -176,15 +169,16 @@ class upgradeDatabase extends Step
176 169 $this->sysVersion = $this->readVersion();
177 170 $this->temp_variables['systemVersion'] = $this->sysVersion;
178 171 $dconf = $this->util->iniUtilities->getSection('db');
179   - $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', 'system_settings');
180 172 $this->util->dbUtilities->load($dconf['dbHost'], '', $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']);
  173 +
  174 + $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', 'system_settings');
181 175 $result = $this->util->dbUtilities->query($query);
182 176 $assArr = $this->util->dbUtilities->fetchAssoc($result);
183 177 if ($result) {
184 178 $lastVersion = $assArr[0]['value'];
185 179 }
186 180 $currentVersion = $this->sysVersion;
187   - require_once("lib/upgrade.inc.php");
  181 +
188 182 $upgrades = describeUpgrade($lastVersion, $currentVersion);
189 183 $ret = "<table border=1 cellpadding=1 cellspacing=1 width='100%'>\n";
190 184 $ret .= "<tr bgcolor='darkgrey'><th width='10'>Code</th><th width='100%'>Description</th><th width='30'>Applied</th></tr>\n";
... ... @@ -256,21 +250,30 @@ class upgradeDatabase extends Step
256 250 require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
257 251 $wizConfigHandler = new configuration();
258 252 $path = $wizConfigHandler->readConfigPathIni();
259   - $this->util->iniUtilities->load($path);
260   - $dbSettings = $this->util->iniUtilities->getSection('db');
261   - $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'],
  253 + $this->util->iniUtilities->load($path);
  254 + $dbSettings = $this->util->iniUtilities->getSection('db');
  255 + $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'],
262 256 'dbName'=> $dbSettings['dbName'],
263 257 'dbUser'=> $dbSettings['dbUser'],
264 258 'dbPass'=> $dbSettings['dbPass'],
265 259 'dbPort'=> $dbSettings['dbPort'],
266 260 'dbAdminUser'=> $dbSettings['dbAdminUser'],
267 261 'dbAdminPass'=> $dbSettings['dbAdminPass'],
268   - );
269   - $this->paths = $this->util->iniUtilities->getSection('urls');
270   - $this->paths = array_merge($this->paths, $this->util->iniUtilities->getSection('cache'));
271   - $this->temp_variables['dbSettings'] = $this->dbSettings;
272   - $this->sysVersion = $this->readVersion();
273   - $this->cachePath = $wizConfigHandler->readCachePath();
  262 + );
  263 + $this->paths = $this->util->iniUtilities->getSection('urls');
  264 + $this->paths = array_merge($this->paths, $this->util->iniUtilities->getSection('cache'));
  265 + $this->sysVersion = $this->readVersion();
  266 + $this->cachePath = $wizConfigHandler->readCachePath();
  267 + $this->proxyPath = $this->cachePath."/.."; // Total guess.
  268 + $this->proxyPath = realpath($this->proxyPath."/proxies");
  269 + $this->storeSilent();
  270 + }
  271 +
  272 + public function storeSilent() {
  273 + $this->temp_variables['paths'] = $this->paths;
  274 + $this->temp_variables['sysVersion'] = $this->sysVersion;
  275 + $this->temp_variables['sysVersion'] = $this->sysVersion;
  276 + $this->temp_variables['dbSettings'] = $this->dbSettings;
274 277 }
275 278  
276 279 private function upgradeConfirm()
... ... @@ -285,8 +288,6 @@ class upgradeDatabase extends Step
285 288  
286 289 private function doDatabaseUpgrade()
287 290 {
288   -// global $default;
289   -
290 291 $errors = false;
291 292  
292 293 $this->temp_variables['detail'] = '<p>The table below describes the upgrades that have occurred to
... ... @@ -294,18 +295,10 @@ class upgradeDatabase extends Step
294 295  
295 296 $pre_res = $this->performPreUpgradeActions();
296 297  
297   - if (PEAR::isError($pre_res)) {
298   - $errors = true;
299   - $this->temp_variables['preUpgrade'] = '<font color="red">Pre-Upgrade actions failed.</font>';
300   - }
301   - else {
302   - $this->temp_variables['preUpgrade'] = '<font color="green">Pre-Upgrade actions succeeded.</font>';
303   -
304   - }
305   -
306 298 $res = $this->performAllUpgrades();
307   - if (PEAR::isError($res) || PEAR::isError($pres)) {
  299 + if (!$res) {
308 300 $errors = true;
  301 + $this->error[] = 'An Error has occured';
309 302 // TODO instantiate error details hideable section?
310 303 $this->temp_variables['upgradeStatus'] = '<font color="red">Database upgrade failed</font>
311 304 <br/><br/>
... ... @@ -319,13 +312,7 @@ class upgradeDatabase extends Step
319 312 }
320 313  
321 314 $post_pres = $this->performPostUpgradeActions();
322   - if (PEAR::isError($post_res)) {
323   - $errors = true;
324   - $this->temp_variables['postUpgrade'] = '<font color="red">Post-Upgrade actions failed.</font>';
325   - }
326   - else {
327   - $this->temp_variables['postUpgrade'] = '<font color="green">Post-Upgrade actions succeeded.</font>';
328   - }
  315 +
329 316  
330 317 return !$errors;
331 318 }
... ... @@ -334,40 +321,63 @@ class upgradeDatabase extends Step
334 321  
335 322 // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works.
336 323 // It should idealy work the same as the upgrades.
337   -
338   -// global $default;
339   -// print_r($this->paths);die;
340 324 // Lock the scheduler
341   - $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock';
342   - touch($lockFile);
  325 + $lockFile = $this->cachePath . DIRECTORY_SEPARATOR . 'scheduler.lock';
  326 + @touch($lockFile);
343 327 return true;
344 328  
345 329 }
346 330  
  331 + private function deleteDirectory($sPath) {
  332 + if (!WINDOWS_OS) {
  333 + if (file_exists('/bin/rm')) {
  334 + $this->util->pexec(array('/bin/rm', '-rf', $sPath));
  335 + return;
  336 + }
  337 + }
  338 + if (WINDOWS_OS) {
  339 + // Potentially kills off all the files in the path, speeding
  340 + // things up a bit
  341 + exec("del /q /s " . escapeshellarg($sPath));
  342 + }
  343 + $hPath = @opendir($sPath);
  344 + while (($sFilename = readdir($hPath)) !== false) {
  345 + if (in_array($sFilename, array('.', '..'))) {
  346 + continue;
  347 + }
  348 + $sFullFilename = sprintf("%s/%s", $sPath, $sFilename);
  349 + if (is_dir($sFullFilename)) {
  350 + $this->deleteDirectory($sFullFilename);
  351 + continue;
  352 + }
  353 + @chmod($sFullFilename, 0666);
  354 + @unlink($sFullFilename);
  355 + }
  356 + closedir($hPath);
  357 + @rmdir($sPath);
  358 + }
  359 +
347 360 private function performPostUpgradeActions() {
348 361  
349 362 // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works.
350 363 // It should idealy work the same as the upgrades.
351 364  
352   -// global $default;
353   -
354 365 // Ensure all plugins are re-registered.
355 366 $sql = "TRUNCATE plugin_helper";
356   - $res = DBUtil::runQuery($sql);
357   -
  367 + //$res = DBUtil::runQuery($sql);
  368 + $res = $this->util->dbUtilities->query($sql);
  369 +
358 370 // Clear out all caches and proxies - they need to be regenerated with the new code
359   - $proxyDir = $default->proxyCacheDirectory;
360   - KTUtil::deleteDirectory($proxyDir);
361   -
362   - $oKTCache = new KTCache();
363   - $oKTCache->deleteAllCaches();
364   -
  371 + $this->deleteDirectory($this->proxyPath);
  372 +// $oKTCache = new KTCache();
  373 +// $oKTCache->deleteAllCaches();
  374 + $this->deleteDirectory($this->cachePath);
365 375 // Clear the configuration cache, it'll regenerate on next load
366   - $oKTConfig = new KTConfig();
367   - $oKTConfig->clearCache();
  376 +// $oKTConfig = new KTConfig();
  377 +// $oKTConfig->clearCache();
368 378  
369 379 // Unlock the scheduler
370   - $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock';
  380 + $lockFile = $this->cachePath . DIRECTORY_SEPARATOR . 'scheduler.lock';
371 381 if(file_exists($lockFile)){
372 382 @unlink($lockFile);
373 383 }
... ... @@ -377,18 +387,15 @@ class upgradeDatabase extends Step
377 387 }
378 388  
379 389 private function performAllUpgrades () {
380   -// global $default;
381   -
382 390 $row = 1;
383   -
384   - $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table);
385   - $lastVersion = DBUtil::getOneResultKey($query, 'value');
386   - $currentVersion = $default->systemVersion;
387   -
  391 + $table = 'system_settings';
  392 + $query = "SELECT value FROM $table WHERE name = 'databaseVersion'";
  393 + $result = $this->util->dbUtilities->query($query);
  394 + $assArr = $this->util->dbUtilities->fetchAssoc($result);
  395 + $lastVersion = $assArr[0]['value'];
  396 + $currentVersion = $this->sysVersion;
388 397 $upgrades = describeUpgrade($lastVersion, $currentVersion);
389   -
390 398 $this->temp_variables['upgradeTable'] = '';
391   -
392 399 foreach ($upgrades as $upgrade) {
393 400 if (($row % 2) == 1) {
394 401 $class = "odd";
... ... @@ -402,15 +409,17 @@ class upgradeDatabase extends Step
402 409 $this->temp_variables['upgradeTable'] .= sprintf('<div class="bar">%s</div>', $this->showResult($res));
403 410 $this->temp_variables['upgradeTable'] .= '<br>' . "\n";
404 411 $this->temp_variables['upgradeTable'] .= "</div>\n";
405   - if (PEAR::isError($res)) {
406   - if (!is_a($res, 'Upgrade_Already_Applied')) {
407   - break;
408   - } else {
409   - $res = true;
410   - }
411   - }
  412 +// if (!$res) {
  413 +// if (!is_a($res, 'Upgrade_Already_Applied')) {
  414 +// $res = false;
  415 +// } else {
  416 +// $res = true;
  417 +// }
  418 +// }
412 419 if ($res === false) {
413   - $res = PEAR::raiseError("Upgrade returned false");
  420 + die;
  421 + $this->error = $this->util->dbUtilities->getErrors();
  422 +// print_r($this->error);
414 423 break;
415 424 }
416 425 }
... ... @@ -419,11 +428,11 @@ class upgradeDatabase extends Step
419 428 }
420 429  
421 430 private function showResult($res) {
422   - if (PEAR::isError($res)) {
  431 + if ($res) {
423 432 if (is_a($res, 'Upgrade_Already_Applied')) {
424 433 return '<span style="color: orange">Already applied</span>';
425 434 }
426   - return sprintf('<span style="color: red">%s</span>', htmlspecialchars($res->toString()));
  435 +// return sprintf('<span style="color: red">%s</span>', htmlspecialchars($res));
427 436 }
428 437 if ($res === true) {
429 438 return '<span style="color: green">Success</span>';
... ... @@ -433,6 +442,5 @@ class upgradeDatabase extends Step
433 442 }
434 443 return $res;
435 444 }
436   -
437 445 }
438 446 ?>
439 447 \ No newline at end of file
... ...
setup/upgrade/steps/upgradeWelcome.php
... ... @@ -45,7 +45,8 @@ class upgradeWelcome extends step {
45 45 protected $silent = true;
46 46 protected $temp_variables = array();
47 47 protected $error = array() ;
48   -
  48 + protected $storeInSession = true;
  49 +
49 50 public function doStep() {
50 51 $this->temp_variables = array("step_name"=>"welcome");
51 52 if($this->next()) {
... ... @@ -88,8 +89,6 @@ class upgradeWelcome extends step {
88 89 $configPath = $wizConfigHandler->readConfigPathIni();
89 90 $this->util->iniUtilities->load($configPath);
90 91 $dconf = $this->util->iniUtilities->getSection('db');
91   - if($dconf['dbPort'] == 'default')
92   - $dconf['dbPort'] = 3306;
93 92 $this->util->dbUtilities->load($dconf['dbHost'],$dconf['dbPort'], $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']);
94 93 $sQuery = "SELECT count(*) AS match_count FROM users WHERE username = '$username' AND password = '".md5($password)."'";
95 94 $res = $this->util->dbUtilities->query($sQuery);
... ...
setup/upgrade/templates/complete.tpl
... ... @@ -6,8 +6,8 @@
6 6 <!-- Services -->
7 7 <br/><br/>
8 8 <div>
9   - Your database has been upgraded to <?php //echo $default->systemVersion; ?>
  9 + Your database has been upgraded to <?php echo $sysVersion; ?>
10 10 </div>
11 11 </div>
12   - <a href="../../" class="back button_next" style="width:90px;" onclick="javascript:{w.clearSessions();}">Goto Login</a>
  12 + <a href="../../login.php" class="back button_next" style="width:90px;" onclick="javascript:{w.clearSessions();}">Goto Login</a>
13 13 </form>
14 14 \ No newline at end of file
... ...
setup/upgrade/templates/database.tpl
... ... @@ -3,6 +3,13 @@
3 3 <div id="database" class="step1" style="display:block;">
4 4 <div class="description">
5 5 This step performs the necessary Database Upgrades.
  6 + <?php
  7 + echo "<br/>";
  8 + foreach ($errors as $error) {
  9 + if($error != '')
  10 + echo "<span class = 'error'>$error</span><br/>";
  11 + }
  12 + ?>
6 13 </div>
7 14 <div id="step_content_database" class="step">
8 15 <br/><br/>
... ...
setup/upgrade/upgradeSession.php deleted
1   -<?php
2   -/**
3   -* Session Controller.
4   -*
5   -* KnowledgeTree Community Edition
6   -* Document Management Made Simple
7   -* Copyright(C) 2008,2009 KnowledgeTree Inc.
8   -* Portions copyright The Jam Warehouse Software(Pty) Limited
9   -*
10   -* This program is free software; you can redistribute it and/or modify it under
11   -* the terms of the GNU General Public License version 3 as published by the
12   -* Free Software Foundation.
13   -*
14   -* This program is distributed in the hope that it will be useful, but WITHOUT
15   -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16   -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17   -* details.
18   -*
19   -* You should have received a copy of the GNU General Public License
20   -* along with this program. If not, see <http://www.gnu.org/licenses/>.
21   -*
22   -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
23   -* California 94120-7775, or email info@knowledgetree.com.
24   -*
25   -* The interactive user interfaces in modified source and object code versions
26   -* of this program must display Appropriate Legal Notices, as required under
27   -* Section 5 of the GNU General Public License version 3.
28   -*
29   -* In accordance with Section 7(b) of the GNU General Public License version 3,
30   -* these Appropriate Legal Notices must retain the display of the "Powered by
31   -* KnowledgeTree" logo and retain the original copyright notice. If the display of the
32   -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
33   -* must display the words "Powered by KnowledgeTree" and retain the original
34   -* copyright notice.
35   -*
36   -* @copyright 2008-2009, KnowledgeTree Inc.
37   -* @license GNU General Public License version 3
38   -* @author KnowledgeTree Team
39   -* @package Upgrader
40   -* @version Version 0.1
41   -*/
42   -class UpgradeSession
43   -{
44   - private $salt = 'upgrade';
45   - /**
46   - * Constructs session object
47   - *
48   - * @author KnowledgeTree Team
49   - * @access public
50   - * @param none
51   - */
52   - public function __construct() {
53   - $this->startSession();
54   - }
55   -
56   - /**
57   - * Starts a session if one does not exist
58   - *
59   - * @author KnowledgeTree Team
60   - * @param none
61   - * @access public
62   - * @return void
63   - */
64   - public function startSession() {
65   - if(!isset($_SESSION[$this->salt]['ready'])) {
66   - session_start();
67   - $_SESSION[$this->salt] ['ready'] = TRUE;
68   - }
69   - }
70   -
71   - /**
72   - * Sets a value key pair in session
73   - *
74   - * @author KnowledgeTree Team
75   - * @param string $fld
76   - * @param string $val
77   - * @access public
78   - * @return void
79   - */
80   - public function set($fld, $val) {
81   - $this->startSession();
82   - $_SESSION[$this->salt] [$fld] = $val;
83   - }
84   -
85   - /**
86   - * Sets a value key pair in a class in session
87   - *
88   - * @author KnowledgeTree Team
89   - * @param string $class
90   - * @param string $fld
91   - * @param string $val
92   - * @access public
93   - * @return void
94   - */
95   - public function setClass($class , $k, $v) {
96   - $this->startSession();
97   - $classArray = $this->get($class);
98   - if(isset($classArray[$k])) {
99   - $classArray[$k] = $v;
100   - } else {
101   - $classArray[$k] = $v;
102   - }
103   - $_SESSION[$this->salt] [ $class] = $classArray;
104   - }
105   -
106   - /**
107   - * Sets a error value key pair in a class in session
108   - *
109   - * @author KnowledgeTree Team
110   - * @param string $class
111   - * @param string $fld
112   - * @param string $val
113   - * @access public
114   - * @return void
115   - */
116   - public function setClassError($class, $k, $v) {
117   - $this->startSession();
118   - $classArray = $this->get($class);
119   - if(isset($classArray[$k])) {
120   - $classArray[$k] = $v;
121   - } else {
122   - $classArray[$k] = $v;
123   - }
124   - $_SESSION[$this->salt] [ $class] = $classArray;
125   - }
126   -
127   - /**
128   - * Clear error values in a class session
129   - *
130   - * @author KnowledgeTree Team
131   - * @param string $class
132   - * @param string $fld
133   - * @param string $val
134   - * @access public
135   - * @return void
136   - */
137   - public function clearErrors($class) {
138   - $classArray = $this->get($class);
139   - unset($classArray['errors']);
140   - $_SESSION[$this->salt] [ $class] = $classArray;
141   - }
142   -
143   - /**
144   - * Unset a value in session
145   - *
146   - * @author KnowledgeTree Team
147   - * @param string $fld
148   - * @access public
149   - * @return void
150   - */
151   - public function un_set($fld) {
152   - $this->startSession();
153   - unset($_SESSION[$this->salt] [$fld]);
154   - }
155   -
156   - /**
157   - * Unset a class value in session
158   - *
159   - * @author KnowledgeTree Team
160   - * @param string $class
161   - * @access public
162   - * @return void
163   - */
164   - public function un_setClass($class) {
165   - $this->startSession();
166   - if(isset($_SESSION[$this->salt] [$class]))
167   - unset($_SESSION[$this->salt] [$class]);
168   - }
169   -
170   - /**
171   - * Destroy the session
172   - *
173   - * @author KnowledgeTree Team
174   - * @param none
175   - * @access public
176   - * @return void
177   - */
178   - public function destroy() {
179   - $this->startSession();
180   - unset($_SESSION[$this->salt]);
181   - session_destroy();
182   - }
183   -
184   - /**
185   - * Get a session value
186   - *
187   - * @author KnowledgeTree Team
188   - * @param string $fld
189   - * @access public
190   - * @return string
191   - */
192   - public function get($fld) {
193   - $this->startSession();
194   - if(isset($_SESSION[$this->salt] [$fld]))
195   - return $_SESSION[$this->salt] [$fld];
196   - return false;
197   - }
198   -
199   - /**
200   - * Check if a field exists in session
201   - *
202   - * @author KnowledgeTree Team
203   - * @param string $fld
204   - * @access public
205   - * @return string
206   - */
207   - public function is_set($fld) {
208   - $this->startSession();
209   - return isset($_SESSION[$this->salt] [$fld]);
210   - }
211   -
212   - /**
213   - * Return a class from session
214   - *
215   - * @author KnowledgeTree Team
216   - * @param string $fld
217   - * @access public
218   - * @return string
219   - */
220   - public function getClass($class) {
221   - return $_SESSION[$this->salt][$class];
222   - }
223   -}
224   -?>
225 0 \ No newline at end of file
setup/wizard/dbUtilities.php
... ... @@ -267,5 +267,15 @@ class dbUtilities {
267 267 public function rollback() {
268 268 $this->query("ROLLBACK");
269 269 }
  270 +
  271 + public function runQueries($aQueries) {
  272 + foreach ($aQueries as $sQuery) {
  273 + $res = $this->query($sQuery);
  274 + if (!$res) {
  275 + return $res;
  276 + }
  277 + }
  278 + return true;
  279 + }
270 280 }
271 281 ?>
272 282 \ No newline at end of file
... ...
setup/wizard/iniUtilities.php
... ... @@ -45,11 +45,11 @@ class iniUtilities {
45 45  
46 46  
47 47 function load($iniFile) {
48   - if($this->iniFile != $iniFile) {
49   - $this->cleanArray = array();
50   - $this->lineNum = 0;
51   - $this->exists = '';
52   - }
  48 +// if($this->iniFile != $iniFile) {
  49 +// $this->cleanArray = array();
  50 +// $this->lineNum = 0;
  51 +// $this->exists = '';
  52 +// }
53 53 $this->iniFile = $iniFile;
54 54 $this->backupIni($iniFile);
55 55 $this->read($iniFile);
... ...
setup/wizard/lib/services/unixLucene.php
... ... @@ -201,7 +201,7 @@ class unixLucene extends unixService {
201 201 public function start() {
202 202 $state = $this->status();
203 203 if($state != 'STARTED') {
204   - $logFile = $this->outputDir."log".DS."lucene.log";
  204 + $logFile = $this->outputDir.DS."lucene.log";
205 205 @unlink($logFile);
206 206 $cmd = "cd ".$this->getLuceneDir()."; ";
207 207 $cmd .= "nohup java {$this->getJavaXmx()} {$this->getJavaXmx()} -jar ".$this->getLuceneSource()." > ".$logFile." 2>&1 & echo $!";
... ...
setup/wizard/lib/services/unixScheduler.php
... ... @@ -180,7 +180,7 @@ class unixScheduler extends unixService {
180 180 // TODO : Write sh on the fly? Not sure the reasoning here
181 181 $source = $this->getSchedulerSourceLoc();
182 182 $this->writeSchedulerTask();
183   - $logFile = $this->outputDir."log".DS."scheduler.log";
  183 + $logFile = $this->outputDir.DS."scheduler.log";
184 184 @unlink($logFile);
185 185 if($source) { // Source
186 186 $cmd = "nohup ".$source." > ".$logFile." 2>&1 & echo $!";
... ...
setup/wizard/resources/graphics/greenit.jpg 0 → 100644

35 KB

setup/wizard/steps/complete.php
... ... @@ -96,6 +96,7 @@ class complete extends Step {
96 96 foreach ($paths as $path)
97 97 {
98 98 $output = '';
  99 + $path['path'] = $class = strtolower(substr($path['path'],0,1)).substr($path['path'],1); // Damn you windows
99 100 $result = $this->util->checkPermission($path['path']);
100 101 $output = sprintf($pathhtml, $result['class'], $path['path'],
101 102 (($result['class'] == 'tick') ? 'class="green"' : 'class="error"' ),
... ...
setup/wizard/steps/configuration.php
... ... @@ -450,7 +450,7 @@ class configuration extends Step
450 450 }
451 451 $dirs = $this->getFromConfigPath(); // Store contents
452 452 }
453   - $varDirectory = $fileSystemRoot . DS . 'var';
  453 +
454 454 foreach ($dirs as $key => $dir){
455 455 $path = (isset($_POST[$dir['setting']])) ? $_POST[$dir['setting']] : $dir['path'];
456 456  
... ... @@ -460,6 +460,7 @@ class configuration extends Step
460 460 if(WINDOWS_OS)
461 461 $path = preg_replace('/\//', '\\',$path);
462 462 $dirs[$key]['path'] = $path;
  463 + $path = $class = strtolower(substr($path,0,1)).substr($path,1); // Damn you windows
463 464 if(isset($dir['file']))
464 465 $class = $this->util->checkPermission($path, $dir['create'], true);
465 466 else
... ...
setup/wizard/steps/services.php
... ... @@ -219,7 +219,7 @@ class services extends Step
219 219 $srv = new $className();
220 220 $srv->load();
221 221 $status = $this->serviceInstalled($srv);
222   - if($status != 'STARTED') {
  222 + if($status != 'STARTED' || $status != 'STOPPED') {
223 223 if(!WINDOWS_OS) { $binary = $this->$class->getBinary(); } // Get binary, if it exists
224 224 $passed = $this->$class->binaryChecks(); // Run Binary Pre Checks
225 225 if ($passed) { // Install Service
... ...
setup/wizard/templates/install.tpl
... ... @@ -5,10 +5,7 @@
5 5 <p class="empty_space">
6 6 We would greatly appreciate it if you would allow us to collect anonymous usage statistics to help us provide a better quality product. The information includes a unique identification number, number of users you have created, your operating system type and your IP address. Your privacy is protected by the <a href="http://www.knowledgetree.com/about/legal" target="_blank">KnowledgeTree Privacy and Data Protection Agreements.</a>
7 7 </p>
8   - <p class="empty_space"">
9   - KnowledgeTree, in partnership with <a href="http://www.trees.co.za/" target="_blank">Food & Trees for Africa</a>, and as a contributor to the National Tree Distribution Program, will also commit to planting one tree in Africa for every 1000 vertified installations of the product.
10   - </p>
11   - <div class="demo"><?php echo $html->image('img_fatlogo.jpg'); ?></div>
  8 + <div class="demo"><?php echo $html->image('greenit.jpg'); ?></div>
12 9 <br/><br/>
13 10 <p> <input class="" type='checkbox' name='call_home' value='enable' checked style="float:left;"/>&nbsp;&nbsp;
14 11 Help to improve KnowledgeTree by providing anonymous usage statistics</p>
... ...
webservice/clienttools/ajaxhandler.php
... ... @@ -8,6 +8,7 @@ class ajaxHandler{
8 8 public $kt=NULL;
9 9 public $authenticator=NULL;
10 10 public $noAuthRequireList=array();
  11 + public $standardServices=array('system');
11 12  
12 13 public function __construct(&$ret=NULL,&$kt,$noAuthRequests=''){
13 14 // set a local copy of the json request wrapper
... ... @@ -30,6 +31,7 @@ class ajaxHandler{
30 31 }
31 32 $this->ret->setRequest($this->req->jsonArray);
32 33 $this->ret->setTitle($this->request['service'].'::'.$this->request['function']);
  34 + $this->ret->setDebug('Server Versions',$this->getServerVersions());
33 35  
34 36 if(get_class($kt)=='KTAPI'){
35 37 $this->kt=&$kt;
... ... @@ -38,20 +40,22 @@ class ajaxHandler{
38 40 return $this->render();
39 41 }
40 42  
41   - // Prepar
42   - $this->loadService('auth');
43   - $this->authenticator=new auth($this->ret,$this->kt,$this->request,$this->auth);
44   -
45   -
46   - //Make sure a token exists before continuing
47   - if(!$this->verifyToken())return $this->render();
48   -
49   -
50   - if(!$this->verifySession()){
51   - $this->doLogin();
52   - $isAuthRequired=$this->isNoAuthRequiredRequest();
53   - $isAuthenticated=$this->isAuthenticated();
54   - if(!$isAuthRequired && !$isAuthenticated)return $this->render();
  43 + // Prepare
  44 + if(!$this->isStandardService()){
  45 + $this->loadService('auth');
  46 + $this->authenticator=new auth($this,$this->ret,$this->kt,$this->request,$this->auth);
  47 +
  48 +
  49 + //Make sure a token exists before continuing
  50 + if(!$this->verifyToken())return $this->render();
  51 +
  52 +
  53 + if(!$this->verifySession()){
  54 + $this->doLogin();
  55 + $isAuthRequired=$this->isNoAuthRequiredRequest();
  56 + $isAuthenticated=$this->isAuthenticated();
  57 + if(!$isAuthRequired && !$isAuthenticated)return $this->render();
  58 + }
55 59 }
56 60  
57 61 $this->dispatch();
... ... @@ -70,11 +74,15 @@ class ajaxHandler{
70 74 $service=$this->authenticator;
71 75 }else{
72 76 $this->loadService($request['service']);
73   - $service=new $request['service']($this->ret,$this->kt,$this->request,$this->auth);
  77 + if(class_exists($request['service'])){
  78 + $service=new $request['service']($this,$this->ret,$this->kt,$this->request,$this->auth);
  79 + }else{
  80 + $this->ret->setDebug('Service could not be loaded',$request['service']);
  81 + }
74 82 }
75 83 $this->ret->setdebug('dispatch_request','The service class loaded');
76 84 if(method_exists($service,$request['function'])){
77   - $this->ret->setdebug('dispatch_execution','The service method was found. Executing');
  85 + $this->ret->setDebug('dispatch_execution','The service method was found. Executing');
78 86 $service->$request['function']($request['parameters']);
79 87 }else{
80 88 $this->ret->addError("Service {$request['service']} does not contain the method: {$request['function']}");
... ... @@ -82,16 +90,34 @@ class ajaxHandler{
82 90 }
83 91 }
84 92  
  93 + public function isStandardService(){
  94 + return in_array($this->request['service'],$this->standardServices);
  95 + }
  96 +
85 97  
86 98 public function loadService($serviceName=NULL){
87   - $version=$this->getVersion();
88   - if(!class_exists($serviceName)){
89   - if(file_exists('services/'.$version.'/'.$serviceName.'.php')){
90   - require_once('services/'.$version.'/'.$serviceName.'.php');
91   - return true;
92   - }else{
93   - throw new Exception('Service could not be found: '.$serviceName);
94   - return false;
  99 + if(in_array($serviceName,$this->standardServices)){
  100 + $fileName=dirname(__FILE__).'/standardservices/'.$serviceName.'.php';
  101 + $this->ret->setDebug('standardService Found',$fileName);
  102 + if(!class_exists($serviceName)){
  103 + if(file_exists($fileName)){
  104 + require_once($fileName);
  105 + return true;
  106 + }else{
  107 + throw new Exception('Standard Service could not be found: '.$serviceName);
  108 + return false;
  109 + }
  110 + }
  111 + }else{
  112 + $version=$this->getVersion();
  113 + if(!class_exists($serviceName)){
  114 + if(file_exists('services/'.$version.'/'.$serviceName.'.php')){
  115 + require_once('services/'.$version.'/'.$serviceName.'.php');
  116 + return true;
  117 + }else{
  118 + throw new Exception('Service could not be found: '.$serviceName);
  119 + return false;
  120 + }
95 121 }
96 122 }
97 123 }
... ... @@ -106,10 +132,22 @@ class ajaxHandler{
106 132 return true;
107 133 }
108 134  
109   - protected function getVersion(){
  135 + public function getVersion(){
110 136 if(!$this->version)$this->version=$this->req->getVersion();
111 137 return $this->version;
112 138 }
  139 +
  140 + public function getServerVersions(){
  141 + $folder='services/';
  142 + $contents=scandir($folder);
  143 + $dir=array();
  144 + foreach($contents as $item){
  145 + if(is_dir($folder.$item) && $item!='.' && $item!=='..'){
  146 + $dir[]=$item;
  147 + }
  148 + }
  149 + return $dir;
  150 + }
113 151  
114 152 protected function verifySession(){
115 153 return $this->authenticator->pickup_session();
... ...
webservice/clienttools/client_service.php
... ... @@ -5,8 +5,9 @@ class client_service{
5 5 public $KT;
6 6 public $Request;
7 7 public $AuthInfo;
  8 + public $handler;
8 9  
9   - public function __construct(&$ResponseObject,&$KT_Instance,&$Request,&$AuthInfo){
  10 + public function __construct(&$handler,&$ResponseObject,&$KT_Instance,&$Request,&$AuthInfo){
10 11 // set the response object
11 12 // if(get_class($ResponseObject)=='jsonResponseObject'){
12 13 // $this->Response=&$ResponseObject;
... ... @@ -14,7 +15,7 @@ class client_service{
14 15 // $this->Response=new jsonResponseObject();
15 16 // }
16 17  
17   -
  18 + $this->handler=$handler;
18 19 $this->Response=&$ResponseObject;
19 20 $this->KT=&$KT_Instance;
20 21 $this->AuthInfo=&$AuthInfo;
... ...
webservice/clienttools/jsonWrapper.php
... ... @@ -14,7 +14,7 @@ class jsonResponseObject{
14 14 public $additional=array();
15 15 public $isDataSource=false;
16 16  
17   - public $includeDebug=false;
  17 + public $includeDebug=true;
18 18  
19 19 public $response=array(
20 20 'requestName' =>'',
... ...
webservice/clienttools/services/0.1/auth.php
... ... @@ -100,17 +100,25 @@ class auth extends client_service {
100 100 public function ping(){
101 101 global $default;
102 102 $user=$this->KT->get_user_object_by_username($this->AuthInfo['user']);
  103 + $versions=$this->handler->getServerVersions();
  104 + $bestVer=$versions[count($versions)-1];
  105 + $clientVer=$this->handler->getVersion();
103 106 $ret=array(
104 107 'response' =>'pong',
105 108 'loginLocation' => '/index.html',
106   - 'currentversion' =>$default->systemVersion,
107   - 'requiredversion' =>$default->systemVersion,
108   - 'versionok' =>true,
109   - 'fullName' =>PEAR::isError($user)?'':$user->getName()
  109 + 'versionok' =>in_array($clientVer,$versions),
  110 + 'fullName' =>PEAR::isError($user)?'':$user->getName(),
  111 + 'serverVersions' =>$versions,
  112 + 'serverBestVersion' =>$bestVer,
  113 + 'clientVersion' =>$clientVer,
  114 + 'canUpgradeClient' =>($clientVer<$bestVer?true:false),
  115 + 'canUpgradeServer' =>($clientVer>$bestVer?true:false)
  116 +
110 117 );
111 118 $this->setResponse($ret);
112 119 return true;
113 120 }
  121 +
114 122  
115 123 function logout($params){
116 124 $params=$this->AuthInfo;
... ...
webservice/clienttools/services/0.2/auth.php
... ... @@ -100,13 +100,20 @@ class auth extends client_service {
100 100 public function ping(){
101 101 global $default;
102 102 $user=$this->KT->get_user_object_by_username($this->AuthInfo['user']);
  103 + $versions=$this->handler->getServerVersions();
  104 + $bestVer=$versions[count($versions)-1];
  105 + $clientVer=$this->handler->getVersion();
103 106 $ret=array(
104 107 'response' =>'pong',
105 108 'loginLocation' => '/index.html',
106   - 'currentversion' =>$default->systemVersion,
107   - 'requiredversion' =>$default->systemVersion,
108   - 'versionok' =>true,
109   - 'fullName' =>PEAR::isError($user)?'':$user->getName()
  109 + 'versionok' =>in_array($clientVer,$versions),
  110 + 'fullName' =>PEAR::isError($user)?'':$user->getName(),
  111 + 'serverVersions' =>$versions,
  112 + 'serverBestVersion' =>$bestVer,
  113 + 'clientVersion' =>$clientVer,
  114 + 'canUpgradeClient' =>($clientVer<$bestVer?true:false),
  115 + 'canUpgradeServer' =>($clientVer>$bestVer?true:false)
  116 +
110 117 );
111 118 $this->setResponse($ret);
112 119 return true;
... ...
webservice/clienttools/services/0.2/kt.php
... ... @@ -140,6 +140,7 @@ class kt extends client_service {
140 140  
141 141 $folder=&$kt->get_folder_by_id($arr['node']);
142 142 if (PEAR::isError($folder)){
  143 + echo '<pre>'.print_r($arr,true).'</pre>';
143 144 $this->addError('Folder Not found');
144 145 return false;
145 146 }
... ... @@ -430,6 +431,7 @@ class kt extends client_service {
430 431 }
431 432 }
432 433 $this->setResponse(array('items'=>$items, 'count'=>count($items)));
  434 + return true;
433 435 }
434 436  
435 437 function update_document_type($params) {
... ... @@ -599,9 +601,10 @@ class kt extends client_service {
599 601 $filename=$params['filename'];
600 602 $reason=$params['reason'];
601 603 $tempfilename=$params['tempfilename'];
  604 + $major_update=$params['major_update'];
602 605 $application=$this->AuthInfo['appType'];
603 606  
604   - $this->addDebug('Checkin',"checkin_document('$session_id',$document_id,'$filename','$reason','$tempfilename', '$application')");
  607 + $this->addDebug('Checkin',"checkin_document('$session_id',$document_id,'$filename','$reason','$tempfilename', '$application', $major_update)");
605 608 $kt=&$this->KT;
606 609  
607 610 // we need to add some security to ensure that people don't frig the checkin process to access restricted files.
... ... @@ -620,7 +623,7 @@ class kt extends client_service {
620 623 }
621 624  
622 625 // checkin
623   - $result=$document->checkin($filename, $reason, $tempfilename, false);
  626 + $result=$document->checkin($filename, $reason, $tempfilename, $major_update);
624 627 if (PEAR::isError($result))
625 628 {
626 629 $this->setResponse(array('status_code'=>14));
... ... @@ -676,7 +679,7 @@ class kt extends client_service {
676 679 $status_code=$update_result['status_code'];
677 680 if ($status_code != 0)
678 681 {
679   - $this->delete_document($arr['session_id'], $document_id, 'Rollback because metadata could not be added', $arr['application']);
  682 + $this->delete_document(array('session_id' => $arr['session_id'], 'document_id' => $document_id, 'reason' => 'Rollback because metadata could not be added', 'application' => $arr['application']));
680 683 $this->response= $update_result;
681 684 }
682 685  
... ... @@ -824,7 +827,12 @@ class kt extends client_service {
824 827 $this->setResponse($detail);
825 828 }
826 829  
827   - function delete_document($session_id, $document_id, $reason, $application){
  830 + function delete_document($params){
  831 + $session_id = $params['session_id'];
  832 + $document_id = $params['document_id'];
  833 + $reason = $params['reason'];
  834 + $application = $params['application'];
  835 +
828 836 $kt=&$this->KT;
829 837  
830 838 $document=&$kt->get_document_by_id($document_id);
... ...
webservice/clienttools/standardservices/system.php 0 → 100644
  1 +<?php
  2 +class system extends client_service{
  3 + public function checkVersion(){
  4 + global $default;
  5 + $user=$this->KT->get_user_object_by_username($this->AuthInfo['user']);
  6 + $versions=$this->handler->getServerVersions();
  7 + $bestVer=$versions[count($versions)-1];
  8 + $clientVer=$this->handler->getVersion();
  9 + $ret=array(
  10 + 'response' =>'pong',
  11 + 'loginLocation' => '/index.html',
  12 + 'versionok' =>in_array($clientVer,$versions),
  13 + 'fullName' =>PEAR::isError($user)?'':$user->getName(),
  14 + 'serverVersions' =>$versions,
  15 + 'serverBestVersion' =>$bestVer,
  16 + 'clientVersion' =>$clientVer,
  17 + 'canUpgradeClient' =>($clientVer<$bestVer?true:false),
  18 + 'canUpgradeServer' =>($clientVer>$bestVer?true:false)
  19 +
  20 + );
  21 + $this->setResponse($ret);
  22 + return true;
  23 + }
  24 +}
  25 +
  26 +?>
0 27 \ No newline at end of file
... ...