Commit ccb0e62ab3f38b2ef125a22e4254ab47eadf8b0c

Authored by Charl Joseph Mert
2 parents efb01422 b2522b03

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

Showing 56 changed files with 605 additions and 707 deletions
.gitignore
1 *~ 1 *~
2 bin/luceneserver/lucene.pid 2 bin/luceneserver/lucene.pid
  3 +bin/schedulerTask.sh
3 *.tmproj 4 *.tmproj
4 .DS_Store 5 .DS_Store
5 .buildpath 6 .buildpath
bin/system_info.php
@@ -43,7 +43,12 @@ @@ -43,7 +43,12 @@
43 * The following data is collected: 43 * The following data is collected:
44 * Unique installation information: installation GUID, number of users in repository, number of documents in repository, 44 * Unique installation information: installation GUID, number of users in repository, number of documents in repository,
45 * operating system (platform, platform version, flavor if Linux), version and edition. 45 * operating system (platform, platform version, flavor if Linux), version and edition.
  46 +
  47 +<installation guid>|<enabled user count>|<disabled user count>|<deleted user count>|
  48 +<live document count>|<deleted document count>|<archived document count>|
  49 +<KT version>|<KT edition>|<User licenses>|<OS info>
46 */ 50 */
  51 +
47 chdir(realpath(dirname(__FILE__))); 52 chdir(realpath(dirname(__FILE__)));
48 require_once('../config/dmsDefaults.php'); 53 require_once('../config/dmsDefaults.php');
49 54
@@ -56,7 +61,7 @@ function getGuid() @@ -56,7 +61,7 @@ function getGuid()
56 $guid = KTUtil::getSystemIdentifier(); 61 $guid = KTUtil::getSystemIdentifier();
57 62
58 if(PEAR::isError($guid)){ 63 if(PEAR::isError($guid)){
59 - $guid = ''; 64 + $guid = '-';
60 } 65 }
61 return $guid; 66 return $guid;
62 } 67 }
@@ -68,42 +73,43 @@ function getUserCnt() @@ -68,42 +73,43 @@ function getUserCnt()
68 $result = DBUtil::getResultArray($query); 73 $result = DBUtil::getResultArray($query);
69 74
70 if(empty($result) || PEAR::isError($result)){ 75 if(empty($result) || PEAR::isError($result)){
71 - return ''; 76 + return '-|-|-';
72 } 77 }
73 - $users = ''; 78 + $enabled = '-';
  79 + $disabled = '-';
  80 + $deleted = '-';
74 81
75 foreach ($result as $row){ 82 foreach ($result as $row){
76 - $str = '';  
77 switch($row['disabled']){ 83 switch($row['disabled']){
78 - case 0: $str = 'Enabled'; break;  
79 - case 1: $str = 'Disabled'; break;  
80 - case 2: $str = 'Deleted'; break; 84 + case 0: $enabled = $row['cnt']; break;
  85 + case 1: $disabled = $row['cnt']; break;
  86 + case 2: $deleted = $row['cnt']; break;
81 } 87 }
82 -  
83 - $str .= ': '.$row['cnt'];  
84 -  
85 - $users .= (!empty($users)) ? '; ' : '';  
86 - $users .= $str;  
87 } 88 }
88 - return $users; 89 + return "{$enabled}|{$disabled}|{$deleted}";
89 } 90 }
90 91
91 // Get the number of documents in the repository 92 // Get the number of documents in the repository
92 function getDocCnt() 93 function getDocCnt()
93 { 94 {
94 - $query = 'select count(*) as cnt, s.name from documents d, status_lookup s WHERE s.id = d.status_id group by d.status_id;'; 95 + $query = 'select count(*) as cnt, status_id from documents d WHERE status_id IN (1,3,4) group by d.status_id;';
95 $result2 = DBUtil::getResultArray($query); 96 $result2 = DBUtil::getResultArray($query);
96 97
97 if(empty($result2) || PEAR::isError($result2)){ 98 if(empty($result2) || PEAR::isError($result2)){
98 - return ''; 99 + return '-|-|-';
99 } 100 }
100 - $docs = ''; 101 + $live = '-';
  102 + $deleted = '-';
  103 + $archived = '-';
101 104
102 foreach ($result2 as $row){ 105 foreach ($result2 as $row){
103 - $docs .= (!empty($docs)) ? '; ' : '';  
104 - $docs .= $row['name'].': '.$row['cnt']; 106 + switch($row['status_id']){
  107 + case 1: $live = $row['cnt']; break;
  108 + case 3: $deleted = $row['cnt']; break;
  109 + case 4: $archived = $row['cnt']; break;
  110 + }
105 } 111 }
106 - return $docs; 112 + return "{$live}|{$deleted}|{$archived}";
107 } 113 }
108 114
109 // Get the version of KT 115 // Get the version of KT
@@ -121,15 +127,21 @@ function getKTVersion() @@ -121,15 +127,21 @@ function getKTVersion()
121 // Get the edition of KT 127 // Get the edition of KT
122 function getKTEdition() 128 function getKTEdition()
123 { 129 {
124 - $edition = 'Community'; 130 + $edition = 'Community|-';
125 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { 131 if (KTPluginUtil::pluginIsActive('ktdms.wintools')) {
126 $path = KTPluginUtil::getPluginPath('ktdms.wintools'); 132 $path = KTPluginUtil::getPluginPath('ktdms.wintools');
127 require_once($path . 'baobabkeyutil.inc.php'); 133 require_once($path . 'baobabkeyutil.inc.php');
128 $edition = BaobabKeyUtil::getName(); 134 $edition = BaobabKeyUtil::getName();
129 135
  136 + // this could be done with regular expressions...
130 // Remove the brackets around the name 137 // Remove the brackets around the name
131 $edition = substr($edition, 1); 138 $edition = substr($edition, 1);
132 $edition = substr($edition, 0, strlen($edition)-1); 139 $edition = substr($edition, 0, strlen($edition)-1);
  140 + // Remove the "users"
  141 + $pos = strpos($edition, 'users');
  142 + $edition = ($pos === false) ? $edition.'|-' : substr($edition, 0, $pos-1);
  143 + // Replace the , with |
  144 + $edition = str_replace(', ', '|', $edition);
133 } 145 }
134 return $edition; 146 return $edition;
135 } 147 }
@@ -139,22 +151,33 @@ function getKTEdition() @@ -139,22 +151,33 @@ function getKTEdition()
139 function getOSInfo() 151 function getOSInfo()
140 { 152 {
141 $server = php_uname(); 153 $server = php_uname();
  154 + $server_arr = explode(' ', $server);
  155 +
  156 + // kernel version and os type - 32bit / 64bit
  157 + $kernel_v = $server_arr[2];
  158 + $os_v = array_pop($server_arr);
142 159
143 if(strpos($server, 'Darwin') !== false){ 160 if(strpos($server, 'Darwin') !== false){
144 $os = 'Mac OS X'; 161 $os = 'Mac OS X';
145 }else if(strpos($server, 'Win') !== false){ 162 }else if(strpos($server, 'Win') !== false){
146 $os = 'Windows'; 163 $os = 'Windows';
147 - }else { 164 + // windows differs from *nix
  165 + // kernel version = windows version
  166 + // os version = build number
  167 + $kernel_v = $server_arr[3];
  168 + $os_v = array_pop($server_arr);
  169 + }else if(strpos($server, 'Linux') !== false) {
148 $os = 'Linux'; 170 $os = 'Linux';
  171 + }else {
  172 + $os = 'Unix';
149 } 173 }
150 174
151 - return $os; 175 + return $os.'|'.$kernel_v.'|'.$os_v;
152 } 176 }
153 177
154 function sendForm($data) 178 function sendForm($data)
155 { 179 {
156 $url = 'http://ktnetwork.knowledgetree.com/call_home.php'; 180 $url = 'http://ktnetwork.knowledgetree.com/call_home.php';
157 - //$url = 'http://10.33.20.250/knowledgetree/call_home.php';  
158 $data = http_build_query($data); 181 $data = http_build_query($data);
159 182
160 $ch = curl_init($url); 183 $ch = curl_init($url);
clienttools/.gitignore deleted
1 -*~  
2 -bin/luceneserver/lucene.pid  
3 -*.tmproj  
4 -.DS_Store  
5 -.buildpath  
6 -.project  
7 -.settings/  
8 -dummy.php  
9 -var/*  
10 -plugins/commercial  
ktwebservice/KTDownloadManager.inc.php
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 * KnowledgeTree Community Edition 9 * KnowledgeTree Community Edition
10 * Document Management Made Simple 10 * Document Management Made Simple
11 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 11 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
12 - * Portions copyright The Jam Warehouse Software (Pty) Limited 12 + *
13 * 13 *
14 * This program is free software; you can redistribute it and/or modify it under 14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU General Public License version 3 as published by the 15 * the terms of the GNU General Public License version 3 as published by the
ktwebservice/KTUploadManager.inc.php
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 * KnowledgeTree Community Edition 9 * KnowledgeTree Community Edition
10 * Document Management Made Simple 10 * Document Management Made Simple
11 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 11 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
12 - * Portions copyright The Jam Warehouse Software (Pty) Limited 12 + *
13 * 13 *
14 * This program is free software; you can redistribute it and/or modify it under 14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU General Public License version 3 as published by the 15 * the terms of the GNU General Public License version 3 as published by the
ktwebservice/KTWebService.php
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 * KnowledgeTree Community Edition 5 * KnowledgeTree Community Edition
6 * Document Management Made Simple 6 * Document Management Made Simple
7 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 7 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
8 - * Portions copyright The Jam Warehouse Software (Pty) Limited 8 + *
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify it under 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 11 * the terms of the GNU General Public License version 3 as published by the
@@ -671,4 +671,4 @@ $ws-&gt;handle(); @@ -671,4 +671,4 @@ $ws-&gt;handle();
671 671
672 exit(); 672 exit();
673 673
674 -?>  
675 \ No newline at end of file 674 \ No newline at end of file
  675 +?>
ktwebservice/checkup.php
@@ -32,4 +32,4 @@ $uploadsWritable = !is_writable($uploadsDir)?&#39;The upload directory is not writab @@ -32,4 +32,4 @@ $uploadsWritable = !is_writable($uploadsDir)?&#39;The upload directory is not writab
32 <td>Upload Directory Writable</td> 32 <td>Upload Directory Writable</td>
33 <td><?php print $uploadsWritable?></td> 33 <td><?php print $uploadsWritable?></td>
34 </tr> 34 </tr>
35 -</table>  
36 \ No newline at end of file 35 \ No newline at end of file
  36 +</table>
ktwebservice/download.php
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 * KnowledgeTree Community Edition 7 * KnowledgeTree Community Edition
8 * Document Management Made Simple 8 * Document Management Made Simple
9 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 9 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
10 - * Portions copyright The Jam Warehouse Software (Pty) Limited 10 + *
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify it under 12 * This program is free software; you can redistribute it and/or modify it under
13 * the terms of the GNU General Public License version 3 as published by the 13 * the terms of the GNU General Public License version 3 as published by the
@@ -81,4 +81,4 @@ if (PEAR::isError($response)) @@ -81,4 +81,4 @@ if (PEAR::isError($response))
81 exit; 81 exit;
82 } 82 }
83 83
84 -?>  
85 \ No newline at end of file 84 \ No newline at end of file
  85 +?>
ktwebservice/download_cleanup.php
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 * KnowledgeTree Community Edition 9 * KnowledgeTree Community Edition
10 * Document Management Made Simple 10 * Document Management Made Simple
11 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 11 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
12 - * Portions copyright The Jam Warehouse Software (Pty) Limited 12 + *
13 * 13 *
14 * This program is free software; you can redistribute it and/or modify it under 14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU General Public License version 3 as published by the 15 * the terms of the GNU General Public License version 3 as published by the
ktwebservice/index.php
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 * KnowledgeTree Community Edition 9 * KnowledgeTree Community Edition
10 * Document Management Made Simple 10 * Document Management Made Simple
11 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 11 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
12 - * Portions copyright The Jam Warehouse Software (Pty) Limited 12 + *
13 * 13 *
14 * This program is free software; you can redistribute it and/or modify it under 14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU General Public License version 3 as published by the 15 * the terms of the GNU General Public License version 3 as published by the
ktwebservice/json.php
@@ -3,4 +3,4 @@ @@ -3,4 +3,4 @@
3 define('JSON_WEBSERVICE',1); 3 define('JSON_WEBSERVICE',1);
4 require_once('webservice.php'); 4 require_once('webservice.php');
5 5
6 -?>  
7 \ No newline at end of file 6 \ No newline at end of file
  7 +?>
ktwebservice/upload.php
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 * KnowledgeTree Community Edition 9 * KnowledgeTree Community Edition
10 * Document Management Made Simple 10 * Document Management Made Simple
11 * Copyright (C) 2008, 2009 KnowledgeTree Inc. 11 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
12 - * Portions copyright The Jam Warehouse Software (Pty) Limited 12 + *
13 * 13 *
14 * This program is free software; you can redistribute it and/or modify it under 14 * This program is free software; you can redistribute it and/or modify it under
15 * the terms of the GNU General Public License version 3 as published by the 15 * the terms of the GNU General Public License version 3 as published by the
@@ -207,4 +207,4 @@ function respond($code, $msg, $uploads=array()) @@ -207,4 +207,4 @@ function respond($code, $msg, $uploads=array())
207 } 207 }
208 208
209 209
210 -?>  
211 \ No newline at end of file 210 \ No newline at end of file
  211 +?>
lib/dispatcher.inc.php
@@ -343,8 +343,8 @@ class KTStandardDispatcher extends KTDispatcher { @@ -343,8 +343,8 @@ class KTStandardDispatcher extends KTDispatcher {
343 } 343 }
344 344
345 function loginRequired() { 345 function loginRequired() {
346 - $oKTConfig =& KTConfig::getSingleton();  
347 - if ($oKTConfig->get('allowAnonymousLogin', false)) { 346 + $oKTConfig =& KTConfig::getSingleton();
  347 + if ($oKTConfig->get('allowAnonymousLogin', false)) {
348 // anonymous logins are now allowed. 348 // anonymous logins are now allowed.
349 // the anonymous user is -1. 349 // the anonymous user is -1.
350 // 350 //
@@ -352,9 +352,9 @@ class KTStandardDispatcher extends KTDispatcher { @@ -352,9 +352,9 @@ class KTStandardDispatcher extends KTDispatcher {
352 352
353 $oUser =& User::get(-2); 353 $oUser =& User::get(-2);
354 if (PEAR::isError($oUser) || ($oUser->getName() != 'Anonymous')) { 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 } else { 356 } else {
357 - $session = new Session(); 357 + $session = new Session();
358 $sessionID = $session->create($oUser); 358 $sessionID = $session->create($oUser);
359 $this->sessionStatus = $this->session->verify(); 359 $this->sessionStatus = $this->session->verify();
360 if ($this->sessionStatus === true) { 360 if ($this->sessionStatus === true) {
lib/metadata/fieldsetregistry.inc.php
@@ -139,26 +139,26 @@ class KTFieldsetRegistry { @@ -139,26 +139,26 @@ class KTFieldsetRegistry {
139 // FIXME delegate. 139 // FIXME delegate.
140 $oFieldset =& $fieldsetOrType; 140 $oFieldset =& $fieldsetOrType;
141 141
142 - $widgets = array();  
143 - $fields = $oFieldset->getFields(); 142 + $widgets = array();
  143 + $fields = $oFieldset->getFields();
144 144
145 - if ($oFieldset->getIsConditional()) {  
146 - $iMasterId = $oFieldset->getMasterFieldId(); 145 + if ($oFieldset->getIsConditional()) {
  146 + $iMasterId = $oFieldset->getMasterFieldId();
147 147
148 - $oMasterField = DocumentField::get($iMasterId); 148 + $oMasterField = DocumentField::get($iMasterId);
149 149
150 - $newfields = array();  
151 - $newfields[] = $oMasterField;  
152 - foreach($fields as $oField) {  
153 - if($oField->getId() != $iMasterId) {  
154 - $newfields[] = $oField;  
155 - }  
156 - } 150 + $newfields = array();
  151 + $newfields[] = $oMasterField;
  152 + foreach($fields as $oField) {
  153 + if($oField->getId() != $iMasterId) {
  154 + $newfields[] = $oField;
  155 + }
  156 + }
157 157
158 foreach ($newfields as $oField) { 158 foreach ($newfields as $oField) {
159 $fname = 'metadata_' . $oField->getId(); 159 $fname = 'metadata_' . $oField->getId();
160 $value = null; 160 $value = null;
161 - 161 +
162 if (!is_null($oDocument)) { 162 if (!is_null($oDocument)) {
163 $oFL = DocumentFieldLink::getByDocumentAndField($oDocument, $oField); 163 $oFL = DocumentFieldLink::getByDocumentAndField($oDocument, $oField);
164 if (!is_null($oFL) && (!PEAR::isError($oFL))) { 164 if (!is_null($oFL) && (!PEAR::isError($oFL))) {
@@ -166,7 +166,7 @@ class KTFieldsetRegistry { @@ -166,7 +166,7 @@ class KTFieldsetRegistry {
166 } 166 }
167 } 167 }
168 168
169 - $widgets[] = $this->oWF->get('ktcore.widgets.conditionalselection', 169 + $widgets[] = $this->oWF->get('ktcore.widgets.conditionalselection',
170 array( 170 array(
171 'label' => $oField->getName(), 171 'label' => $oField->getName(),
172 'required' => $oField->getIsMandatory(), 172 'required' => $oField->getIsMandatory(),
lib/session/Session.inc
@@ -228,7 +228,7 @@ class Session { @@ -228,7 +228,7 @@ class Session {
228 // Compare the system version and the database version to determine if the database needs to be upgraded. 228 // Compare the system version and the database version to determine if the database needs to be upgraded.
229 $version = KTUtil::getSystemSetting('databaseVersion'); 229 $version = KTUtil::getSystemSetting('databaseVersion');
230 230
231 - if ($default->systemVersion != $version) { 231 + if (trim($default->systemVersion) != trim($version)) {
232 if (KTLOG_CACHE) $default->log->info("Session::verify : Database not upgraded"); 232 if (KTLOG_CACHE) $default->log->info("Session::verify : Database not upgraded");
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'); 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 return PEAR::raiseError($_SESSION['errormessage']['login']); 234 return PEAR::raiseError($_SESSION['errormessage']['login']);
lib/widgets/forms.inc.php
@@ -328,7 +328,7 @@ class KTForm { @@ -328,7 +328,7 @@ class KTForm {
328 $aOldData = array(); 328 $aOldData = array();
329 $aErrors = array(); 329 $aErrors = array();
330 $old_data = KTUtil::arrayGet((array) $_SESSION['_kt_old_data'], 330 $old_data = KTUtil::arrayGet((array) $_SESSION['_kt_old_data'],
331 - $this->_kt_form_name, array()); 331 + $this->_kt_form_name, array());
332 if (KTUtil::arrayGet($old_data, 'identifier') == $this->sIdentifier) { 332 if (KTUtil::arrayGet($old_data, 'identifier') == $this->sIdentifier) {
333 $bUseOld = true; 333 $bUseOld = true;
334 $aStoredData = (array) unserialize(KTUtil::arrayGet($old_data, 'data')); 334 $aStoredData = (array) unserialize(KTUtil::arrayGet($old_data, 'data'));
presentation/lookAndFeel/knowledgeTree/documentmanagement/getTypeMetadataFields.php
@@ -44,6 +44,7 @@ require_once(KT_LIB_DIR . &#39;/metadata/fieldset.inc.php&#39;); @@ -44,6 +44,7 @@ require_once(KT_LIB_DIR . &#39;/metadata/fieldset.inc.php&#39;);
44 44
45 require_once(KT_LIB_DIR . '/widgets/fieldsetDisplay.inc.php'); 45 require_once(KT_LIB_DIR . '/widgets/fieldsetDisplay.inc.php');
46 require_once(KT_LIB_DIR . "/widgets/fieldWidgets.php"); 46 require_once(KT_LIB_DIR . "/widgets/fieldWidgets.php");
  47 +require_once(KT_LIB_DIR . "/widgets/forms.inc.php");
47 48
48 require_once(KT_LIB_DIR . "/metadata/fieldsetregistry.inc.php"); 49 require_once(KT_LIB_DIR . "/metadata/fieldsetregistry.inc.php");
49 require_once(KT_LIB_DIR . "/widgets/widgetfactory.inc.php"); 50 require_once(KT_LIB_DIR . "/widgets/widgetfactory.inc.php");
setup/migrate/steps/migrateInstallation.php
@@ -148,7 +148,7 @@ class migrateInstallation extends step @@ -148,7 +148,7 @@ class migrateInstallation extends step
148 return false; 148 return false;
149 } else { 149 } else {
150 $this->foundVersion = $this->readVersion(); 150 $this->foundVersion = $this->readVersion();
151 - if($version) { 151 + if($this->foundVersion) {
152 $this->checkVersion(); 152 $this->checkVersion();
153 } 153 }
154 $this->storeSilent(); 154 $this->storeSilent();
@@ -239,6 +239,8 @@ class migrateInstallation extends step @@ -239,6 +239,8 @@ class migrateInstallation extends step
239 ); 239 );
240 $ktSettings = $this->util->iniUtilities->getSection('KnowledgeTree'); 240 $ktSettings = $this->util->iniUtilities->getSection('KnowledgeTree');
241 $froot = $ktSettings['fileSystemRoot']; 241 $froot = $ktSettings['fileSystemRoot'];
  242 +// print_r($ktSettings);
  243 +// die;
242 if ($froot == 'default') { 244 if ($froot == 'default') {
243 $froot = $this->location; 245 $froot = $this->location;
244 } 246 }
setup/postcheckup.php
@@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
38 38
39 $checkup = true; 39 $checkup = true;
40 error_reporting(E_ALL); 40 error_reporting(E_ALL);
41 -require_once('../config/dmsDefaults.php'); 41 +//require_once('../config/dmsDefaults.php');
42 42
43 function writablePath($name, $path) { 43 function writablePath($name, $path) {
44 $ret = sprintf('<tr><td>%s (%s)</td><td>', $name, $path); 44 $ret = sprintf('<tr><td>%s (%s)</td><td>', $name, $path);
setup/precheckup.php
@@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
38 38
39 error_reporting(E_ALL); 39 error_reporting(E_ALL);
40 40
41 -require_once('../config/dmsDefaults.php'); 41 +//require_once('../config/dmsDefaults.php');
42 42
43 function get_php_setting($val) { 43 function get_php_setting($val) {
44 $r = (ini_get($val) == '1' ? 1 : 0); 44 $r = (ini_get($val) == '1' ? 1 : 0);
setup/upgrade/lib/UpgradeItems.inc.php
@@ -49,19 +49,24 @@ @@ -49,19 +49,24 @@
49 */ 49 */
50 // }}} 50 // }}}
51 51
52 -//require_once(KT_LIB_DIR . '/upgrades/UpgradeFunctions.inc.php');  
53 require_once('sqlfile.inc.php'); 52 require_once('sqlfile.inc.php');
54 -require_once('datetime.inc'); 53 +require_once('datetime.inc.php');
  54 +
  55 +require_once("../wizard/iniUtilities.php");
  56 +require_once("../wizard/dbUtilities.php");
55 57
56 // {{{ Upgrade_Already_Applied 58 // {{{ Upgrade_Already_Applied
57 -class Upgrade_Already_Applied { //extends PEAR_Error { 59 +class Upgrade_Already_Applied {
  60 +
58 function Upgrade_Already_Applied($oUpgradeItem) { 61 function Upgrade_Already_Applied($oUpgradeItem) {
59 $this->oUpgradeItem = $oUpgradeItem; 62 $this->oUpgradeItem = $oUpgradeItem;
60 } 63 }
  64 +
61 } 65 }
62 // }}} 66 // }}}
63 67
64 -class UpgradeItem extends InstallUtil { 68 +class UpgradeItem {
  69 +
65 var $type = ""; 70 var $type = "";
66 var $name; 71 var $name;
67 var $version; 72 var $version;
@@ -81,9 +86,9 @@ class UpgradeItem extends InstallUtil { @@ -81,9 +86,9 @@ class UpgradeItem extends InstallUtil {
81 $this->description = $description; 86 $this->description = $description;
82 $this->phase = $phase; 87 $this->phase = $phase;
83 $this->priority = $priority; 88 $this->priority = $priority;
84 - parent::__construct();  
85 -// print_r($this);  
86 -// die; 89 +
  90 + $this->dbUtilities = new dbUtilities();
  91 + $this->iniUtilities = new iniUtilities();
87 } 92 }
88 93
89 function setParent($parent) { 94 function setParent($parent) {
@@ -117,24 +122,41 @@ class UpgradeItem extends InstallUtil { @@ -117,24 +122,41 @@ class UpgradeItem extends InstallUtil {
117 return $this->type; 122 return $this->type;
118 } 123 }
119 124
120 - function runDBQuery($query) {  
121 - require_once("../wizard/steps/configuration.php"); // configuration to read the ini path 125 + /**
  126 + * Runs a DB query and returns a result based on arguments which specify what to look for
  127 + *
  128 + * @param string $query The query to run
  129 + * @param boolean $checkResult Whether to check that a result was found (not needed for update/delete, only select): This result may be empty
  130 + * @param boolean $resultCheck Whether to check for returned results from the query
  131 + * @return unknown
  132 + */
  133 + function runDBQuery($query, $checkResult = false, $resultCheck = false) {
  134 + if(!isset($this->iniUtilities) || !is_object($this->iniUtilities)) {
  135 + $this->dbUtilities = new dbUtilities();
  136 + $this->iniUtilities = new iniUtilities();
  137 + }
  138 +
122 $wizConfigHandler = new configuration(); 139 $wizConfigHandler = new configuration();
123 $configPath = $wizConfigHandler->readConfigPathIni(); 140 $configPath = $wizConfigHandler->readConfigPathIni();
124 - if(!is_object($this->iniUtilities)) {  
125 - parent::__construct();  
126 - } 141 +
127 $this->iniUtilities->load($configPath); 142 $this->iniUtilities->load($configPath);
128 $dconf = $this->iniUtilities->getSection('db'); 143 $dconf = $this->iniUtilities->getSection('db');
129 $this->dbUtilities->load($dconf['dbHost'], '', $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']); 144 $this->dbUtilities->load($dconf['dbHost'], '', $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']);
130 $result = $this->dbUtilities->query($query); 145 $result = $this->dbUtilities->query($query);
131 - $assArr = $this->dbUtilities->fetchAssoc($result);  
132 - return $assArr; 146 + if($checkResult) {
  147 + $assArr = $this->dbUtilities->fetchAssoc($result);
  148 + if($resultCheck) {
  149 + return !is_null($assArr);
  150 + } else {
  151 + return is_null($assArr);
  152 + }
  153 + }
  154 + return !is_null($result);
133 } 155 }
134 156
135 function _upgradeTableInstalled() { 157 function _upgradeTableInstalled() {
136 $query = "SELECT COUNT(id) FROM upgrades"; 158 $query = "SELECT COUNT(id) FROM upgrades";
137 - $res = $this->runDBQuery($query); 159 + $res = $this->runDBQuery($query, true, true);
138 if($res) { 160 if($res) {
139 return true; 161 return true;
140 } 162 }
@@ -146,8 +168,9 @@ class UpgradeItem extends InstallUtil { @@ -146,8 +168,9 @@ class UpgradeItem extends InstallUtil {
146 return false; 168 return false;
147 } 169 }
148 $query = "SELECT id FROM upgrades WHERE descriptor = '".$this->getDescriptor()."' AND result = 1"; 170 $query = "SELECT id FROM upgrades WHERE descriptor = '".$this->getDescriptor()."' AND result = 1";
149 - $res = $this->runDBQuery($query);  
150 - if($res) { 171 + $res = $this->runDBQuery($query, true, false);
  172 +
  173 + if(!$res) {
151 return true; 174 return true;
152 } 175 }
153 return false; 176 return false;
@@ -161,27 +184,23 @@ class UpgradeItem extends InstallUtil { @@ -161,27 +184,23 @@ class UpgradeItem extends InstallUtil {
161 return new Upgrade_Already_Applied($this); 184 return new Upgrade_Already_Applied($this);
162 } 185 }
163 } 186 }
164 -// if (PEAR::isError($res)) {  
165 -// return $res;  
166 -// }  
167 - $oCache =& KTCache::getSingleton();  
168 - $save = $oCache->bEnabled;  
169 - $oCache->bEnabled = false;  
170 $res = $this->_performUpgrade(); 187 $res = $this->_performUpgrade();
171 - $oCache->bEnabled = $save;  
172 -// if (PEAR::isError($res)) {  
173 -// $this->_recordUpgrade(false);  
174 -// return $res;  
175 -// } 188 + if (!$res) {
  189 + $this->_recordUpgrade(false);
  190 + $this->error[] = $this->dbUtilities->getErrors();
  191 + return false;
  192 + }
176 $res = $this->_recordUpgrade(true); 193 $res = $this->_recordUpgrade(true);
177 -// if (PEAR::isError($res)) {  
178 -// return $res;  
179 -// } 194 + if (!$res) {
  195 + $this->error[] = 'An Error Has Occured';
  196 + return false;
  197 + }
180 return true; 198 return true;
181 } 199 }
182 200
183 function _performUpgrade() { 201 function _performUpgrade() {
184 -// return PEAR::raiseError("Unimplemented"); 202 + $this->error[] = 'Unimplemented';
  203 + return false;
185 } 204 }
186 205
187 function _recordUpgrade($result) { 206 function _recordUpgrade($result) {
@@ -193,28 +212,20 @@ class UpgradeItem extends InstallUtil { @@ -193,28 +212,20 @@ class UpgradeItem extends InstallUtil {
193 } else { 212 } else {
194 $parentid = null; 213 $parentid = null;
195 } 214 }
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 - ));*/ 215 + $sql = "INSERT INTO upgrades (`id`, `descriptor`, `description`, `date_performed`, `result`, `parent`) VALUES (NULL, '". $this->getDescriptor()."', '".$this->description."', '".$this->date."', '".$result."', '".$parentid."')";
  216 + $this->dbUtilities->query($sql);
  217 +
  218 + return true;
207 } 219 }
208 220
209 - // STATIC  
210 function getAllUpgrades() { 221 function getAllUpgrades() {
211 return array(); 222 return array();
212 } 223 }
213 -  
214 224
215 -} 225 +} // end class UpgradeItem
216 226
217 class SQLUpgradeItem extends UpgradeItem { 227 class SQLUpgradeItem extends UpgradeItem {
  228 +
218 function SQLUpgradeItem($path, $version = null, $description = null, $phase = null, $priority = null) { 229 function SQLUpgradeItem($path, $version = null, $description = null, $phase = null, $priority = null) {
219 $this->type = "sql"; 230 $this->type = "sql";
220 $this->priority = 0; 231 $this->priority = 0;
@@ -249,19 +260,16 @@ class SQLUpgradeItem extends UpgradeItem { @@ -249,19 +260,16 @@ class SQLUpgradeItem extends UpgradeItem {
249 * 260 *
250 * STATIC 261 * STATIC
251 */ 262 */
252 - function getUpgrades($origVersion, $currVersion) {  
253 -// global $default;  
254 -  
255 -// $sqlupgradedir = KT_DIR . '/sql/' . $default->dbType . '/upgrade/';  
256 - $dbType = 'mysql';  
257 - $sqlupgradedir = KT_DIR . 'sql/' . $dbType . '/upgrade/'; 263 + public static function getUpgrades($origVersion, $currVersion) {
  264 + $dbType = 'mysql';
  265 + $sqlupgradedir = KT_DIR . 'sql/' . $dbType . '/upgrade/';
258 $ret = array(); 266 $ret = array();
259 267
260 if (!is_dir($sqlupgradedir)) { 268 if (!is_dir($sqlupgradedir)) {
261 -// return PEAR::raiseError("SQL Upgrade directory ($sqlupgradedir) not accessible"); 269 + return false;
262 } 270 }
263 if (!($dh = opendir($sqlupgradedir))) { 271 if (!($dh = opendir($sqlupgradedir))) {
264 -// return PEAR::raiseError("SQL Upgrade directory ($sqlupgradedir) not accessible"); 272 + return false;
265 } 273 }
266 274
267 while (($file = readdir($dh)) !== false) { 275 while (($file = readdir($dh)) !== false) {
@@ -289,9 +297,6 @@ class SQLUpgradeItem extends UpgradeItem { @@ -289,9 +297,6 @@ class SQLUpgradeItem extends UpgradeItem {
289 if (!lte_version($details[1], $currVersion)) { 297 if (!lte_version($details[1], $currVersion)) {
290 continue; 298 continue;
291 } 299 }
292 - //print "Will run $file\n";  
293 -// print_r($this->util->dbUtilities);  
294 -// die;  
295 $ret[] = new SQLUpgradeItem($file); 300 $ret[] = new SQLUpgradeItem($file);
296 } 301 }
297 } 302 }
@@ -310,10 +315,6 @@ class SQLUpgradeItem extends UpgradeItem { @@ -310,10 +315,6 @@ class SQLUpgradeItem extends UpgradeItem {
310 if (!lte_version($details[1], $currVersion)) { 315 if (!lte_version($details[1], $currVersion)) {
311 continue; 316 continue;
312 } 317 }
313 - //print "Will run $file\n";  
314 -// print_r(SQLUpgradeItem::);  
315 -// die;  
316 -// new InstallUtil();  
317 $ret[] = new SQLUpgradeItem($relpath); 318 $ret[] = new SQLUpgradeItem($relpath);
318 } 319 }
319 } 320 }
@@ -323,7 +324,7 @@ class SQLUpgradeItem extends UpgradeItem { @@ -323,7 +324,7 @@ class SQLUpgradeItem extends UpgradeItem {
323 return $ret; 324 return $ret;
324 } 325 }
325 326
326 - function _getDetailsFromFileName($path) { 327 + public static function _getDetailsFromFileName($path) {
327 // Old format (pre 2.0.6) 328 // Old format (pre 2.0.6)
328 $matched = preg_match('#^([\d.]*)-to-([\d.]*).sql$#', $path, $matches); 329 $matched = preg_match('#^([\d.]*)-to-([\d.]*).sql$#', $path, $matches);
329 if ($matched != 0) { 330 if ($matched != 0) {
@@ -358,18 +359,16 @@ class SQLUpgradeItem extends UpgradeItem { @@ -358,18 +359,16 @@ class SQLUpgradeItem extends UpgradeItem {
358 } 359 }
359 360
360 function _performUpgrade() { 361 function _performUpgrade() {
361 -// global $default;  
362 $dbType = 'mysql'; 362 $dbType = 'mysql';
363 $sqlupgradedir = KT_DIR . 'sql/' . $dbType . '/upgrade/'; 363 $sqlupgradedir = KT_DIR . 'sql/' . $dbType . '/upgrade/';
364 $queries = SQLFile::sqlFromFile($sqlupgradedir . $this->name); 364 $queries = SQLFile::sqlFromFile($sqlupgradedir . $this->name);
365 - exit('add code');  
366 -// return DBUtil::runQueries($queries, $default->_admindb); 365 + return $this->dbUtilities->runQueries($queries);
367 } 366 }
368 367
369 -  
370 -} 368 +} // end class SQLUpgradeItem
371 369
372 class KTRebuildPermissionObserver { 370 class KTRebuildPermissionObserver {
  371 +
373 function start() { 372 function start() {
374 $this->lastBeat = time(); 373 $this->lastBeat = time();
375 } 374 }
@@ -383,9 +382,11 @@ class KTRebuildPermissionObserver { @@ -383,9 +382,11 @@ class KTRebuildPermissionObserver {
383 } 382 }
384 function end() { 383 function end() {
385 } 384 }
  385 +
386 } 386 }
387 387
388 class RecordUpgradeItem extends UpgradeItem { 388 class RecordUpgradeItem extends UpgradeItem {
  389 +
389 function RecordUpgradeItem ($version, $oldversion = null) { 390 function RecordUpgradeItem ($version, $oldversion = null) {
390 $this->type = "upgrade"; 391 $this->type = "upgrade";
391 if (is_null($oldversion)) { 392 if (is_null($oldversion)) {
@@ -399,24 +400,30 @@ class RecordUpgradeItem extends UpgradeItem { @@ -399,24 +400,30 @@ class RecordUpgradeItem extends UpgradeItem {
399 } 400 }
400 401
401 function _performUpgrade() { 402 function _performUpgrade() {
402 -// $this->_deleteSmartyFiles();  
403 -// $this->_deleteProxyFiles();  
404 -// require_once(KT_LIB_DIR . '/cache/cache.inc.php');  
405 -// $oCache =& KTCache::getSingleton();  
406 -// $oCache->deleteAllCaches(); 403 + // What did this do?
  404 + /*
  405 + $this->_deleteSmartyFiles();
  406 + $this->_deleteProxyFiles();
  407 + require_once(KT_LIB_DIR . '/cache/cache.inc.php');
  408 + $oCache =& KTCache::getSingleton();
  409 + $oCache->deleteAllCaches();
407 // TODO : clear cache folder 410 // TODO : clear cache folder
408 -// require_once(KT_LIB_DIR . '/permissions/permissionutil.inc.php');  
409 - // TODO : What does this do  
410 -// $po =& new KTRebuildPermissionObserver($this);  
411 -// $po->start();  
412 -// $oChannel =& KTPermissionChannel::getSingleton();  
413 -// $oChannel->addObserver($po); 411 + require_once(KT_LIB_DIR . '/permissions/permissionutil.inc.php');
  412 + TODO : What does this do
  413 + $po =& new KTRebuildPermissionObserver($this);
  414 + $po->start();
  415 + $oChannel =& KTPermissionChannel::getSingleton();
  416 + $oChannel->addObserver($po);
  417 + */
414 418
415 set_time_limit(0); 419 set_time_limit(0);
416 ignore_user_abort(true); 420 ignore_user_abort(true);
417 421
418 -// KTPermissionUtil::rebuildPermissionLookups(true);  
419 -// $po->end(); 422 + // What did this do?
  423 + /*
  424 + KTPermissionUtil::rebuildPermissionLookups(true);
  425 + $po->end();
  426 + */
420 427
421 $versionFile=KT_DIR . '/docs/VERSION-NAME.txt'; 428 $versionFile=KT_DIR . '/docs/VERSION-NAME.txt';
422 $fp = fopen($versionFile,'rt'); 429 $fp = fopen($versionFile,'rt');
@@ -426,8 +433,8 @@ class RecordUpgradeItem extends UpgradeItem { @@ -426,8 +433,8 @@ class RecordUpgradeItem extends UpgradeItem {
426 $query = "UPDATE system_settings SET value = '$systemVersion' WHERE name = 'knowledgetreeVersion'"; 433 $query = "UPDATE system_settings SET value = '$systemVersion' WHERE name = 'knowledgetreeVersion'";
427 $this->runDBQuery($query); 434 $this->runDBQuery($query);
428 $query = "UPDATE system_settings SET value = '{$this->version}' WHERE name = 'databaseVersion'"; 435 $query = "UPDATE system_settings SET value = '{$this->version}' WHERE name = 'databaseVersion'";
429 - $assArray = $this->runDBQuery($query);  
430 - return !is_null($assArray); 436 + $result = $this->runDBQuery($query);
  437 + return $result;
431 } 438 }
432 439
433 function _deleteSmartyFiles() { 440 function _deleteSmartyFiles() {
@@ -452,7 +459,6 @@ class RecordUpgradeItem extends UpgradeItem { @@ -452,7 +459,6 @@ class RecordUpgradeItem extends UpgradeItem {
452 } 459 }
453 } 460 }
454 461
455 -  
456 function _deleteProxyFiles() { 462 function _deleteProxyFiles() {
457 $oKTConfig =& KTConfig::getSingleton(); 463 $oKTConfig =& KTConfig::getSingleton();
458 464
@@ -487,6 +493,7 @@ class RecordUpgradeItem extends UpgradeItem { @@ -487,6 +493,7 @@ class RecordUpgradeItem extends UpgradeItem {
487 @unlink($sFile); 493 @unlink($sFile);
488 } 494 }
489 } 495 }
490 -} 496 +
  497 +} // end class RecordUpgradeItem
491 498
492 ?> 499 ?>
setup/upgrade/lib/datetime.inc renamed to setup/upgrade/lib/datetime.inc.php
setup/upgrade/lib/upgrade.inc.php
@@ -40,31 +40,34 @@ @@ -40,31 +40,34 @@
40 40
41 require_once('UpgradeItems.inc.php'); 41 require_once('UpgradeItems.inc.php');
42 42
43 -//function setupAdminDatabase() {  
44 -// global $default;  
45 -// $dsn = array(  
46 -// 'phptype' => $default->dbType,  
47 -// 'username' => $default->dbAdminUser,  
48 -// 'password' => $default->dbAdminPass,  
49 -// 'hostspec' => $default->dbHost,  
50 -// 'database' => $default->dbName,  
51 -// 'port' => $default->dbPort,  
52 -// );  
53 -//  
54 -// $options = array(  
55 -// 'debug' => 2,  
56 -// 'portability' => DB_PORTABILITY_ERRORS,  
57 -// 'seqname_format' => 'zseq_%s',  
58 -// );  
59 -//  
60 -// $default->_admindb = &DB::connect($dsn, $options);  
61 -// if (PEAR::isError($default->_admindb)) {  
62 -// die($default->_admindb->toString());  
63 -// }  
64 -// $default->_admindb->setFetchMode(DB_FETCHMODE_ASSOC);  
65 -// return;  
66 -//}  
67 -//setupAdminDatabase(); 43 +// What did this do?
  44 +/*
  45 +function setupAdminDatabase() {
  46 + global $default;
  47 + $dsn = array(
  48 + 'phptype' => $default->dbType,
  49 + 'username' => $default->dbAdminUser,
  50 + 'password' => $default->dbAdminPass,
  51 + 'hostspec' => $default->dbHost,
  52 + 'database' => $default->dbName,
  53 + 'port' => $default->dbPort,
  54 + );
  55 +
  56 + $options = array(
  57 + 'debug' => 2,
  58 + 'portability' => DB_PORTABILITY_ERRORS,
  59 + 'seqname_format' => 'zseq_%s',
  60 + );
  61 +
  62 + $default->_admindb = &DB::connect($dsn, $options);
  63 + if (PEAR::isError($default->_admindb)) {
  64 + die($default->_admindb->toString());
  65 + }
  66 + $default->_admindb->setFetchMode(DB_FETCHMODE_ASSOC);
  67 + return;
  68 +}
  69 +setupAdminDatabase();
  70 +*/
68 71
69 // {{{ Format of the descriptor 72 // {{{ Format of the descriptor
70 /** 73 /**
@@ -92,25 +95,24 @@ function &amp;describeUpgrade ($origVersion, $currVersion) { @@ -92,25 +95,24 @@ function &amp;describeUpgrade ($origVersion, $currVersion) {
92 // How to figure out what upgrades to do: 95 // How to figure out what upgrades to do:
93 // 96 //
94 // 1. Get all SQL upgrades >= origVersion and <= currVersion 97 // 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 98 + // 2. Categorise each into version they upgrade to
  99 + // 3. Sort each version subgroup into correct order
98 // 5. Add "recordSubUpgrade" for each version there. 100 // 5. Add "recordSubUpgrade" for each version there.
99 - // 6. Add back into one big list again  
100 - // 7. Add "recordUpgrade" for whole thing 101 + // 5. Add back into one big list again
  102 + // 6. Add "recordUpgrade" for whole thing
101 103
102 // $recordUpgrade = array('upgrade*' . $currVersion, 'Upgrade to ' . $currVersion, null); 104 // $recordUpgrade = array('upgrade*' . $currVersion, 'Upgrade to ' . $currVersion, null);
103 105
104 $steps = array(); 106 $steps = array();
105 foreach (array('SQLUpgradeItem') as $itemgen) { 107 foreach (array('SQLUpgradeItem') as $itemgen) {
106 $f = array($itemgen, 'getUpgrades'); 108 $f = array($itemgen, 'getUpgrades');
107 - $ssteps =& call_user_func($f, $origVersion, $currVersion); 109 + $ssteps = call_user_func($f, $origVersion, $currVersion);
108 $scount = count($ssteps); 110 $scount = count($ssteps);
109 for ($i = 0; $i < $scount; $i++) { 111 for ($i = 0; $i < $scount; $i++) {
110 $steps[] =& $ssteps[$i]; 112 $steps[] =& $ssteps[$i];
111 } 113 }
112 } 114 }
113 - $upgradestep =& new RecordUpgradeItem($currVersion, $origVersion); 115 + $upgradestep = new RecordUpgradeItem($currVersion, $origVersion);
114 $steps[] =& $upgradestep; 116 $steps[] =& $upgradestep;
115 $stepcount = count($steps); 117 $stepcount = count($steps);
116 for ($i = 0; $i < $stepcount; $i++) { 118 for ($i = 0; $i < $stepcount; $i++) {
@@ -197,7 +199,7 @@ function compare_version($version1, $version2) { @@ -197,7 +199,7 @@ function compare_version($version1, $version2) {
197 */ 199 */
198 function lte_version($version1, $version2) { 200 function lte_version($version1, $version2) {
199 if (in_array(compare_version($version1, $version2), array(-1, 0))) { 201 if (in_array(compare_version($version1, $version2), array(-1, 0))) {
200 - return true; 202 + return true;
201 } 203 }
202 return false; 204 return false;
203 } 205 }
@@ -209,7 +211,7 @@ function lte_version($version1, $version2) { @@ -209,7 +211,7 @@ function lte_version($version1, $version2) {
209 */ 211 */
210 function gte_version($version1, $version2) { 212 function gte_version($version1, $version2) {
211 if (in_array(compare_version($version1, $version2), array(0, 1))) { 213 if (in_array(compare_version($version1, $version2), array(0, 1))) {
212 - return true; 214 + return true;
213 } 215 }
214 return false; 216 return false;
215 } 217 }
setup/upgrade/session.php
@@ -63,7 +63,7 @@ class session @@ -63,7 +63,7 @@ class session
63 */ 63 */
64 public function startSession() { 64 public function startSession() {
65 if(!isset($_SESSION[$this->salt]['ready'])) { 65 if(!isset($_SESSION[$this->salt]['ready'])) {
66 -// session_start(); 66 + session_start();
67 $_SESSION[$this->salt] ['ready'] = TRUE; 67 $_SESSION[$this->salt] ['ready'] = TRUE;
68 } 68 }
69 } 69 }
setup/upgrade/step.php
@@ -39,6 +39,9 @@ @@ -39,6 +39,9 @@
39 * @package Upgrader 39 * @package Upgrader
40 * @version Version 0.1 40 * @version Version 0.1
41 */ 41 */
  42 +
  43 +require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
  44 +
42 class Step 45 class Step
43 { 46 {
44 /** 47 /**
@@ -435,6 +438,44 @@ class Step @@ -435,6 +438,44 @@ class Step
435 438
436 return $_SESSION[$package][$class]; 439 return $_SESSION[$package][$class];
437 } 440 }
  441 +
  442 + protected function readConfig() {
  443 + $wizConfigHandler = new configuration();
  444 + $path = $wizConfigHandler->readConfigPathIni();
  445 + $this->util->iniUtilities->load($path);
  446 + $dbSettings = $this->util->iniUtilities->getSection('db');
  447 + $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'],
  448 + 'dbName'=> $dbSettings['dbName'],
  449 + 'dbUser'=> $dbSettings['dbUser'],
  450 + 'dbPass'=> $dbSettings['dbPass'],
  451 + 'dbPort'=> $dbSettings['dbPort'],
  452 + 'dbAdminUser'=> $dbSettings['dbAdminUser'],
  453 + 'dbAdminPass'=> $dbSettings['dbAdminPass'],
  454 + );
  455 + $this->paths = $this->util->iniUtilities->getSection('urls');
  456 + $this->paths = array_merge($this->paths, $this->util->iniUtilities->getSection('cache'));
  457 + $this->sysVersion = $this->readVersion();
  458 + $this->cachePath = $wizConfigHandler->readCachePath();
  459 + $this->proxyPath = $this->cachePath."/.."; // Total guess.
  460 + $this->proxyPath = realpath($this->proxyPath."/proxies");
  461 + $this->storeSilent();
  462 + }
  463 +
  464 + protected function readVersion() {
  465 + $verFile = SYSTEM_DIR."docs".DS."VERSION.txt";
  466 + if(file_exists($verFile)) {
  467 + $foundVersion = file_get_contents($verFile);
  468 + return $foundVersion;
  469 + } else {
  470 + $this->error[] = "KT installation version not found";
  471 + }
  472 +
  473 + return false;
  474 + }
  475 +
  476 + protected function storeSilent() {
  477 +
  478 + }
438 } 479 }
439 480
440 ?> 481 ?>
441 \ No newline at end of file 482 \ No newline at end of file
setup/upgrade/stepAction.php
@@ -382,12 +382,12 @@ class stepAction { @@ -382,12 +382,12 @@ class stepAction {
382 $step_errors = $this->action->getErrors(); // Get errors 382 $step_errors = $this->action->getErrors(); // Get errors
383 $step_warnings = $this->action->getWarnings(); // Get warnings 383 $step_warnings = $this->action->getWarnings(); // Get warnings
384 if($this->displayConfirm()) { // Check if theres a confirm step 384 if($this->displayConfirm()) { // Check if theres a confirm step
385 - $template = "templates/{$this->stepName}_confirm.tpl"; 385 + $template = "templates" . DS . "{$this->stepName}_confirm.tpl";
386 } else { 386 } else {
387 if($this->displayFirst()) { 387 if($this->displayFirst()) {
388 - $template = "templates/{$this->stepName}_confirm.tpl"; 388 + $template = "templates" . DS . "{$this->stepName}_confirm.tpl";
389 } else { 389 } else {
390 - $template = "templates/{$this->stepName}.tpl"; 390 + $template = "templates" . DS . "{$this->stepName}.tpl";
391 } 391 }
392 } 392 }
393 $step_tpl = new Template($template); 393 $step_tpl = new Template($template);
@@ -402,7 +402,7 @@ class stepAction { @@ -402,7 +402,7 @@ class stepAction {
402 } 402 }
403 } 403 }
404 $content = $step_tpl->fetch(); 404 $content = $step_tpl->fetch();
405 - $tpl = new Template("templates/wizard.tpl"); 405 + $tpl = new Template("templates" . DS . "wizard.tpl");
406 $vars = $this->getVars(); // Get template variables 406 $vars = $this->getVars(); // Get template variables
407 $tpl->set("vars", $vars); // Set template errors 407 $tpl->set("vars", $vars); // Set template errors
408 $tpl->set('content', $content); 408 $tpl->set('content', $content);
setup/upgrade/steps/upgradeBackup.php
@@ -40,9 +40,8 @@ @@ -40,9 +40,8 @@
40 * @version Version 0.1 40 * @version Version 0.1
41 */ 41 */
42 42
43 -//require_once('../../config/dmsDefaults.php');  
44 -  
45 class upgradeBackup extends Step { 43 class upgradeBackup extends Step {
  44 +
46 protected $silent = false; 45 protected $silent = false;
47 protected $temp_variables = array(); 46 protected $temp_variables = array();
48 47
@@ -83,13 +82,14 @@ class upgradeBackup extends Step { @@ -83,13 +82,14 @@ class upgradeBackup extends Step {
83 return 'landing'; 82 return 'landing';
84 } 83 }
85 84
86 - private function backupNow()  
87 - { 85 + private function backupNow() {
88 return isset($_POST['BackupNow']); 86 return isset($_POST['BackupNow']);
89 } 87 }
90 88
91 private function doRun($action = null) { 89 private function doRun($action = null) {
  90 + $this->readConfig();
92 $this->temp_variables['action'] = $action; 91 $this->temp_variables['action'] = $action;
  92 + $this->temp_variables['backupStatus'] = false;
93 93
94 if (is_null($action) || ($action == 'confirm')) { 94 if (is_null($action) || ($action == 'confirm')) {
95 $this->temp_variables['title'] = 'Confirm Backup'; 95 $this->temp_variables['title'] = 'Confirm Backup';
@@ -101,18 +101,10 @@ class upgradeBackup extends Step { @@ -101,18 +101,10 @@ class upgradeBackup extends Step {
101 // TODO error checking (done in backupDone at the moment) 101 // TODO error checking (done in backupDone at the moment)
102 $this->backupDone(); 102 $this->backupDone();
103 } 103 }
104 - $this->storeSilent();// Set silent mode variables  
105 104
106 return true; 105 return true;
107 } 106 }
108 107
109 - /**  
110 - * Set all silent mode varibles  
111 - *  
112 - */  
113 - private function storeSilent() {  
114 - }  
115 -  
116 private function backup() { 108 private function backup() {
117 $targetfile = $_SESSION['backupFile']; 109 $targetfile = $_SESSION['backupFile'];
118 $stmt = $this->create_backup_stmt($targetfile); 110 $stmt = $this->create_backup_stmt($targetfile);
@@ -126,11 +118,11 @@ class upgradeBackup extends Step { @@ -126,11 +118,11 @@ class upgradeBackup extends Step {
126 $handle = popen($stmt['cmd'], 'r'); 118 $handle = popen($stmt['cmd'], 'r');
127 $read = fread($handle, 10240); 119 $read = fread($handle, 10240);
128 pclose($handle); 120 pclose($handle);
129 - $_SESSION['backupOutput']=$read; 121 + $_SESSION['backupOutput'] = $read;
130 $dir = $this->util->resolveTempDir(); 122 $dir = $this->util->resolveTempDir();
131 - $_SESSION['backupFile'] = $stmt['target']; 123 + $_SESSION['backupFile'] = $stmt['target'];
132 124
133 - if (OS_UNIX) { 125 + if (!WINDOWS_OS) {
134 chmod($stmt['target'],0600); 126 chmod($stmt['target'],0600);
135 } 127 }
136 128
@@ -151,7 +143,7 @@ class upgradeBackup extends Step { @@ -151,7 +143,7 @@ class upgradeBackup extends Step {
151 143
152 if ($status) 144 if ($status)
153 { 145 {
154 - $stmt = $this->util->create_restore_stmt($filename); 146 + $stmt = $this->util->create_restore_stmt($filename, $this->dbSettings);
155 $this->temp_variables['display'] = 'The backup file <nobr><i>"' . $filename . '"</i></nobr> has been created. 147 $this->temp_variables['display'] = 'The backup file <nobr><i>"' . $filename . '"</i></nobr> has been created.
156 <P> It appears as though the <font color=green>backup has been successful</font>. 148 <P> It appears as though the <font color=green>backup has been successful</font>.
157 <P>'; 149 <P>';
@@ -193,56 +185,54 @@ class upgradeBackup extends Step { @@ -193,56 +185,54 @@ class upgradeBackup extends Step {
193 } 185 }
194 186
195 private function create_backup_stmt($targetfile=null) 187 private function create_backup_stmt($targetfile=null)
196 - {  
197 - $oKTConfig =& KTConfig::getSingleton();  
198 -  
199 - $adminUser = $oKTConfig->get('db/dbAdminUser');  
200 - $adminPwd = $oKTConfig->get('db/dbAdminPass');  
201 - $dbHost = $oKTConfig->get('db/dbHost');  
202 - $dbName = $oKTConfig->get('db/dbName');  
203 -  
204 - $dbPort = trim($oKTConfig->get('db/dbPort')); 188 + {
  189 + $adminUser = $this->dbSettings['dbAdminUser'];
  190 + $adminPwd = $this->dbSettings['dbAdminPass'];
  191 + $dbHost = $this->dbSettings['dbHost'];
  192 + $dbName = $this->dbSettings['dbName'];
  193 +
  194 + $dbPort = trim($this->dbSettings['dbPort']);
205 if (empty($dbPort) || $dbPort=='default') $dbPort = get_cfg_var('mysql.default_port'); 195 if (empty($dbPort) || $dbPort=='default') $dbPort = get_cfg_var('mysql.default_port');
206 if (empty($dbPort)) $dbPort='3306'; 196 if (empty($dbPort)) $dbPort='3306';
207 - $dbSocket = trim($oKTConfig->get('db/dbSocket')); 197 + // dbSocket doesn't exist as far as I can find, where was it coming from?
  198 + //$dbSocket = trim($this->dbSettings['dbSocket']);
  199 + $dbSocket = '';
208 if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); 200 if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket');
209 if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; 201 if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock';
210 202
211 $date=date('Y-m-d-H-i-s'); 203 $date=date('Y-m-d-H-i-s');
212 204
213 - $dir=$this->util->resolveMysqlDir(); 205 + $dir = $this->util->resolveMysqlDir();
214 206
215 - $info['dir']=$dir;  
216 -  
217 - $prefix='';  
218 - if (OS_UNIX) 207 + $info['dir'] = $dir;
  208 + $prefix = '';
  209 + if (!WINDOWS_OS)
219 { 210 {
220 $prefix .= "./"; 211 $prefix .= "./";
221 } 212 }
222 213
223 if (@stat($dbSocket) !== false) 214 if (@stat($dbSocket) !== false)
224 { 215 {
225 - $mechanism="--socket=\"$dbSocket\""; 216 + $mechanism = "--socket=\"$dbSocket\"";
226 } 217 }
227 else 218 else
228 { 219 {
229 - $mechanism="--port=\"$dbPort\""; 220 + $mechanism = "--port=\"$dbPort\"";
230 } 221 }
231 222
232 - $tmpdir=$this->util->resolveTempDir(); 223 + $tmpdir = $this->util->resolveTempDir();
233 224
234 if (is_null($targetfile)) 225 if (is_null($targetfile))
235 { 226 {
236 - $targetfile="$tmpdir/kt-backup-$date.sql"; 227 + $targetfile = "$tmpdir/kt-backup-$date.sql";
237 } 228 }
238 229
239 $stmt = $prefix . "mysqldump --user=\"$adminUser\" -p $mechanism \"$dbName\" > \"$targetfile\""; 230 $stmt = $prefix . "mysqldump --user=\"$adminUser\" -p $mechanism \"$dbName\" > \"$targetfile\"";
240 - $info['display']=$stmt;  
241 - $info['target']=$targetfile;  
242 - 231 + $info['display'] = $stmt;
  232 + $info['target'] = $targetfile;
243 233
244 $stmt = $prefix. "mysqldump --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" > \"$targetfile\""; 234 $stmt = $prefix. "mysqldump --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" > \"$targetfile\"";
245 - $info['cmd']=$stmt; 235 + $info['cmd'] = $stmt;
246 return $info; 236 return $info;
247 } 237 }
248 238
@@ -255,5 +245,6 @@ class upgradeBackup extends Step { @@ -255,5 +245,6 @@ class upgradeBackup extends Step {
255 $this->temp_variables['dir'] = $dir; 245 $this->temp_variables['dir'] = $dir;
256 $this->temp_variables['display'] = $stmt['display']; 246 $this->temp_variables['display'] = $stmt['display'];
257 } 247 }
  248 +
258 } 249 }
259 ?> 250 ?>
260 \ No newline at end of file 251 \ No newline at end of file
setup/upgrade/steps/upgradeComplete.php
@@ -40,8 +40,6 @@ @@ -40,8 +40,6 @@
40 * @version Version 0.1 40 * @version Version 0.1
41 */ 41 */
42 42
43 -//require_once('../../config/dmsDefaults.php');  
44 -  
45 class upgradeComplete extends Step { 43 class upgradeComplete extends Step {
46 44
47 protected $silent = false; 45 protected $silent = false;
@@ -50,6 +48,7 @@ class upgradeComplete extends Step { @@ -50,6 +48,7 @@ class upgradeComplete extends Step {
50 48
51 public function doStep() { 49 public function doStep() {
52 $this->temp_variables = array("step_name"=>"complete", "silent"=>$this->silent); 50 $this->temp_variables = array("step_name"=>"complete", "silent"=>$this->silent);
  51 +
53 $this->doRun(); 52 $this->doRun();
54 return 'landing'; 53 return 'landing';
55 } 54 }
@@ -62,7 +61,9 @@ class upgradeComplete extends Step { @@ -62,7 +61,9 @@ class upgradeComplete extends Step {
62 * Set all silent mode varibles 61 * Set all silent mode varibles
63 * 62 *
64 */ 63 */
65 - private function storeSilent() { 64 + protected function storeSilent() {
  65 + $v = $this->getDataFromSession('upgradeProperties');
  66 + $this->temp_variables['sysVersion'] = $v['upgrade_version'];
66 } 67 }
67 68
68 } 69 }
setup/upgrade/steps/upgradeDatabase.php
@@ -40,12 +40,9 @@ @@ -40,12 +40,9 @@
40 * @version Version 0.1 40 * @version Version 0.1
41 */ 41 */
42 42
43 -//require_once('../../config/dmsDefaults.php');  
44 -//require_once(KT_LIB_DIR . '/config/config.inc.php');  
45 -//require_once(KT_LIB_DIR . '/plugins/pluginutil.inc.php');  
46 define('KT_DIR', SYSTEM_DIR); 43 define('KT_DIR', SYSTEM_DIR);
47 define('KT_LIB_DIR', SYSTEM_DIR.'lib'); 44 define('KT_LIB_DIR', SYSTEM_DIR.'lib');
48 -//require_once(SYSTEM_DIR . 'lib/upgrades/upgrade.inc.php'); 45 +require_once(WIZARD_LIB . 'upgrade.inc.php');
49 46
50 class upgradeDatabase extends Step 47 class upgradeDatabase extends Step
51 { 48 {
@@ -68,15 +65,6 @@ class upgradeDatabase extends Step @@ -68,15 +65,6 @@ class upgradeDatabase extends Step
68 private $dbBinary = ''; // TODO:multiple databases 65 private $dbBinary = ''; // TODO:multiple databases
69 66
70 /** 67 /**
71 - * List of errors encountered  
72 - *  
73 - * @author KnowledgeTree Team  
74 - * @access public  
75 - * @var array  
76 - */  
77 - public $error = array();  
78 -  
79 - /**  
80 * List of errors used in template 68 * List of errors used in template
81 * 69 *
82 * @author KnowledgeTree Team 70 * @author KnowledgeTree Team
@@ -93,11 +81,13 @@ class upgradeDatabase extends Step @@ -93,11 +81,13 @@ class upgradeDatabase extends Step
93 * @var array 81 * @var array
94 */ 82 */
95 public $storeInSession = true; 83 public $storeInSession = true;
  84 +
96 public $sysVersion = ''; 85 public $sysVersion = '';
97 protected $silent = false; 86 protected $silent = false;
98 protected $temp_variables = array(); 87 protected $temp_variables = array();
99 public $paths = ''; 88 public $paths = '';
100 - /** 89 +
  90 + /**
101 * Main control of database setup 91 * Main control of database setup
102 * 92 *
103 * @author KnowledgeTree Team 93 * @author KnowledgeTree Team
@@ -143,17 +133,11 @@ class upgradeDatabase extends Step @@ -143,17 +133,11 @@ class upgradeDatabase extends Step
143 } 133 }
144 134
145 private function doRun($action = null) { 135 private function doRun($action = null) {
146 -// $this->readConfig(KTConfig::getConfigFilename());  
147 -  
148 $this->readConfig(); 136 $this->readConfig();
149 -// if($this->dbSettings['dbPort'] == '') {  
150 -// $con = $this->util->dbUtilities->load($this->dbSettings['dbHost'], '', $this->dbSettings['dbUser'],$this->dbSettings['dbPass'], $this->dbSettings['dbName']);  
151 -// } else {  
152 - $con = $this->util->dbUtilities->load($this->dbSettings['dbHost'], $this->dbSettings['dbPort'], $this->dbSettings['dbUser'],  
153 - $this->dbSettings['dbPass'], $this->dbSettings['dbName']);  
154 -// }  
155 137
  138 + $con = $this->util->dbUtilities->load($this->dbSettings['dbHost'], $this->dbSettings['dbPort'], $this->dbSettings['dbUser'],$this->dbSettings['dbPass'], $this->dbSettings['dbName']);
156 $this->temp_variables['action'] = $action; 139 $this->temp_variables['action'] = $action;
  140 +
157 if (is_null($action) || ($action == 'preview')) { 141 if (is_null($action) || ($action == 'preview')) {
158 $this->temp_variables['title'] = 'Preview Upgrade'; 142 $this->temp_variables['title'] = 'Preview Upgrade';
159 $this->temp_variables['upgradeTable'] = $this->generateUpgradeTable(); 143 $this->temp_variables['upgradeTable'] = $this->generateUpgradeTable();
@@ -178,15 +162,16 @@ class upgradeDatabase extends Step @@ -178,15 +162,16 @@ class upgradeDatabase extends Step
178 $this->sysVersion = $this->readVersion(); 162 $this->sysVersion = $this->readVersion();
179 $this->temp_variables['systemVersion'] = $this->sysVersion; 163 $this->temp_variables['systemVersion'] = $this->sysVersion;
180 $dconf = $this->util->iniUtilities->getSection('db'); 164 $dconf = $this->util->iniUtilities->getSection('db');
181 - $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', 'system_settings');  
182 $this->util->dbUtilities->load($dconf['dbHost'], '', $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']); 165 $this->util->dbUtilities->load($dconf['dbHost'], '', $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']);
  166 +
  167 + $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', 'system_settings');
183 $result = $this->util->dbUtilities->query($query); 168 $result = $this->util->dbUtilities->query($query);
184 $assArr = $this->util->dbUtilities->fetchAssoc($result); 169 $assArr = $this->util->dbUtilities->fetchAssoc($result);
185 if ($result) { 170 if ($result) {
186 $lastVersion = $assArr[0]['value']; 171 $lastVersion = $assArr[0]['value'];
187 } 172 }
188 $currentVersion = $this->sysVersion; 173 $currentVersion = $this->sysVersion;
189 - require_once("lib/upgrade.inc.php"); 174 +
190 $upgrades = describeUpgrade($lastVersion, $currentVersion); 175 $upgrades = describeUpgrade($lastVersion, $currentVersion);
191 $ret = "<table border=1 cellpadding=1 cellspacing=1 width='100%'>\n"; 176 $ret = "<table border=1 cellpadding=1 cellspacing=1 width='100%'>\n";
192 $ret .= "<tr bgcolor='darkgrey'><th width='10'>Code</th><th width='100%'>Description</th><th width='30'>Applied</th></tr>\n"; 177 $ret .= "<tr bgcolor='darkgrey'><th width='10'>Code</th><th width='100%'>Description</th><th width='30'>Applied</th></tr>\n";
@@ -214,30 +199,6 @@ class upgradeDatabase extends Step @@ -214,30 +199,6 @@ class upgradeDatabase extends Step
214 199
215 return false; 200 return false;
216 } 201 }
217 - /**  
218 - * Stores varibles used by template  
219 - *  
220 - * @author KnowledgeTree Team  
221 - * @params none  
222 - * @access public  
223 - * @return array  
224 - */  
225 - public function getStepVars() {  
226 - return $this->temp_variables;  
227 - }  
228 -  
229 - /**  
230 - * Returns database errors  
231 - *  
232 - * @author KnowledgeTree Team  
233 - * @access public  
234 - * @params none  
235 - * @return array  
236 - */  
237 - public function getErrors() {  
238 -  
239 - return $this->error;  
240 - }  
241 202
242 /** 203 /**
243 * Initialize errors to false 204 * Initialize errors to false
@@ -253,25 +214,11 @@ class upgradeDatabase extends Step @@ -253,25 +214,11 @@ class upgradeDatabase extends Step
253 } 214 }
254 } 215 }
255 216
256 - private function readConfig() {  
257 - require_once("../wizard/steps/configuration.php"); // configuration to read the ini path  
258 - $wizConfigHandler = new configuration();  
259 - $path = $wizConfigHandler->readConfigPathIni();  
260 - $this->util->iniUtilities->load($path);  
261 - $dbSettings = $this->util->iniUtilities->getSection('db');  
262 - $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'],  
263 - 'dbName'=> $dbSettings['dbName'],  
264 - 'dbUser'=> $dbSettings['dbUser'],  
265 - 'dbPass'=> $dbSettings['dbPass'],  
266 - 'dbPort'=> $dbSettings['dbPort'],  
267 - 'dbAdminUser'=> $dbSettings['dbAdminUser'],  
268 - 'dbAdminPass'=> $dbSettings['dbAdminPass'],  
269 - );  
270 - $this->paths = $this->util->iniUtilities->getSection('urls');  
271 - $this->paths = array_merge($this->paths, $this->util->iniUtilities->getSection('cache'));  
272 - $this->temp_variables['dbSettings'] = $this->dbSettings;  
273 - $this->sysVersion = $this->readVersion();  
274 - $this->cachePath = $wizConfigHandler->readCachePath(); 217 + public function storeSilent() {
  218 + $this->temp_variables['paths'] = $this->paths;
  219 + $this->temp_variables['sysVersion'] = $this->sysVersion;
  220 + $this->temp_variables['sysVersion'] = $this->sysVersion;
  221 + $this->temp_variables['dbSettings'] = $this->dbSettings;
275 } 222 }
276 223
277 private function upgradeConfirm() 224 private function upgradeConfirm()
@@ -286,8 +233,6 @@ class upgradeDatabase extends Step @@ -286,8 +233,6 @@ class upgradeDatabase extends Step
286 233
287 private function doDatabaseUpgrade() 234 private function doDatabaseUpgrade()
288 { 235 {
289 -// global $default;  
290 -  
291 $errors = false; 236 $errors = false;
292 237
293 $this->temp_variables['detail'] = '<p>The table below describes the upgrades that have occurred to 238 $this->temp_variables['detail'] = '<p>The table below describes the upgrades that have occurred to
@@ -295,18 +240,10 @@ class upgradeDatabase extends Step @@ -295,18 +240,10 @@ class upgradeDatabase extends Step
295 240
296 $pre_res = $this->performPreUpgradeActions(); 241 $pre_res = $this->performPreUpgradeActions();
297 242
298 - if (PEAR::isError($pre_res)) {  
299 - $errors = true;  
300 - $this->temp_variables['preUpgrade'] = '<font color="red">Pre-Upgrade actions failed.</font>';  
301 - }  
302 - else {  
303 - $this->temp_variables['preUpgrade'] = '<font color="green">Pre-Upgrade actions succeeded.</font>';  
304 -  
305 - }  
306 -  
307 $res = $this->performAllUpgrades(); 243 $res = $this->performAllUpgrades();
308 - if (PEAR::isError($res) || PEAR::isError($pres)) { 244 + if (!$res) {
309 $errors = true; 245 $errors = true;
  246 + $this->error[] = 'An Error has occured';
310 // TODO instantiate error details hideable section? 247 // TODO instantiate error details hideable section?
311 $this->temp_variables['upgradeStatus'] = '<font color="red">Database upgrade failed</font> 248 $this->temp_variables['upgradeStatus'] = '<font color="red">Database upgrade failed</font>
312 <br/><br/> 249 <br/><br/>
@@ -320,13 +257,7 @@ class upgradeDatabase extends Step @@ -320,13 +257,7 @@ class upgradeDatabase extends Step
320 } 257 }
321 258
322 $post_pres = $this->performPostUpgradeActions(); 259 $post_pres = $this->performPostUpgradeActions();
323 - if (PEAR::isError($post_res)) {  
324 - $errors = true;  
325 - $this->temp_variables['postUpgrade'] = '<font color="red">Post-Upgrade actions failed.</font>';  
326 - }  
327 - else {  
328 - $this->temp_variables['postUpgrade'] = '<font color="green">Post-Upgrade actions succeeded.</font>';  
329 - } 260 +
330 261
331 return !$errors; 262 return !$errors;
332 } 263 }
@@ -335,40 +266,59 @@ class upgradeDatabase extends Step @@ -335,40 +266,59 @@ class upgradeDatabase extends Step
335 266
336 // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works. 267 // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works.
337 // It should idealy work the same as the upgrades. 268 // It should idealy work the same as the upgrades.
338 -  
339 -// global $default;  
340 -// print_r($this->paths);die;  
341 // Lock the scheduler 269 // Lock the scheduler
342 - $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock';  
343 - touch($lockFile); 270 + $lockFile = $this->cachePath . DIRECTORY_SEPARATOR . 'scheduler.lock';
  271 + @touch($lockFile);
344 return true; 272 return true;
345 273
346 } 274 }
347 275
  276 + private function deleteDirectory($sPath) {
  277 + if (empty($sPath) || !is_dir($sPath)) return;
  278 +
  279 + if (!WINDOWS_OS) {
  280 + if (file_exists('/bin/rm')) {
  281 + $this->util->pexec(array('/bin/rm', '-rf', $sPath));
  282 + return;
  283 + }
  284 + }
  285 + if (WINDOWS_OS) {
  286 + // Potentially kills off all the files in the path, speeding
  287 + // things up a bit
  288 + exec("del /q /s " . escapeshellarg($sPath));
  289 + }
  290 + $hPath = @opendir($sPath);
  291 + while (($sFilename = readdir($hPath)) !== false) {
  292 + if (in_array($sFilename, array('.', '..'))) {
  293 + continue;
  294 + }
  295 + $sFullFilename = sprintf("%s/%s", $sPath, $sFilename);
  296 + if (is_dir($sFullFilename)) {
  297 + $this->deleteDirectory($sFullFilename);
  298 + continue;
  299 + }
  300 + @chmod($sFullFilename, 0666);
  301 + @unlink($sFullFilename);
  302 + }
  303 + closedir($hPath);
  304 + @rmdir($sPath);
  305 + }
  306 +
348 private function performPostUpgradeActions() { 307 private function performPostUpgradeActions() {
349 308
350 // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works. 309 // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works.
351 // It should idealy work the same as the upgrades. 310 // It should idealy work the same as the upgrades.
352 311
353 -// global $default;  
354 -  
355 // Ensure all plugins are re-registered. 312 // Ensure all plugins are re-registered.
356 $sql = "TRUNCATE plugin_helper"; 313 $sql = "TRUNCATE plugin_helper";
357 - $res = DBUtil::runQuery($sql);  
358 - 314 + $res = $this->util->dbUtilities->query($sql);
  315 +
359 // Clear out all caches and proxies - they need to be regenerated with the new code 316 // Clear out all caches and proxies - they need to be regenerated with the new code
360 - $proxyDir = $default->proxyCacheDirectory;  
361 - KTUtil::deleteDirectory($proxyDir);  
362 -  
363 - $oKTCache = new KTCache();  
364 - $oKTCache->deleteAllCaches();  
365 -  
366 - // Clear the configuration cache, it'll regenerate on next load  
367 - $oKTConfig = new KTConfig();  
368 - $oKTConfig->clearCache(); 317 + $this->deleteDirectory($this->proxyPath);
  318 + $this->deleteDirectory($this->cachePath);
369 319
370 // Unlock the scheduler 320 // Unlock the scheduler
371 - $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock'; 321 + $lockFile = $this->cachePath . DIRECTORY_SEPARATOR . 'scheduler.lock';
372 if(file_exists($lockFile)){ 322 if(file_exists($lockFile)){
373 @unlink($lockFile); 323 @unlink($lockFile);
374 } 324 }
@@ -378,18 +328,15 @@ class upgradeDatabase extends Step @@ -378,18 +328,15 @@ class upgradeDatabase extends Step
378 } 328 }
379 329
380 private function performAllUpgrades () { 330 private function performAllUpgrades () {
381 -// global $default;  
382 -  
383 $row = 1; 331 $row = 1;
384 -  
385 - $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table);  
386 - $lastVersion = DBUtil::getOneResultKey($query, 'value');  
387 - $currentVersion = $default->systemVersion;  
388 - 332 + $table = 'system_settings';
  333 + $query = "SELECT value FROM $table WHERE name = 'databaseVersion'";
  334 + $result = $this->util->dbUtilities->query($query);
  335 + $assArr = $this->util->dbUtilities->fetchAssoc($result);
  336 + $lastVersion = $assArr[0]['value'];
  337 + $currentVersion = $this->sysVersion;
389 $upgrades = describeUpgrade($lastVersion, $currentVersion); 338 $upgrades = describeUpgrade($lastVersion, $currentVersion);
390 -  
391 $this->temp_variables['upgradeTable'] = ''; 339 $this->temp_variables['upgradeTable'] = '';
392 -  
393 foreach ($upgrades as $upgrade) { 340 foreach ($upgrades as $upgrade) {
394 if (($row % 2) == 1) { 341 if (($row % 2) == 1) {
395 $class = "odd"; 342 $class = "odd";
@@ -403,15 +350,8 @@ class upgradeDatabase extends Step @@ -403,15 +350,8 @@ class upgradeDatabase extends Step
403 $this->temp_variables['upgradeTable'] .= sprintf('<div class="bar">%s</div>', $this->showResult($res)); 350 $this->temp_variables['upgradeTable'] .= sprintf('<div class="bar">%s</div>', $this->showResult($res));
404 $this->temp_variables['upgradeTable'] .= '<br>' . "\n"; 351 $this->temp_variables['upgradeTable'] .= '<br>' . "\n";
405 $this->temp_variables['upgradeTable'] .= "</div>\n"; 352 $this->temp_variables['upgradeTable'] .= "</div>\n";
406 - if (PEAR::isError($res)) {  
407 - if (!is_a($res, 'Upgrade_Already_Applied')) {  
408 - break;  
409 - } else {  
410 - $res = true;  
411 - }  
412 - }  
413 if ($res === false) { 353 if ($res === false) {
414 - $res = PEAR::raiseError("Upgrade returned false"); 354 + $this->error = $this->util->dbUtilities->getErrors();
415 break; 355 break;
416 } 356 }
417 } 357 }
@@ -420,11 +360,8 @@ class upgradeDatabase extends Step @@ -420,11 +360,8 @@ class upgradeDatabase extends Step
420 } 360 }
421 361
422 private function showResult($res) { 362 private function showResult($res) {
423 - if (PEAR::isError($res)) {  
424 - if (is_a($res, 'Upgrade_Already_Applied')) {  
425 - return '<span style="color: orange">Already applied</span>';  
426 - }  
427 - return sprintf('<span style="color: red">%s</span>', htmlspecialchars($res->toString())); 363 + if ($res && is_a($res, 'Upgrade_Already_Applied')) {
  364 + return '<span style="color: orange">Already applied</span>';
428 } 365 }
429 if ($res === true) { 366 if ($res === true) {
430 return '<span style="color: green">Success</span>'; 367 return '<span style="color: green">Success</span>';
@@ -434,6 +371,5 @@ class upgradeDatabase extends Step @@ -434,6 +371,5 @@ class upgradeDatabase extends Step
434 } 371 }
435 return $res; 372 return $res;
436 } 373 }
437 -  
438 } 374 }
439 ?> 375 ?>
440 \ No newline at end of file 376 \ No newline at end of file
setup/upgrade/steps/upgradeRestore.php
@@ -40,18 +40,18 @@ @@ -40,18 +40,18 @@
40 * @version Version 0.1 40 * @version Version 0.1
41 */ 41 */
42 42
43 -//require_once('../../config/dmsDefaults.php');  
44 -  
45 class upgradeRestore extends Step { 43 class upgradeRestore extends Step {
46 44
47 45
48 protected $silent = false; 46 protected $silent = false;
49 protected $temp_variables = array(); 47 protected $temp_variables = array();
50 48
51 - public function doStep() { 49 + public function doStep() {
52 $this->temp_variables = array("step_name"=>"restore", "silent"=>$this->silent, 50 $this->temp_variables = array("step_name"=>"restore", "silent"=>$this->silent,
53 "loadingText"=>"The database restore is under way. Please wait until it completes"); 51 "loadingText"=>"The database restore is under way. Please wait until it completes");
54 $this->temp_variables['restore'] = false; 52 $this->temp_variables['restore'] = false;
  53 + $this->temp_variables['display'] = '';
  54 + $this->temp_variables['dir'] = '';
55 55
56 if(!$this->inStep("restore")) { 56 if(!$this->inStep("restore")) {
57 $this->doRun(); 57 $this->doRun();
@@ -79,6 +79,8 @@ class upgradeRestore extends Step { @@ -79,6 +79,8 @@ class upgradeRestore extends Step {
79 } 79 }
80 80
81 private function doRun($restore = false) { 81 private function doRun($restore = false) {
  82 + $this->readConfig();
  83 +
82 if (!$restore) { 84 if (!$restore) {
83 $this->temp_variables['selected'] = false; 85 $this->temp_variables['selected'] = false;
84 if ($this->select()) { 86 if ($this->select()) {
@@ -92,8 +94,6 @@ class upgradeRestore extends Step { @@ -92,8 +94,6 @@ class upgradeRestore extends Step {
92 $this->restoreDatabase(); 94 $this->restoreDatabase();
93 } 95 }
94 96
95 - $this->storeSilent();// Set silent mode variables  
96 -  
97 return true; 97 return true;
98 } 98 }
99 99
@@ -101,19 +101,12 @@ class upgradeRestore extends Step { @@ -101,19 +101,12 @@ class upgradeRestore extends Step {
101 return isset($_POST['RestoreSelect']); 101 return isset($_POST['RestoreSelect']);
102 } 102 }
103 103
104 - /**  
105 - * Set all silent mode varibles  
106 - *  
107 - */  
108 - private function storeSilent() {  
109 - }  
110 -  
111 private function restoreDatabase() 104 private function restoreDatabase()
112 { 105 {
113 $this->temp_variables['restore'] = true; 106 $this->temp_variables['restore'] = true;
114 $status = $_SESSION['backupStatus']; 107 $status = $_SESSION['backupStatus'];
115 $filename = $_SESSION['backupFile']; 108 $filename = $_SESSION['backupFile'];
116 - $stmt = $this->util->create_restore_stmt($filename); 109 + $stmt = $this->util->create_restore_stmt($filename, $this->dbSettings);
117 $dir = $stmt['dir']; 110 $dir = $stmt['dir'];
118 111
119 if (is_file($dir . '/mysql') || is_file($dir . '/mysql.exe')) 112 if (is_file($dir . '/mysql') || is_file($dir . '/mysql.exe'))
@@ -219,7 +212,7 @@ class upgradeRestore extends Step { @@ -219,7 +212,7 @@ class upgradeRestore extends Step {
219 212
220 $status = $_SESSION['backupStatus']; 213 $status = $_SESSION['backupStatus'];
221 $filename = $_SESSION['backupFile']; 214 $filename = $_SESSION['backupFile'];
222 - $stmt = $this->util->create_restore_stmt($filename); 215 + $stmt = $this->util->create_restore_stmt($filename, $this->dbSettings);
223 216
224 $this->temp_variables['title'] = 'Confirm Restore'; 217 $this->temp_variables['title'] = 'Confirm Restore';
225 $this->temp_variables['dir'] = $stmt['dir']; 218 $this->temp_variables['dir'] = $stmt['dir'];
@@ -227,6 +220,6 @@ class upgradeRestore extends Step { @@ -227,6 +220,6 @@ class upgradeRestore extends Step {
227 $this->temp_variables['availableBackups'] = true; 220 $this->temp_variables['availableBackups'] = true;
228 $this->temp_variables['selected'] = true; 221 $this->temp_variables['selected'] = true;
229 } 222 }
230 - 223 +
231 } 224 }
232 ?> 225 ?>
233 \ No newline at end of file 226 \ No newline at end of file
setup/upgrade/steps/upgradeWelcome.php
@@ -45,7 +45,8 @@ class upgradeWelcome extends step { @@ -45,7 +45,8 @@ class upgradeWelcome extends step {
45 protected $silent = true; 45 protected $silent = true;
46 protected $temp_variables = array(); 46 protected $temp_variables = array();
47 protected $error = array() ; 47 protected $error = array() ;
48 - 48 + protected $storeInSession = true;
  49 +
49 public function doStep() { 50 public function doStep() {
50 $this->temp_variables = array("step_name"=>"welcome"); 51 $this->temp_variables = array("step_name"=>"welcome");
51 if($this->next()) { 52 if($this->next()) {
@@ -81,15 +82,13 @@ class upgradeWelcome extends step { @@ -81,15 +82,13 @@ class upgradeWelcome extends step {
81 private function checkPassword($username, $password) { 82 private function checkPassword($username, $password) {
82 $dconf = $this->getDataFromPackage('installers', 'database'); // Use info from install 83 $dconf = $this->getDataFromPackage('installers', 'database'); // Use info from install
83 if($dconf) { 84 if($dconf) {
84 - $this->util->dbUtilities->load($dconf['dhost'], $dbconf['dport'], $dconf['duname'], $dconf['dpassword'], $dconf['dname']); 85 + $this->util->dbUtilities->load($dconf['dhost'], $dconf['dport'], $dconf['duname'], $dconf['dpassword'], $dconf['dname']);
85 } else { 86 } else {
86 require_once("../wizard/steps/configuration.php"); // configuration to read the ini path 87 require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
87 $wizConfigHandler = new configuration(); 88 $wizConfigHandler = new configuration();
88 $configPath = $wizConfigHandler->readConfigPathIni(); 89 $configPath = $wizConfigHandler->readConfigPathIni();
89 $this->util->iniUtilities->load($configPath); 90 $this->util->iniUtilities->load($configPath);
90 $dconf = $this->util->iniUtilities->getSection('db'); 91 $dconf = $this->util->iniUtilities->getSection('db');
91 - if($dconf['dbPort'] == 'default')  
92 - $dconf['dbPort'] = 3306;  
93 $this->util->dbUtilities->load($dconf['dbHost'],$dconf['dbPort'], $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']); 92 $this->util->dbUtilities->load($dconf['dbHost'],$dconf['dbPort'], $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']);
94 $sQuery = "SELECT count(*) AS match_count FROM users WHERE username = '$username' AND password = '".md5($password)."'"; 93 $sQuery = "SELECT count(*) AS match_count FROM users WHERE username = '$username' AND password = '".md5($password)."'";
95 $res = $this->util->dbUtilities->query($sQuery); 94 $res = $this->util->dbUtilities->query($sQuery);
setup/upgrade/templates/backup.tpl
@@ -46,7 +46,7 @@ You can continue to do the backup manually using the following process: @@ -46,7 +46,7 @@ You can continue to do the backup manually using the following process:
46 <P> 46 <P>
47 </div> 47 </div>
48 </div> 48 </div>
49 - <?php include 'templates/loading.tpl'; ?> 49 + <?php include WIZARD_DIR . 'templates/loading.tpl'; ?>
50 <div id="buttonBar"> 50 <div id="buttonBar">
51 <input type="submit" name="Previous" value="Previous" class="button_previous"> 51 <input type="submit" name="Previous" value="Previous" class="button_previous">
52 <?php 52 <?php
setup/upgrade/templates/complete.tpl
@@ -6,8 +6,8 @@ @@ -6,8 +6,8 @@
6 <!-- Services --> 6 <!-- Services -->
7 <br/><br/> 7 <br/><br/>
8 <div> 8 <div>
9 - Your database has been upgraded to <?php //echo $default->systemVersion; ?> 9 + Your database has been upgraded to <?php echo $sysVersion; ?>
10 </div> 10 </div>
11 </div> 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 </form> 13 </form>
14 \ No newline at end of file 14 \ No newline at end of file
setup/upgrade/templates/database.tpl
@@ -3,6 +3,13 @@ @@ -3,6 +3,13 @@
3 <div id="database" class="step1" style="display:block;"> 3 <div id="database" class="step1" style="display:block;">
4 <div class="description"> 4 <div class="description">
5 This step performs the necessary Database Upgrades. 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 </div> 13 </div>
7 <div id="step_content_database" class="step"> 14 <div id="step_content_database" class="step">
8 <br/><br/> 15 <br/><br/>
@@ -13,13 +20,11 @@ @@ -13,13 +20,11 @@
13 <?php echo $upgradeTable; ?> 20 <?php echo $upgradeTable; ?>
14 <?php } 21 <?php }
15 else if ($action == 'confirm') { 22 else if ($action == 'confirm') {
16 - if (!$backupStatus) { ?> 23 + if ($backupStatus) { ?>
17 <p>We are about to start the upgrade process.<P> 24 <p>We are about to start the upgrade process.<P>
18 <?php } 25 <?php }
19 else { ?> 26 else { ?>
20 - <br/>  
21 - <font color="Red">Please ensure that you have made a backup before continuing with the upgrade process.</font>  
22 - <p> 27 + <p><font color="Red">Please ensure that you have made a backup before continuing with the upgrade process.</font><p>
23 <?php } ?> 28 <?php } ?>
24 <?php } 29 <?php }
25 else if ($action == 'runUpgrade') { 30 else if ($action == 'runUpgrade') {
setup/upgrade/templates/loading.tpl
1 <div id="loadingBar" style="display:none; text-align: center; padding: 4px;"> 1 <div id="loadingBar" style="display:none; text-align: center; padding: 4px;">
2 - <img src="/setup/upgrade/resources/graphics/loading.gif"> 2 + <img src="/setup/wizard/resources/graphics/loading.gif">
3 <br/> 3 <br/>
4 <?php echo $loadingText; ?> 4 <?php echo $loadingText; ?>
5 </div> 5 </div>
setup/upgrade/templates/restore.tpl
@@ -92,7 +92,7 @@ Press &lt;i&gt;Next&lt;/i&gt; to attempt the command(s) above. @@ -92,7 +92,7 @@ Press &lt;i&gt;Next&lt;/i&gt; to attempt the command(s) above.
92 ?> 92 ?>
93 </div> 93 </div>
94 </div> 94 </div>
95 - <?php include 'templates/loading.tpl'; ?> 95 + <?php include WIZARD_DIR . 'templates/loading.tpl'; ?>
96 <div id="buttonBar"> 96 <div id="buttonBar">
97 <input type="submit" name="Previous" value="Previous" class="button_previous"> 97 <input type="submit" name="Previous" value="Previous" class="button_previous">
98 <?php if (($dir != '') && ($selected)) { ?> 98 <?php if (($dir != '') && ($selected)) { ?>
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 \ No newline at end of file 0 \ No newline at end of file
setup/upgrade/upgradeUtil.php
@@ -116,35 +116,35 @@ class UpgradeUtil extends InstallUtil { @@ -116,35 +116,35 @@ class UpgradeUtil extends InstallUtil {
116 return true; 116 return true;
117 } 117 }
118 118
119 - public function create_restore_stmt($targetfile) 119 + public function create_restore_stmt($targetfile, $dbConfig)
120 { 120 {
121 - $oKTConfig =& KTConfig::getSingleton(); 121 +// $oKTConfig =& KTConfig::getSingleton();
122 122
123 - $adminUser = $oKTConfig->get('db/dbAdminUser');  
124 - $adminPwd = $oKTConfig->get('db/dbAdminPass');  
125 - $dbHost = $oKTConfig->get('db/dbHost');  
126 - $dbName = $oKTConfig->get('db/dbName');  
127 - $dbPort = trim($oKTConfig->get('db/dbPort')); 123 + $adminUser = $dbConfig['dbAdminUser'];
  124 + $adminPwd = $dbConfig['dbAdminPass'];
  125 + $dbHost = $dbConfig['dbHost'];
  126 + $dbName = $dbConfig['dbName'];
  127 + $dbPort = trim($dbConfig['dbPort']);
128 if ($dbPort=='' || $dbPort=='default')$dbPort = get_cfg_var('mysql.default_port'); 128 if ($dbPort=='' || $dbPort=='default')$dbPort = get_cfg_var('mysql.default_port');
129 if (empty($dbPort)) $dbPort='3306'; 129 if (empty($dbPort)) $dbPort='3306';
130 - $dbSocket = trim($oKTConfig->get('db/dbSocket')); 130 + $dbSocket = '';
131 if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); 131 if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket');
132 if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; 132 if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock';
133 133
134 $dir = $this->resolveMysqlDir(); 134 $dir = $this->resolveMysqlDir();
135 135
136 - $info['dir']=$dir; 136 + $info['dir'] = $dir;
137 137
138 - $prefix='';  
139 - if (OS_UNIX) { 138 + $prefix = '';
  139 + if (!WINDOWS_OS) {
140 $prefix .= "./"; 140 $prefix .= "./";
141 } 141 }
142 142
143 if (@stat($dbSocket) !== false) { 143 if (@stat($dbSocket) !== false) {
144 - $mechanism="--socket=\"$dbSocket\""; 144 + $mechanism = "--socket=\"$dbSocket\"";
145 } 145 }
146 else { 146 else {
147 - $mechanism="--port=\"$dbPort\""; 147 + $mechanism = "--port=\"$dbPort\"";
148 } 148 }
149 149
150 $tmpdir = $this->resolveTempDir(); 150 $tmpdir = $this->resolveTempDir();
@@ -152,16 +152,14 @@ class UpgradeUtil extends InstallUtil { @@ -152,16 +152,14 @@ class UpgradeUtil extends InstallUtil {
152 $stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"<br/>"; 152 $stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"<br/>";
153 $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"<br/>"; 153 $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"<br/>";
154 154
155 -  
156 $stmt .= $prefix ."mysql --user=\"$adminUser\" -p $mechanism \"$dbName\" < \"$targetfile\"\n"; 155 $stmt .= $prefix ."mysql --user=\"$adminUser\" -p $mechanism \"$dbName\" < \"$targetfile\"\n";
157 $info['display']=$stmt; 156 $info['display']=$stmt;
158 157
159 -  
160 $stmt = $prefix ."mysqladmin --user=\"$adminUser\" --force --password=\"$adminPwd\" $mechanism drop \"$dbName\"\n"; 158 $stmt = $prefix ."mysqladmin --user=\"$adminUser\" --force --password=\"$adminPwd\" $mechanism drop \"$dbName\"\n";
161 $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism create \"$dbName\"\n"; 159 $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism create \"$dbName\"\n";
162 160
163 $stmt .= $prefix ."mysql --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" < \"$targetfile\""; 161 $stmt .= $prefix ."mysql --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" < \"$targetfile\"";
164 - $info['cmd']=$stmt; 162 + $info['cmd'] = $stmt;
165 return $info; 163 return $info;
166 } 164 }
167 165
@@ -169,7 +167,7 @@ class UpgradeUtil extends InstallUtil { @@ -169,7 +167,7 @@ class UpgradeUtil extends InstallUtil {
169 { 167 {
170 // possibly detect existing installations: 168 // possibly detect existing installations:
171 169
172 - if (OS_UNIX) { 170 + if (!WINDOWS_OS) {
173 $dirs = array('/opt/mysql/bin','/usr/local/mysql/bin'); 171 $dirs = array('/opt/mysql/bin','/usr/local/mysql/bin');
174 $mysqlname ='mysql'; 172 $mysqlname ='mysql';
175 } 173 }
@@ -181,8 +179,9 @@ class UpgradeUtil extends InstallUtil { @@ -181,8 +179,9 @@ class UpgradeUtil extends InstallUtil {
181 $mysqlname ='mysql.exe'; 179 $mysqlname ='mysql.exe';
182 } 180 }
183 181
184 - $oKTConfig =& KTConfig::getSingleton();  
185 - $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir); 182 + // I don't know if this value exists anymore?
  183 +// $mysqldir = $oKTConfig->get('backup/mysqlDirectory',$mysqldir);
  184 + $mysqldir = '';
186 $dirs[] = $mysqldir; 185 $dirs[] = $mysqldir;
187 186
188 if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false) { 187 if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false) {
@@ -202,14 +201,16 @@ class UpgradeUtil extends InstallUtil { @@ -202,14 +201,16 @@ class UpgradeUtil extends InstallUtil {
202 201
203 public function resolveTempDir() 202 public function resolveTempDir()
204 { 203 {
205 - if (OS_UNIX) { 204 + $dir = '';
  205 + if (!WINDOWS_OS) {
206 $dir='/tmp/kt-db-backup'; 206 $dir='/tmp/kt-db-backup';
207 } 207 }
208 else { 208 else {
209 $dir='c:/kt-db-backup'; 209 $dir='c:/kt-db-backup';
210 } 210 }
211 - $oKTConfig =& KTConfig::getSingleton();  
212 - $dir = $oKTConfig->get('backup/backupDirectory',$dir); 211 +
  212 +// $oKTConfig =& KTConfig::getSingleton();
  213 +// $dir = $oKTConfig->get('backup/backupDirectory',$dir);
213 214
214 if (!is_dir($dir)) { 215 if (!is_dir($dir)) {
215 mkdir($dir); 216 mkdir($dir);
setup/upgrade/upgradeWizard.php
@@ -50,8 +50,8 @@ include(&quot;../wizard/path.php&quot;); // Paths @@ -50,8 +50,8 @@ include(&quot;../wizard/path.php&quot;); // Paths
50 function __autoload($class) { // Attempt and autoload classes 50 function __autoload($class) { // Attempt and autoload classes
51 $class = strtolower(substr($class,0,1)).substr($class,1); // Linux Systems. 51 $class = strtolower(substr($class,0,1)).substr($class,1); // Linux Systems.
52 if ($class == "template") { // Load existing templating classes 52 if ($class == "template") { // Load existing templating classes
53 - require_once("../wizard/template.php");  
54 - require_once("../wizard/lib/helpers/htmlHelper.php"); 53 + require_once(WIZARD_DIR."../wizard/template.php");
  54 + require_once(WIZARD_DIR."../wizard/lib/helpers/htmlHelper.php");
55 return ; 55 return ;
56 } 56 }
57 if(file_exists(WIZARD_DIR."$class.php")) { 57 if(file_exists(WIZARD_DIR."$class.php")) {
setup/wizard/dbUtilities.php
@@ -267,5 +267,15 @@ class dbUtilities { @@ -267,5 +267,15 @@ class dbUtilities {
267 public function rollback() { 267 public function rollback() {
268 $this->query("ROLLBACK"); 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 \ No newline at end of file 282 \ No newline at end of file
setup/wizard/iniUtilities.php
@@ -45,11 +45,11 @@ class iniUtilities { @@ -45,11 +45,11 @@ class iniUtilities {
45 45
46 46
47 function load($iniFile) { 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 $this->iniFile = $iniFile; 53 $this->iniFile = $iniFile;
54 $this->backupIni($iniFile); 54 $this->backupIni($iniFile);
55 $this->read($iniFile); 55 $this->read($iniFile);
setup/wizard/lib/services/unixLucene.php
@@ -201,7 +201,7 @@ class unixLucene extends unixService { @@ -201,7 +201,7 @@ class unixLucene extends unixService {
201 public function start() { 201 public function start() {
202 $state = $this->status(); 202 $state = $this->status();
203 if($state != 'STARTED') { 203 if($state != 'STARTED') {
204 - $logFile = $this->outputDir."log".DS."lucene.log"; 204 + $logFile = $this->outputDir.DS."lucene.log";
205 @unlink($logFile); 205 @unlink($logFile);
206 $cmd = "cd ".$this->getLuceneDir()."; "; 206 $cmd = "cd ".$this->getLuceneDir()."; ";
207 $cmd .= "nohup java {$this->getJavaXmx()} {$this->getJavaXmx()} -jar ".$this->getLuceneSource()." > ".$logFile." 2>&1 & echo $!"; 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,7 +180,7 @@ class unixScheduler extends unixService {
180 // TODO : Write sh on the fly? Not sure the reasoning here 180 // TODO : Write sh on the fly? Not sure the reasoning here
181 $source = $this->getSchedulerSourceLoc(); 181 $source = $this->getSchedulerSourceLoc();
182 $this->writeSchedulerTask(); 182 $this->writeSchedulerTask();
183 - $logFile = $this->outputDir."log".DS."scheduler.log"; 183 + $logFile = $this->outputDir.DS."scheduler.log";
184 @unlink($logFile); 184 @unlink($logFile);
185 if($source) { // Source 185 if($source) { // Source
186 $cmd = "nohup ".$source." > ".$logFile." 2>&1 & echo $!"; 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,6 +96,7 @@ class complete extends Step {
96 foreach ($paths as $path) 96 foreach ($paths as $path)
97 { 97 {
98 $output = ''; 98 $output = '';
  99 + $path['path'] = $class = strtolower(substr($path['path'],0,1)).substr($path['path'],1); // Damn you windows
99 $result = $this->util->checkPermission($path['path']); 100 $result = $this->util->checkPermission($path['path']);
100 $output = sprintf($pathhtml, $result['class'], $path['path'], 101 $output = sprintf($pathhtml, $result['class'], $path['path'],
101 (($result['class'] == 'tick') ? 'class="green"' : 'class="error"' ), 102 (($result['class'] == 'tick') ? 'class="green"' : 'class="error"' ),
setup/wizard/steps/configuration.php
@@ -390,17 +390,25 @@ class configuration extends Step @@ -390,17 +390,25 @@ class configuration extends Step
390 */ 390 */
391 private function getServerInfo() 391 private function getServerInfo()
392 { 392 {
  393 + $iis = false;
393 $script = $_SERVER['SCRIPT_NAME']; 394 $script = $_SERVER['SCRIPT_NAME'];
394 $file_system_root = $_SERVER['DOCUMENT_ROOT']; 395 $file_system_root = $_SERVER['DOCUMENT_ROOT'];
  396 + if(preg_match('/inetpub/', $file_system_root)) {
  397 + $iis = true;
  398 + $file_system_root = $_SERVER['APPL_PHYSICAL_PATH'];
  399 + }
395 $host = $_SERVER['SERVER_NAME']; 400 $host = $_SERVER['SERVER_NAME'];
396 $port = $_SERVER['SERVER_PORT']; 401 $port = $_SERVER['SERVER_PORT'];
397 $ssl_enabled = isset($_SERVER['HTTPS']) ? (strtolower($_SERVER['HTTPS']) === 'on' ? 'yes' : 'no') : 'no'; 402 $ssl_enabled = isset($_SERVER['HTTPS']) ? (strtolower($_SERVER['HTTPS']) === 'on' ? 'yes' : 'no') : 'no';
398 403
399 $pos = strpos($script, '/setup/wizard/'); 404 $pos = strpos($script, '/setup/wizard/');
400 $root_url = substr($script, 0, $pos); 405 $root_url = substr($script, 0, $pos);
401 -  
402 $root_url = (isset($_POST['root_url'])) ? $_POST['root_url'] : $root_url; 406 $root_url = (isset($_POST['root_url'])) ? $_POST['root_url'] : $root_url;
403 - $file_system_root = (isset($_POST['file_system_root'])) ? $_POST['file_system_root'] : $file_system_root.$root_url; 407 + if($iis) {
  408 + $file_system_root = (isset($_POST['file_system_root'])) ? $_POST['file_system_root'] : $file_system_root;
  409 + } else {
  410 + $file_system_root = (isset($_POST['file_system_root'])) ? $_POST['file_system_root'] : $file_system_root.$root_url;
  411 + }
404 $host = (isset($_POST['host'])) ? $_POST['host'] : $host; 412 $host = (isset($_POST['host'])) ? $_POST['host'] : $host;
405 $port = (isset($_POST['port'])) ? $_POST['port'] : $port; 413 $port = (isset($_POST['port'])) ? $_POST['port'] : $port;
406 $ssl_enabled = (isset($_POST['ssl_enabled'])) ? $_POST['ssl_enabled'] : $ssl_enabled; 414 $ssl_enabled = (isset($_POST['ssl_enabled'])) ? $_POST['ssl_enabled'] : $ssl_enabled;
@@ -460,6 +468,7 @@ class configuration extends Step @@ -460,6 +468,7 @@ class configuration extends Step
460 if(WINDOWS_OS) 468 if(WINDOWS_OS)
461 $path = preg_replace('/\//', '\\',$path); 469 $path = preg_replace('/\//', '\\',$path);
462 $dirs[$key]['path'] = $path; 470 $dirs[$key]['path'] = $path;
  471 + $path = $class = strtolower(substr($path,0,1)).substr($path,1); // Damn you windows
463 if(isset($dir['file'])) 472 if(isset($dir['file']))
464 $class = $this->util->checkPermission($path, $dir['create'], true); 473 $class = $this->util->checkPermission($path, $dir['create'], true);
465 else 474 else
setup/wizard/steps/services.php
@@ -219,7 +219,7 @@ class services extends Step @@ -219,7 +219,7 @@ class services extends Step
219 $srv = new $className(); 219 $srv = new $className();
220 $srv->load(); 220 $srv->load();
221 $status = $this->serviceInstalled($srv); 221 $status = $this->serviceInstalled($srv);
222 - if($status != 'STARTED') { 222 + if($status != 'STARTED' || $status != 'STOPPED') {
223 if(!WINDOWS_OS) { $binary = $this->$class->getBinary(); } // Get binary, if it exists 223 if(!WINDOWS_OS) { $binary = $this->$class->getBinary(); } // Get binary, if it exists
224 $passed = $this->$class->binaryChecks(); // Run Binary Pre Checks 224 $passed = $this->$class->binaryChecks(); // Run Binary Pre Checks
225 if ($passed) { // Install Service 225 if ($passed) { // Install Service
setup/wizard/template.php
@@ -96,6 +96,8 @@ class Template @@ -96,6 +96,8 @@ class Template
96 public function fetch($file = null) 96 public function fetch($file = null)
97 { 97 {
98 if (is_null($file)) $file = $this->file; 98 if (is_null($file)) $file = $this->file;
  99 +
  100 + $file = WIZARD_DIR . $file;
99 if (!file_exists($file)) { 101 if (!file_exists($file)) {
100 trigger_error('Template file '.$file.' does not exist ', E_USER_ERROR); 102 trigger_error('Template file '.$file.' does not exist ', E_USER_ERROR);
101 } 103 }
setup/wizard/templates/install.tpl
@@ -5,10 +5,7 @@ @@ -5,10 +5,7 @@
5 <p class="empty_space"> 5 <p class="empty_space">
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> 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 </p> 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 <br/><br/> 9 <br/><br/>
13 <p> <input class="" type='checkbox' name='call_home' value='enable' checked style="float:left;"/>&nbsp;&nbsp; 10 <p> <input class="" type='checkbox' name='call_home' value='enable' checked style="float:left;"/>&nbsp;&nbsp;
14 Help to improve KnowledgeTree by providing anonymous usage statistics</p> 11 Help to improve KnowledgeTree by providing anonymous usage statistics</p>
webservice/clienttools/ajaxhandler.php
@@ -8,6 +8,7 @@ class ajaxHandler{ @@ -8,6 +8,7 @@ class ajaxHandler{
8 public $kt=NULL; 8 public $kt=NULL;
9 public $authenticator=NULL; 9 public $authenticator=NULL;
10 public $noAuthRequireList=array(); 10 public $noAuthRequireList=array();
  11 + public $standardServices=array('system');
11 12
12 public function __construct(&$ret=NULL,&$kt,$noAuthRequests=''){ 13 public function __construct(&$ret=NULL,&$kt,$noAuthRequests=''){
13 // set a local copy of the json request wrapper 14 // set a local copy of the json request wrapper
@@ -30,6 +31,7 @@ class ajaxHandler{ @@ -30,6 +31,7 @@ class ajaxHandler{
30 } 31 }
31 $this->ret->setRequest($this->req->jsonArray); 32 $this->ret->setRequest($this->req->jsonArray);
32 $this->ret->setTitle($this->request['service'].'::'.$this->request['function']); 33 $this->ret->setTitle($this->request['service'].'::'.$this->request['function']);
  34 + $this->ret->setDebug('Server Versions',$this->getServerVersions());
33 35
34 if(get_class($kt)=='KTAPI'){ 36 if(get_class($kt)=='KTAPI'){
35 $this->kt=&$kt; 37 $this->kt=&$kt;
@@ -38,20 +40,22 @@ class ajaxHandler{ @@ -38,20 +40,22 @@ class ajaxHandler{
38 return $this->render(); 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 $this->dispatch(); 61 $this->dispatch();
@@ -70,11 +74,15 @@ class ajaxHandler{ @@ -70,11 +74,15 @@ class ajaxHandler{
70 $service=$this->authenticator; 74 $service=$this->authenticator;
71 }else{ 75 }else{
72 $this->loadService($request['service']); 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 $this->ret->setdebug('dispatch_request','The service class loaded'); 83 $this->ret->setdebug('dispatch_request','The service class loaded');
76 if(method_exists($service,$request['function'])){ 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 $service->$request['function']($request['parameters']); 86 $service->$request['function']($request['parameters']);
79 }else{ 87 }else{
80 $this->ret->addError("Service {$request['service']} does not contain the method: {$request['function']}"); 88 $this->ret->addError("Service {$request['service']} does not contain the method: {$request['function']}");
@@ -82,16 +90,34 @@ class ajaxHandler{ @@ -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 public function loadService($serviceName=NULL){ 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,10 +132,22 @@ class ajaxHandler{
106 return true; 132 return true;
107 } 133 }
108 134
109 - protected function getVersion(){ 135 + public function getVersion(){
110 if(!$this->version)$this->version=$this->req->getVersion(); 136 if(!$this->version)$this->version=$this->req->getVersion();
111 return $this->version; 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 protected function verifySession(){ 152 protected function verifySession(){
115 return $this->authenticator->pickup_session(); 153 return $this->authenticator->pickup_session();
webservice/clienttools/client_service.php
@@ -5,8 +5,9 @@ class client_service{ @@ -5,8 +5,9 @@ class client_service{
5 public $KT; 5 public $KT;
6 public $Request; 6 public $Request;
7 public $AuthInfo; 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 // set the response object 11 // set the response object
11 // if(get_class($ResponseObject)=='jsonResponseObject'){ 12 // if(get_class($ResponseObject)=='jsonResponseObject'){
12 // $this->Response=&$ResponseObject; 13 // $this->Response=&$ResponseObject;
@@ -14,7 +15,7 @@ class client_service{ @@ -14,7 +15,7 @@ class client_service{
14 // $this->Response=new jsonResponseObject(); 15 // $this->Response=new jsonResponseObject();
15 // } 16 // }
16 17
17 - 18 + $this->handler=$handler;
18 $this->Response=&$ResponseObject; 19 $this->Response=&$ResponseObject;
19 $this->KT=&$KT_Instance; 20 $this->KT=&$KT_Instance;
20 $this->AuthInfo=&$AuthInfo; 21 $this->AuthInfo=&$AuthInfo;
webservice/clienttools/jsonWrapper.php
@@ -14,7 +14,7 @@ class jsonResponseObject{ @@ -14,7 +14,7 @@ class jsonResponseObject{
14 public $additional=array(); 14 public $additional=array();
15 public $isDataSource=false; 15 public $isDataSource=false;
16 16
17 - public $includeDebug=false; 17 + public $includeDebug=true;
18 18
19 public $response=array( 19 public $response=array(
20 'requestName' =>'', 20 'requestName' =>'',
@@ -91,6 +91,7 @@ class jsonWrapper{ @@ -91,6 +91,7 @@ class jsonWrapper{
91 public $jsonArray=array(); 91 public $jsonArray=array();
92 92
93 public function __construct($content=NULL){ 93 public function __construct($content=NULL){
  94 + $content=stripslashes($content);
94 $this->raw=$content; 95 $this->raw=$content;
95 $content=@json_decode($content,true); 96 $content=@json_decode($content,true);
96 if(!is_array($content))throw new jsonContentException('Invalid JSON input',jsonContentException::INPUT_ERROR); 97 if(!is_array($content))throw new jsonContentException('Invalid JSON input',jsonContentException::INPUT_ERROR);
webservice/clienttools/services/0.1/auth.php
@@ -100,17 +100,25 @@ class auth extends client_service { @@ -100,17 +100,25 @@ class auth extends client_service {
100 public function ping(){ 100 public function ping(){
101 global $default; 101 global $default;
102 $user=$this->KT->get_user_object_by_username($this->AuthInfo['user']); 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 $ret=array( 106 $ret=array(
104 'response' =>'pong', 107 'response' =>'pong',
105 'loginLocation' => '/index.html', 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 $this->setResponse($ret); 118 $this->setResponse($ret);
112 return true; 119 return true;
113 } 120 }
  121 +
114 122
115 function logout($params){ 123 function logout($params){
116 $params=$this->AuthInfo; 124 $params=$this->AuthInfo;
webservice/clienttools/services/0.2/auth.php
@@ -100,13 +100,20 @@ class auth extends client_service { @@ -100,13 +100,20 @@ class auth extends client_service {
100 public function ping(){ 100 public function ping(){
101 global $default; 101 global $default;
102 $user=$this->KT->get_user_object_by_username($this->AuthInfo['user']); 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 $ret=array( 106 $ret=array(
104 'response' =>'pong', 107 'response' =>'pong',
105 'loginLocation' => '/index.html', 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 $this->setResponse($ret); 118 $this->setResponse($ret);
112 return true; 119 return true;
webservice/clienttools/services/0.2/kt.php
@@ -140,6 +140,7 @@ class kt extends client_service { @@ -140,6 +140,7 @@ class kt extends client_service {
140 140
141 $folder=&$kt->get_folder_by_id($arr['node']); 141 $folder=&$kt->get_folder_by_id($arr['node']);
142 if (PEAR::isError($folder)){ 142 if (PEAR::isError($folder)){
  143 + echo '<pre>'.print_r($arr,true).'</pre>';
143 $this->addError('Folder Not found'); 144 $this->addError('Folder Not found');
144 return false; 145 return false;
145 } 146 }
@@ -430,6 +431,7 @@ class kt extends client_service { @@ -430,6 +431,7 @@ class kt extends client_service {
430 } 431 }
431 } 432 }
432 $this->setResponse(array('items'=>$items, 'count'=>count($items))); 433 $this->setResponse(array('items'=>$items, 'count'=>count($items)));
  434 + return true;
433 } 435 }
434 436
435 function update_document_type($params) { 437 function update_document_type($params) {
@@ -599,9 +601,10 @@ class kt extends client_service { @@ -599,9 +601,10 @@ class kt extends client_service {
599 $filename=$params['filename']; 601 $filename=$params['filename'];
600 $reason=$params['reason']; 602 $reason=$params['reason'];
601 $tempfilename=$params['tempfilename']; 603 $tempfilename=$params['tempfilename'];
  604 + $major_update=$params['major_update'];
602 $application=$this->AuthInfo['appType']; 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 $kt=&$this->KT; 608 $kt=&$this->KT;
606 609
607 // we need to add some security to ensure that people don't frig the checkin process to access restricted files. 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,7 +623,7 @@ class kt extends client_service {
620 } 623 }
621 624
622 // checkin 625 // checkin
623 - $result=$document->checkin($filename, $reason, $tempfilename, false); 626 + $result=$document->checkin($filename, $reason, $tempfilename, $major_update);
624 if (PEAR::isError($result)) 627 if (PEAR::isError($result))
625 { 628 {
626 $this->setResponse(array('status_code'=>14)); 629 $this->setResponse(array('status_code'=>14));
@@ -676,7 +679,7 @@ class kt extends client_service { @@ -676,7 +679,7 @@ class kt extends client_service {
676 $status_code=$update_result['status_code']; 679 $status_code=$update_result['status_code'];
677 if ($status_code != 0) 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 $this->response= $update_result; 683 $this->response= $update_result;
681 } 684 }
682 685
@@ -824,7 +827,12 @@ class kt extends client_service { @@ -824,7 +827,12 @@ class kt extends client_service {
824 $this->setResponse($detail); 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 $kt=&$this->KT; 836 $kt=&$this->KT;
829 837
830 $document=&$kt->get_document_by_id($document_id); 838 $document=&$kt->get_document_by_id($document_id);
@@ -847,7 +855,7 @@ class kt extends client_service { @@ -847,7 +855,7 @@ class kt extends client_service {
847 855
848 856
849 private function update_document_metadata($session_id, $document_id, $metadata, $application, $sysdata=null){ 857 private function update_document_metadata($session_id, $document_id, $metadata, $application, $sysdata=null){
850 - $this->addDebug('','entered update_document_metadata'); 858 + $this->addDebug('update_document_metadata','entered update_document_metadata');
851 $kt=&$this->KT; 859 $kt=&$this->KT;
852 $responseType='kt_document_detail'; 860 $responseType='kt_document_detail';
853 861
@@ -915,27 +923,44 @@ class kt extends client_service { @@ -915,27 +923,44 @@ class kt extends client_service {
915 923
916 public function update_metadata($arr){ 924 public function update_metadata($arr){
917 $metadata=array(); 925 $metadata=array();
918 - $packed=@json_decode($arr['metadata']); 926 + $meta=$arr['metadata'];
919 927
920 $this->addDebug('','Entered add_document_with_metadata'); 928 $this->addDebug('','Entered add_document_with_metadata');
  929 + $this->addDebug('metadata received',$meta);
921 930
922 $special=array(); 931 $special=array();
923 -  
924 - foreach($packed as $key=>$val) {  
925 - if(substr($val->name,0,2) != '__') {  
926 - if(!is_array($metadata[$val->fieldset])) {  
927 - $metadata[$val->fieldset]['fieldset']=$val->fieldset;  
928 - $metadata[$val->fieldset]['fields']=array();  
929 - }  
930 - $metadata[$val->fieldset]['fields'][]=array(  
931 - 'name'=>$val->name,  
932 - 'value'=>$val->value  
933 - ); 932 +// foreach($apacked as $packed){
  933 +// foreach($packed as $key=>$val) {
  934 +// if(substr($val->name,0,2) != '__') {
  935 +// if(!is_array($metadata[$val->fieldset])) {
  936 +// $metadata[$val->fieldset]['fieldset']=$val->fieldset;
  937 +// $metadata[$val->fieldset]['fields']=array();
  938 +// }
  939 +// $metadata[$val->fieldset]['fields'][]=array(
  940 +// 'name'=>$val->name,
  941 +// 'value'=>$val->value
  942 +// );
  943 +// }else{
  944 +// $special[$val->name]=$val->value;
  945 +// }
  946 +// }
  947 +// }
  948 +
  949 + foreach($meta as $item){
  950 + $isSpecial=substr($item['name'],0,2)=='__';
  951 + if($isSpecial){
  952 + $special[$item['name']]=$item['value'];
934 }else{ 953 }else{
935 - $special[$val->name]=$val->value;  
936 - } 954 + $fieldSet=$item['fieldset'];
  955 + unset($item['fieldset']);
  956 + $metadata[$fieldSet]['fieldset']=$fieldSet;
  957 + $metadata[$fieldSet]['fields'][]=$item;
  958 + }
937 } 959 }
938 - 960 +
  961 +
  962 + $this->addDebug('after processing',array('metadata'=>$metadata,'special'=>$special));
  963 +
939 $document_id=$arr['document_id']; 964 $document_id=$arr['document_id'];
940 965
941 $update_result=$this->update_document_metadata($arr['session_id'], $document_id, $metadata, $arr['application'], array()); 966 $update_result=$this->update_document_metadata($arr['session_id'], $document_id, $metadata, $arr['application'], array());
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 + public function jsondecode($params){
  26 + $this->setResponse(@json_decode(trim($params['code'])));
  27 + }
  28 +}
  29 +
  30 +?>
0 \ No newline at end of file 31 \ No newline at end of file