Commit 97a4f1184cafe3c39113f94836c70a96e036360d
Merge branch 'edge' of git@github.com:ktgit/knowledgetree into edge
Showing
75 changed files
with
1708 additions
and
1279 deletions
bin/system_info.php
| ... | ... | @@ -43,7 +43,12 @@ |
| 43 | 43 | * The following data is collected: |
| 44 | 44 | * Unique installation information: installation GUID, number of users in repository, number of documents in repository, |
| 45 | 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 | 52 | chdir(realpath(dirname(__FILE__))); |
| 48 | 53 | require_once('../config/dmsDefaults.php'); |
| 49 | 54 | |
| ... | ... | @@ -56,7 +61,7 @@ function getGuid() |
| 56 | 61 | $guid = KTUtil::getSystemIdentifier(); |
| 57 | 62 | |
| 58 | 63 | if(PEAR::isError($guid)){ |
| 59 | - $guid = ''; | |
| 64 | + $guid = '-'; | |
| 60 | 65 | } |
| 61 | 66 | return $guid; |
| 62 | 67 | } |
| ... | ... | @@ -68,42 +73,43 @@ function getUserCnt() |
| 68 | 73 | $result = DBUtil::getResultArray($query); |
| 69 | 74 | |
| 70 | 75 | if(empty($result) || PEAR::isError($result)){ |
| 71 | - return ''; | |
| 76 | + return '-|-|-'; | |
| 72 | 77 | } |
| 73 | - $users = ''; | |
| 78 | + $enabled = '-'; | |
| 79 | + $disabled = '-'; | |
| 80 | + $deleted = '-'; | |
| 74 | 81 | |
| 75 | 82 | foreach ($result as $row){ |
| 76 | - $str = ''; | |
| 77 | 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 | 92 | // Get the number of documents in the repository |
| 92 | 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 | 96 | $result2 = DBUtil::getResultArray($query); |
| 96 | 97 | |
| 97 | 98 | if(empty($result2) || PEAR::isError($result2)){ |
| 98 | - return ''; | |
| 99 | + return '-|-|-'; | |
| 99 | 100 | } |
| 100 | - $docs = ''; | |
| 101 | + $live = '-'; | |
| 102 | + $deleted = '-'; | |
| 103 | + $archived = '-'; | |
| 101 | 104 | |
| 102 | 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 | 115 | // Get the version of KT |
| ... | ... | @@ -121,15 +127,21 @@ function getKTVersion() |
| 121 | 127 | // Get the edition of KT |
| 122 | 128 | function getKTEdition() |
| 123 | 129 | { |
| 124 | - $edition = 'Community'; | |
| 130 | + $edition = 'Community|-'; | |
| 125 | 131 | if (KTPluginUtil::pluginIsActive('ktdms.wintools')) { |
| 126 | 132 | $path = KTPluginUtil::getPluginPath('ktdms.wintools'); |
| 127 | 133 | require_once($path . 'baobabkeyutil.inc.php'); |
| 128 | 134 | $edition = BaobabKeyUtil::getName(); |
| 129 | 135 | |
| 136 | + // this could be done with regular expressions... | |
| 130 | 137 | // Remove the brackets around the name |
| 131 | 138 | $edition = substr($edition, 1); |
| 132 | 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 | 146 | return $edition; |
| 135 | 147 | } |
| ... | ... | @@ -139,22 +151,27 @@ function getKTEdition() |
| 139 | 151 | function getOSInfo() |
| 140 | 152 | { |
| 141 | 153 | $server = php_uname(); |
| 154 | + $flavour = '';//'|-'; | |
| 142 | 155 | |
| 143 | 156 | if(strpos($server, 'Darwin') !== false){ |
| 144 | 157 | $os = 'Mac OS X'; |
| 145 | 158 | }else if(strpos($server, 'Win') !== false){ |
| 146 | 159 | $os = 'Windows'; |
| 147 | - }else { | |
| 160 | + }else if(strpos($server, 'Linux') !== false) { | |
| 161 | + // Again regular expressions would be nice... | |
| 162 | + // $pos = strpos($server, 'SMP'); | |
| 163 | + // $flavour = '|'.substr($server, 6, $pos-7); | |
| 148 | 164 | $os = 'Linux'; |
| 165 | + }else { | |
| 166 | + $os = 'Unix'; | |
| 149 | 167 | } |
| 150 | 168 | |
| 151 | - return $os; | |
| 169 | + return $os.$flavour; | |
| 152 | 170 | } |
| 153 | 171 | |
| 154 | 172 | function sendForm($data) |
| 155 | 173 | { |
| 156 | 174 | $url = 'http://ktnetwork.knowledgetree.com/call_home.php'; |
| 157 | - //$url = 'http://10.33.20.250/knowledgetree/call_home.php'; | |
| 158 | 175 | $data = http_build_query($data); |
| 159 | 176 | |
| 160 | 177 | $ch = curl_init($url); | ... | ... |
config/cache-path
config/config-path
config/config.ini
| ... | ... | @@ -9,14 +9,14 @@ |
| 9 | 9 | dbType = mysql |
| 10 | 10 | |
| 11 | 11 | ; Database login details |
| 12 | -dbHost = localhost | |
| 13 | -dbName = dms | |
| 14 | -dbUser = dms | |
| 15 | -dbPass = djw9281js | |
| 16 | -dbPort = default | |
| 12 | +dbHost = localhost | |
| 13 | +dbName = dms | |
| 14 | +dbUser = dms | |
| 15 | +dbPass = djw9281js | |
| 16 | +dbPort = default | |
| 17 | 17 | |
| 18 | -dbAdminUser = dmsadmin | |
| 19 | -dbAdminPass = js9281djw | |
| 18 | +dbAdminUser = dmsadmin | |
| 19 | +dbAdminPass = js9281djw | |
| 20 | 20 | |
| 21 | 21 | [KnowledgeTree] |
| 22 | 22 | |
| ... | ... | @@ -43,7 +43,7 @@ serverName = default |
| 43 | 43 | ; |
| 44 | 44 | ; Leave as default to have it automatically detected. |
| 45 | 45 | ; |
| 46 | -sslEnabled = default | |
| 46 | +sslEnabled = false | |
| 47 | 47 | |
| 48 | 48 | ; Path to the web application from the root of the web site. |
| 49 | 49 | ; If KT is at http://example.org/foo/, then rootUrl should be '/foo' |
| ... | ... | @@ -146,4 +146,4 @@ encoding = default |
| 146 | 146 | ; |
| 147 | 147 | cacheEnabled = true |
| 148 | 148 | cacheDirectory = ${varDirectory}/cache |
| 149 | -cachePlugins = true | |
| 150 | 149 | \ No newline at end of file |
| 150 | +cachePlugins = true | ... | ... |
lib/dispatcher.inc.php
| ... | ... | @@ -343,8 +343,8 @@ class KTStandardDispatcher extends KTDispatcher { |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | function loginRequired() { |
| 346 | - $oKTConfig =& KTConfig::getSingleton(); | |
| 347 | - if ($oKTConfig->get('allowAnonymousLogin', false)) { | |
| 346 | + $oKTConfig =& KTConfig::getSingleton(); | |
| 347 | + if ($oKTConfig->get('allowAnonymousLogin', false)) { | |
| 348 | 348 | // anonymous logins are now allowed. |
| 349 | 349 | // the anonymous user is -1. |
| 350 | 350 | // |
| ... | ... | @@ -352,9 +352,9 @@ class KTStandardDispatcher extends KTDispatcher { |
| 352 | 352 | |
| 353 | 353 | $oUser =& User::get(-2); |
| 354 | 354 | if (PEAR::isError($oUser) || ($oUser->getName() != 'Anonymous')) { |
| 355 | - ; // do nothing - the database integrity would break if we log the user in now. | |
| 355 | + ; // do nothing - the database integrity would break if we log the user in now. | |
| 356 | 356 | } else { |
| 357 | - $session = new Session(); | |
| 357 | + $session = new Session(); | |
| 358 | 358 | $sessionID = $session->create($oUser); |
| 359 | 359 | $this->sessionStatus = $this->session->verify(); |
| 360 | 360 | if ($this->sessionStatus === true) { | ... | ... |
lib/metadata/fieldsetregistry.inc.php
| ... | ... | @@ -111,7 +111,7 @@ class KTFieldsetRegistry { |
| 111 | 111 | */ |
| 112 | 112 | function getGenericFields($oFieldset, $idPre = 'metadata_') { |
| 113 | 113 | //return false if this isn't a generic fieldset |
| 114 | - if ($oFieldset->getIsGeneric()) { | |
| 114 | + if (!$oFieldset->getIsGeneric()) { | |
| 115 | 115 | return false; |
| 116 | 116 | } |
| 117 | 117 | ... | ... |
lib/session/Session.inc
| ... | ... | @@ -228,7 +228,7 @@ class Session { |
| 228 | 228 | // Compare the system version and the database version to determine if the database needs to be upgraded. |
| 229 | 229 | $version = KTUtil::getSystemSetting('databaseVersion'); |
| 230 | 230 | |
| 231 | - if ($default->systemVersion != $version) { | |
| 231 | + if (trim($default->systemVersion) != trim($version)) { | |
| 232 | 232 | if (KTLOG_CACHE) $default->log->info("Session::verify : Database not upgraded"); |
| 233 | 233 | $_SESSION['errormessage']['login'] = sprintf(_kt('Database incompatibility error: <br> Please ensure that you have completed the database upgrade procedure. <br> Please <a href=%s>click here</a> to complete.'),'setup/upgrade.php'); |
| 234 | 234 | return PEAR::raiseError($_SESSION['errormessage']['login']); | ... | ... |
plugins/multiselect/BulkImport.php
100644 โ 100755
| ... | ... | @@ -292,14 +292,17 @@ class InetBulkImportFolderMultiSelectAction extends KTFolderAction { |
| 292 | 292 | // name='metadata[fieldset][metadata_9]' |
| 293 | 293 | |
| 294 | 294 | $aData = $_REQUEST['data']; |
| 295 | + $data = $aData; | |
| 295 | 296 | |
| 297 | + /* | |
| 296 | 298 | $oForm = $this->getBulkImportForm(); |
| 297 | 299 | $res = $oForm->validate(); |
| 298 | 300 | if (!empty($res['errors'])) { |
| 299 | 301 | return $oForm->handleError(); |
| 300 | 302 | } |
| 301 | 303 | $data = $res['results']; |
| 302 | - | |
| 304 | + */ | |
| 305 | + | |
| 303 | 306 | $doctypeid = $requestDocumentType; |
| 304 | 307 | $aGenericFieldsetIds = KTFieldset::getGenericFieldsets(array('ids' => false)); |
| 305 | 308 | $aSpecificFieldsetIds = KTFieldset::getForDocumentType($doctypeid, array('ids' => false)); |
| ... | ... | @@ -312,6 +315,7 @@ class InetBulkImportFolderMultiSelectAction extends KTFolderAction { |
| 312 | 315 | |
| 313 | 316 | foreach ($fields as $oField) { |
| 314 | 317 | $val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId()); |
| 318 | + | |
| 315 | 319 | if ($oFieldset->getIsConditional()) |
| 316 | 320 | { |
| 317 | 321 | if ($val == _kt('No selection.')) |
| ... | ... | @@ -319,16 +323,16 @@ class InetBulkImportFolderMultiSelectAction extends KTFolderAction { |
| 319 | 323 | $val = null; |
| 320 | 324 | } |
| 321 | 325 | } |
| 322 | - | |
| 326 | + | |
| 323 | 327 | if (!is_null($val)) { |
| 324 | 328 | $MDPack[] = array( |
| 325 | 329 | $oField, |
| 326 | 330 | $val |
| 327 | 331 | ); |
| 328 | 332 | } |
| 329 | - | |
| 333 | + | |
| 330 | 334 | } |
| 331 | - } | |
| 335 | + } | |
| 332 | 336 | |
| 333 | 337 | $aOptions = array( |
| 334 | 338 | 'documenttype' => $oDocumentType, |
| ... | ... | @@ -340,7 +344,7 @@ class InetBulkImportFolderMultiSelectAction extends KTFolderAction { |
| 340 | 344 | $po->start(); |
| 341 | 345 | $oUploadChannel =& KTUploadChannel::getSingleton(); |
| 342 | 346 | $oUploadChannel->addObserver($po); |
| 343 | - | |
| 347 | + | |
| 344 | 348 | $fs =& new KTFSImportStorage($sPath); |
| 345 | 349 | $bm =& new KTBulkImportManager($this->oFolder, $fs, $this->oUser, $aOptions); |
| 346 | 350 | if(KTPluginUtil::pluginIsActive('inet.foldermetadata.plugin')) | ... | ... |
plugins/multiselect/BulkUpload.php
100644 โ 100755
| ... | ... | @@ -330,7 +330,6 @@ class InetBulkUploadFolderAction extends KTFolderAction { |
| 330 | 330 | foreach ($fields as $oField) { |
| 331 | 331 | //var_dump($oField->getId()); |
| 332 | 332 | $val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId()); |
| 333 | - //var_dump($val); | |
| 334 | 333 | if ($oFieldset->getIsConditional()) |
| 335 | 334 | { |
| 336 | 335 | if ($val == _kt('No selection.')) | ... | ... |
presentation/lookAndFeel/knowledgeTree/documentmanagement/getHtmlFields.php
| ... | ... | @@ -84,7 +84,7 @@ class GetHtmlFieldsDispatcher extends KTDispatcher { |
| 84 | 84 | $activesets = KTFieldset::getForDocumentType($iDocumentTypeID); |
| 85 | 85 | |
| 86 | 86 | foreach ($activesets as $oFieldset) { |
| 87 | - $htmlFieldIds = kt_array_merge($htmlFields, $oFReg->getHtmlFields($oFieldset)); | |
| 87 | + $htmlFieldIds = kt_array_merge($htmlFieldIds, $oFReg->getHtmlFields($oFieldset)); | |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | $jsOptions = '{ "htmlId" : {'; |
| ... | ... | @@ -101,20 +101,19 @@ class GetHtmlFieldsDispatcher extends KTDispatcher { |
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | 103 | * Returns a JSON object containing a list of fields belonging to a generic fieldset |
| 104 | - * for the given DocumentId | |
| 105 | 104 | * @return JSON Object |
| 106 | 105 | * |
| 107 | 106 | */ |
| 108 | - function getGenericFields($iDocumentTypeID) { | |
| 107 | + function getGenericFields() { | |
| 109 | 108 | $oFReg =& KTFieldsetRegistry::getSingleton(); |
| 110 | - $activesets = KTFieldset::getForDocumentType($iDocumentTypeID); | |
| 109 | + $activesets = KTFieldset::getGenericFieldsets(); | |
| 111 | 110 | |
| 112 | 111 | $fields = array(); |
| 113 | 112 | foreach ($activesets as $oFieldset) { |
| 114 | - $fieldIds = kt_array_merge($fields, $oFReg->getGenericFields($oFieldset)); | |
| 113 | + $fieldIds = kt_array_merge($fieldIds, $oFReg->getGenericFields($oFieldset)); | |
| 115 | 114 | } |
| 116 | 115 | |
| 117 | - $jsOptions = '{ "htmlId" : {'; | |
| 116 | + $jsOptions = '{ "genericId" : {'; | |
| 118 | 117 | |
| 119 | 118 | foreach($fieldIds as $fieldId) { |
| 120 | 119 | $jsOptions .= "'$fieldId' : '$fieldId',"; | ... | ... |
resources/js/kt_bulkupload.js
| ... | ... | @@ -19,10 +19,10 @@ function swapInItem(docId, elementId, req) { |
| 19 | 19 | //Need to compare against fields from generic fieldsets to |
| 20 | 20 | //prevent duplicate date field instanciation. |
| 21 | 21 | var genericFields = ''; |
| 22 | - //Sample { "htmlId" : {'metadata_7' : 'metadata_7','metadata_9' : 'metadata_9'}} | |
| 22 | + //Sample { "genericId" : {'metadata_7' : 'metadata_7','metadata_9' : 'metadata_9'}} | |
| 23 | 23 | jQuery.getJSON('presentation/lookAndFeel/knowledgeTree/documentmanagement/getHtmlFields.php?fDocumentTypeID=' + docId + '&type=generic', |
| 24 | 24 | function(json){ |
| 25 | - jQuery.each(json.htmlId, function(id) { | |
| 25 | + jQuery.each(json.genericId, function(id) { | |
| 26 | 26 | //Building a list of generic fields |
| 27 | 27 | genericFields += id + ','; |
| 28 | 28 | }); |
| ... | ... | @@ -30,16 +30,15 @@ function swapInItem(docId, elementId, req) { |
| 30 | 30 | var elems = jQuery(document).find(".kt_date_field"); |
| 31 | 31 | for (i = 0; i < elems.length; i++) { |
| 32 | 32 | var fieldName = elems[i].id; |
| 33 | - //alert(fieldName); | |
| 34 | - isGeneric = true; | |
| 35 | 33 | |
| 34 | + isGeneric = false; | |
| 36 | 35 | if (genericFields.indexOf(fieldName.match('metadata_[0-9]+')) >= 0){ |
| 37 | - isGeneric = false; | |
| 36 | + isGeneric = true; | |
| 38 | 37 | } |
| 39 | 38 | |
| 40 | 39 | if (!isGeneric){ |
| 41 | 40 | var dp = new Ext.form.DateField({ |
| 42 | - name: fieldName, | |
| 41 | + name: fieldName.replace('div_', ''), | |
| 43 | 42 | allowBlank:false, |
| 44 | 43 | size:10, |
| 45 | 44 | format: 'Y-m-d', | ... | ... |
setup/migrate/migrateUtil.php
| ... | ... | @@ -63,14 +63,14 @@ class MigrateUtil extends InstallUtil { |
| 63 | 63 | $template_vars['error'] = $error; |
| 64 | 64 | $file = "templates/error.tpl"; |
| 65 | 65 | if (!file_exists($file)) { |
| 66 | - return false; | |
| 66 | + extract($template_vars); // Extract the vars to local namespace | |
| 67 | + ob_start(); | |
| 68 | + include($file); | |
| 69 | + $contents = ob_get_contents(); | |
| 70 | + ob_end_clean(); | |
| 71 | + echo $contents; | |
| 67 | 72 | } |
| 68 | - extract($template_vars); // Extract the vars to local namespace | |
| 69 | - ob_start(); | |
| 70 | - include($file); | |
| 71 | - $contents = ob_get_contents(); | |
| 72 | - ob_end_clean(); | |
| 73 | - echo $contents; | |
| 73 | + return false; | |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
| ... | ... | @@ -89,19 +89,10 @@ class MigrateUtil extends InstallUtil { |
| 89 | 89 | |
| 90 | 90 | return true; |
| 91 | 91 | } |
| 92 | - | |
| 93 | - public function loadInstallDBUtil() { | |
| 94 | - require_once("../wizard/dbUtilities.php"); | |
| 95 | - return new dbUtilities(); | |
| 96 | - } | |
| 97 | - | |
| 98 | - public function loadInstallUtil() { | |
| 99 | - require_once("../wizard/steps/services.php"); | |
| 100 | - return new services(); | |
| 101 | - } | |
| 102 | 92 | |
| 103 | 93 | public function loadInstallServices() { |
| 104 | - $s = $this->loadInstallUtil(); | |
| 94 | + require_once("../wizard/steps/services.php"); | |
| 95 | + $s = new services(); | |
| 105 | 96 | return $s->getServices(); |
| 106 | 97 | } |
| 107 | 98 | |
| ... | ... | @@ -112,11 +103,6 @@ class MigrateUtil extends InstallUtil { |
| 112 | 103 | return new $serviceName(); |
| 113 | 104 | } |
| 114 | 105 | |
| 115 | - public function loadInstallIni($path) { | |
| 116 | - require_once("../wizard/iniUtilities.php"); | |
| 117 | - return new iniUtilities($path); | |
| 118 | - } | |
| 119 | - | |
| 120 | 106 | public function getPort($location) { |
| 121 | 107 | if(WINDOWS_OS) { |
| 122 | 108 | $myIni = "my.ini"; |
| ... | ... | @@ -125,8 +111,8 @@ class MigrateUtil extends InstallUtil { |
| 125 | 111 | } |
| 126 | 112 | $dbConfigPath = $location.DS."mysql".DS."$myIni"; |
| 127 | 113 | if(file_exists($dbConfigPath)) { |
| 128 | - $ini = $this->loadInstallIni($dbConfigPath); | |
| 129 | - $dbSettings = $ini->getSection('mysqladmin'); | |
| 114 | + $this->iniUtilities->load($dbConfigPath); | |
| 115 | + $dbSettings = $this->iniUtilities->getSection('mysqladmin'); | |
| 130 | 116 | return $dbSettings['port']; |
| 131 | 117 | } |
| 132 | 118 | ... | ... |
setup/migrate/migrateWizard.php
| ... | ... | @@ -52,16 +52,14 @@ function __autoload($class) { // Attempt and autoload classes |
| 52 | 52 | if ($class == "template") { // Load existing templating classes |
| 53 | 53 | require_once("../wizard/template.php"); |
| 54 | 54 | require_once("../wizard/lib/helpers/htmlHelper.php"); |
| 55 | - return ; | |
| 56 | - } | |
| 57 | - if(file_exists(WIZARD_DIR."$class.php")) { | |
| 58 | - require_once(WIZARD_DIR."$class.php"); | |
| 59 | - } elseif (file_exists(STEP_DIR."$class.php")) { | |
| 60 | - require_once(STEP_DIR."$class.php"); | |
| 61 | - } elseif (file_exists(WIZARD_LIB."$class.php")) { | |
| 62 | - require_once(WIZARD_LIB."$class.php"); | |
| 63 | 55 | } else { |
| 64 | - return null; | |
| 56 | + if(file_exists(WIZARD_DIR."$class.php")) { | |
| 57 | + require_once(WIZARD_DIR."$class.php"); | |
| 58 | + } elseif (file_exists(STEP_DIR."$class.php")) { | |
| 59 | + require_once(STEP_DIR."$class.php"); | |
| 60 | + } elseif (file_exists(WIZARD_LIB."$class.php")) { | |
| 61 | + require_once(WIZARD_LIB."$class.php"); | |
| 62 | + } | |
| 65 | 63 | } |
| 66 | 64 | } |
| 67 | 65 | |
| ... | ... | @@ -233,8 +231,6 @@ class MigrateWizard { |
| 233 | 231 | return true; |
| 234 | 232 | break; |
| 235 | 233 | } |
| 236 | - | |
| 237 | - return $res; | |
| 238 | 234 | } |
| 239 | 235 | |
| 240 | 236 | /** | ... | ... |
setup/migrate/migrater.php
| ... | ... | @@ -157,7 +157,7 @@ class Migrater { |
| 157 | 157 | $this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name); |
| 158 | 158 | } catch (Exception $e) { |
| 159 | 159 | $util = new MigrateUtil(); |
| 160 | - $util->error("Error reading configuration file: $name"); | |
| 160 | + $util->error("Error reading configuration file: $e"); | |
| 161 | 161 | exit(); |
| 162 | 162 | } |
| 163 | 163 | } |
| ... | ... | @@ -431,8 +431,7 @@ class Migrater { |
| 431 | 431 | if($class->runMigrate()) { // Check if step needs to be migrated |
| 432 | 432 | $class->setDataFromSession($className); // Set Session Information |
| 433 | 433 | $class->setPostConfig(); // Set any posted variables |
| 434 | - $response = $class->migrateStep(); // Run migrate step | |
| 435 | - // TODO : Break on error response | |
| 434 | + $class->migrateStep(); // Run migrate step | |
| 436 | 435 | } |
| 437 | 436 | } else { |
| 438 | 437 | $util = new MigrateUtil(); | ... | ... |
setup/migrate/step.php
| ... | ... | @@ -117,18 +117,8 @@ class Step |
| 117 | 117 | */ |
| 118 | 118 | public $util; |
| 119 | 119 | |
| 120 | - /** | |
| 121 | - * Reference to utility object | |
| 122 | - * | |
| 123 | - * @author KnowledgeTree Team | |
| 124 | - * @access protected | |
| 125 | - * @var object | |
| 126 | - */ | |
| 127 | - public $dbhandler; | |
| 128 | - | |
| 129 | 120 | public function __construct() { |
| 130 | 121 | $this->util = new MigrateUtil(); |
| 131 | - $this->dbhandler = $this->util->loadInstallDBUtil(); | |
| 132 | 122 | } |
| 133 | 123 | |
| 134 | 124 | /** | ... | ... |
setup/migrate/stepAction.php
| ... | ... | @@ -224,17 +224,18 @@ class stepAction { |
| 224 | 224 | if($this->action->storeInSession()) { // Check if class values need to be stored in session |
| 225 | 225 | $this->_loadStepToSession($this->stepName); // Send class to session |
| 226 | 226 | } |
| 227 | - if ($response == 'error') { | |
| 228 | - $this->_handleErrors(); // Send Errors to session | |
| 229 | - } else { | |
| 230 | - $this->_clearErrors($this->stepName); // Send Errors to session | |
| 231 | - } | |
| 232 | - return $response; | |
| 233 | 227 | } else { |
| 234 | 228 | $this->stepName = 'errors'; |
| 235 | 229 | $this->action = $this->createStep(); |
| 236 | 230 | $this->action->error = array('Class File Missing in Step Directory'); |
| 231 | + | |
| 232 | + } | |
| 233 | + if ($response == 'error') { | |
| 234 | + $this->_handleErrors(); // Send Errors to session | |
| 235 | + } else { | |
| 236 | + $this->_clearErrors($this->stepName); // Send Errors to session | |
| 237 | 237 | } |
| 238 | + return $response; | |
| 238 | 239 | } |
| 239 | 240 | |
| 240 | 241 | /** |
| ... | ... | @@ -308,7 +309,7 @@ class stepAction { |
| 308 | 309 | $menu = ''; |
| 309 | 310 | $active = false; |
| 310 | 311 | if($this->stepClassNames) { |
| 311 | - foreach ($this->stepClassNames as $k=>$step) { | |
| 312 | + foreach ($this->stepClassNames as $step) { | |
| 312 | 313 | if($this->step_names[$step] != '') { |
| 313 | 314 | $item = $this->step_names[$step]; |
| 314 | 315 | } else { |
| ... | ... | @@ -452,7 +453,7 @@ class stepAction { |
| 452 | 453 | * @access private |
| 453 | 454 | * @return void |
| 454 | 455 | */ |
| 455 | - private function _loadValueToSession($class, $k, $v, $overwrite = false) { | |
| 456 | + private function _loadValueToSession($class, $k, $v) { | |
| 456 | 457 | if($this->session != null) { |
| 457 | 458 | $this->session->setClass($class, $k, $v); |
| 458 | 459 | } else { |
| ... | ... | @@ -502,8 +503,7 @@ class stepAction { |
| 502 | 503 | * @access private |
| 503 | 504 | * @return void |
| 504 | 505 | */ |
| 505 | - private function _loadErrorToSession($class, $k, $v, $overwrite = false) { | |
| 506 | - $k = "errors"; | |
| 506 | + private function _loadErrorToSession($class, $k = "errors", $v) { | |
| 507 | 507 | if($this->session != null) { |
| 508 | 508 | $this->session->setClassError($class, $k, $v); |
| 509 | 509 | } else { | ... | ... |
setup/migrate/steps/migrateDatabase.php
| ... | ... | @@ -122,16 +122,16 @@ class migrateDatabase extends Step |
| 122 | 122 | $manual = false; // If file was exported manually |
| 123 | 123 | $dbSettings = $installation['dbSettings']; |
| 124 | 124 | $location = $installation['location']; |
| 125 | - $uname = $this->temp_variables['duname']; | |
| 126 | - $pwrd = $this->temp_variables['dpassword']; | |
| 125 | +// $uname = $this->temp_variables['duname']; | |
| 126 | +// $pwrd = $this->temp_variables['dpassword']; | |
| 127 | 127 | $port = $this->util->getPort($location); |
| 128 | 128 | $tmpFolder = $this->resolveTempDir(); |
| 129 | 129 | if(WINDOWS_OS) { |
| 130 | 130 | $termOrBash = "command prompt window"; |
| 131 | - $exe = "\"$location\mysql\bin\mysqldump.exe\""; // Location of dump | |
| 131 | + $exe = DS."$location".DS."mysql".DS."bin".DS."mysqldump.exe".DS; // Location of dump | |
| 132 | 132 | } else { |
| 133 | 133 | $termOrBash = "terminal window"; |
| 134 | - $exe = "'$location/mysql/bin/mysqldump'"; // Location of dump | |
| 134 | + $exe = "'$location".DS."mysql".DS."bin".DS."mysqldump'"; // Location of dump | |
| 135 | 135 | } |
| 136 | 136 | $date = date('Y-m-d-H-i-s'); |
| 137 | 137 | if(isset($database['manual_export'])) { |
| ... | ... | @@ -147,7 +147,7 @@ class migrateDatabase extends Step |
| 147 | 147 | if(!$manual) { // Try to export database |
| 148 | 148 | $sqlFile = $tmpFolder."/kt-backup-$date.sql"; |
| 149 | 149 | $cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.$dbName.' > '.$sqlFile; |
| 150 | - $response = $this->util->pexec($cmd); | |
| 150 | + $this->util->pexec($cmd); | |
| 151 | 151 | } |
| 152 | 152 | if(file_exists($sqlFile)) { |
| 153 | 153 | $fileContents = file_get_contents($sqlFile); | ... | ... |
setup/migrate/steps/migrateInstallation.php
| ... | ... | @@ -85,10 +85,6 @@ class migrateInstallation extends step |
| 85 | 85 | private $ktSettings = array(); |
| 86 | 86 | |
| 87 | 87 | private $urlPaths = array(); |
| 88 | - | |
| 89 | - private $knownWindowsLocations = array("C:\Program Files\ktdms"=>"C:\Program Files\ktdms\knowledgeTree\config\config-path","C:\Program Files x86\ktdms"=>"C:\Program Files x86\ktdms\knowledgeTree\config\config-path","C:\ktdms"=>"C:\ktdms\knowledgeTree\config\config-path"); | |
| 90 | - | |
| 91 | - private $knownUnixLocations = array("/opt/ktdms","/var/www/ktdms"); | |
| 92 | 88 | |
| 93 | 89 | /** |
| 94 | 90 | * Installation Settings |
| ... | ... | @@ -132,12 +128,14 @@ class migrateInstallation extends step |
| 132 | 128 | |
| 133 | 129 | public function detectInstallation() { |
| 134 | 130 | if(WINDOWS_OS) { |
| 135 | - foreach ($this->knownWindowsLocations as $loc=>$configPath) { | |
| 131 | + $knownWindowsLocations = array("C:\Program Files\ktdms"=>"C:\Program Files\ktdms\knowledgeTree\config\config-path","C:\Program Files x86\ktdms"=>"C:\Program Files x86\ktdms\knowledgeTree\config\config-path","C:\ktdms"=>"C:\ktdms\knowledgeTree\config\config-path"); | |
| 132 | + foreach ($knownWindowsLocations as $loc=>$configPath) { | |
| 136 | 133 | if(file_exists($configPath)) |
| 137 | 134 | $this->location = $loc; |
| 138 | 135 | } |
| 139 | 136 | } else { |
| 140 | - foreach ($this->knownUnixLocations as $loc=>$configPath) { | |
| 137 | + $knownUnixLocations = array("/opt/ktdms"=>"/opt/ktdms/knowledgeTree/config/config-path","/var/www/ktdms"=>"/var/www/ktdms/knowledgeTree/config/config-path"); | |
| 138 | + foreach ($knownUnixLocations as $loc=>$configPath) { | |
| 141 | 139 | if(file_exists($configPath)) |
| 142 | 140 | $this->location = $loc; |
| 143 | 141 | } |
| ... | ... | @@ -149,7 +147,8 @@ class migrateInstallation extends step |
| 149 | 147 | $this->storeSilent(); |
| 150 | 148 | return false; |
| 151 | 149 | } else { |
| 152 | - if($this->readVersion()) { | |
| 150 | + $this->foundVersion = $this->readVersion(); | |
| 151 | + if($this->foundVersion) { | |
| 153 | 152 | $this->checkVersion(); |
| 154 | 153 | } |
| 155 | 154 | $this->storeSilent(); |
| ... | ... | @@ -162,16 +161,17 @@ class migrateInstallation extends step |
| 162 | 161 | if($this->foundVersion < $this->supportedVersion) { |
| 163 | 162 | $this->versionError = true; |
| 164 | 163 | $this->error[] = "KT installation needs to be 3.6.1 or higher"; |
| 165 | - } else { | |
| 166 | - return true; | |
| 164 | + return false; | |
| 167 | 165 | } |
| 166 | + | |
| 167 | + return true; | |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | public function readVersion() { |
| 171 | 171 | $verFile = $this->location."/knowledgeTree/docs/VERSION.txt"; |
| 172 | 172 | if(file_exists($verFile)) { |
| 173 | - $this->foundVersion = file_get_contents($verFile); | |
| 174 | - return true; | |
| 173 | + $foundVersion = file_get_contents($verFile); | |
| 174 | + return $foundVersion; | |
| 175 | 175 | } else { |
| 176 | 176 | $this->error[] = "KT installation version not found"; |
| 177 | 177 | } |
| ... | ... | @@ -222,11 +222,13 @@ class migrateInstallation extends step |
| 222 | 222 | } else { |
| 223 | 223 | $this->error[] = "Please Enter a Location"; |
| 224 | 224 | } |
| 225 | + | |
| 226 | + return false; | |
| 225 | 227 | } |
| 226 | 228 | |
| 227 | 229 | private function loadConfig($path) { |
| 228 | - $ini = $this->util->loadInstallIni($path); | |
| 229 | - $dbSettings = $ini->getSection('db'); | |
| 230 | + $this->util->iniUtilities->load($path); | |
| 231 | + $dbSettings = $this->util->iniUtilities->getSection('db'); | |
| 230 | 232 | $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'], |
| 231 | 233 | 'dbName'=> $dbSettings['dbName'], |
| 232 | 234 | 'dbUser'=> $dbSettings['dbUser'], |
| ... | ... | @@ -235,14 +237,15 @@ class migrateInstallation extends step |
| 235 | 237 | 'dbAdminUser'=> $dbSettings['dbAdminUser'], |
| 236 | 238 | 'dbAdminPass'=> $dbSettings['dbAdminPass'], |
| 237 | 239 | ); |
| 238 | - $ktSettings = $ini->getSection('KnowledgeTree'); | |
| 240 | + $ktSettings = $this->util->iniUtilities->getSection('KnowledgeTree'); | |
| 239 | 241 | $froot = $ktSettings['fileSystemRoot']; |
| 242 | +// print_r($ktSettings); | |
| 243 | +// die; | |
| 240 | 244 | if ($froot == 'default') { |
| 241 | 245 | $froot = $this->location; |
| 242 | 246 | } |
| 243 | 247 | $this->ktSettings = array('fileSystemRoot'=> $froot, |
| 244 | 248 | ); |
| 245 | - $urlPaths = $ini->getSection('urls'); | |
| 246 | 249 | $varDir = $froot.DS.'var'; |
| 247 | 250 | $this->urlPaths = array(array('name'=> 'Var Directory', 'path'=> $varDir), |
| 248 | 251 | array('name'=> 'Log Directory', 'path'=> $varDir.DS.'log'), | ... | ... |
setup/migrate/steps/migrateServices.php
| ... | ... | @@ -127,7 +127,6 @@ class migrateServices extends Step |
| 127 | 127 | public function doStep() |
| 128 | 128 | { |
| 129 | 129 | $this->temp_variables = array("step_name"=>"services", "silent"=>$this->silent); |
| 130 | - $this->installServices = $this->util->loadInstallUtil(); // Use installer utility class | |
| 131 | 130 | $this->services = $this->util->loadInstallServices(); // Use installer services class |
| 132 | 131 | $this->storeSilent(); |
| 133 | 132 | if(!$this->inStep("services")) { |
| ... | ... | @@ -202,11 +201,11 @@ class migrateServices extends Step |
| 202 | 201 | */ |
| 203 | 202 | public function unixStop() { |
| 204 | 203 | $cmd = $this->conf['location']."/dmsctl.sh stop lucene"; |
| 205 | - $res = $this->util->pexec($cmd); | |
| 204 | + $this->util->pexec($cmd); | |
| 206 | 205 | $cmd = $this->conf['location']."/dmsctl.sh stop scheduler"; |
| 207 | - $res = $this->util->pexec($cmd); | |
| 206 | + $this->util->pexec($cmd); | |
| 208 | 207 | $cmd = $this->conf['location']."/dmsctl.sh stop soffice"; |
| 209 | - $res = $this->util->pexec($cmd); | |
| 208 | + $this->util->pexec($cmd); | |
| 210 | 209 | } |
| 211 | 210 | |
| 212 | 211 | /** |
| ... | ... | @@ -215,11 +214,11 @@ class migrateServices extends Step |
| 215 | 214 | */ |
| 216 | 215 | public function windowsStop() { |
| 217 | 216 | $cmd = "sc delete KTLucene"; |
| 218 | - $res = $this->util->pexec($cmd); | |
| 217 | + $this->util->pexec($cmd); | |
| 219 | 218 | $cmd = "sc delete KTScheduler"; |
| 220 | - $res = $this->util->pexec($cmd); | |
| 219 | + $this->util->pexec($cmd); | |
| 221 | 220 | $cmd = "sc delete KTOpenoffice"; |
| 222 | - $res = $this->util->pexec($cmd); | |
| 221 | + $this->util->pexec($cmd); | |
| 223 | 222 | } |
| 224 | 223 | |
| 225 | 224 | /** |
| ... | ... | @@ -233,7 +232,7 @@ class migrateServices extends Step |
| 233 | 232 | $serv->load(); |
| 234 | 233 | $sStatus = $serv->status(); |
| 235 | 234 | if($sStatus != '') { |
| 236 | - $res = $serv->uninstall(); | |
| 235 | + $serv->uninstall(); | |
| 237 | 236 | } |
| 238 | 237 | } |
| 239 | 238 | } | ... | ... |
setup/migrate/templates/error.tpl
| 1 | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 2 | 2 | <html> |
| 3 | 3 | <head> |
| 4 | + <link rel="shortcut icon" href="../wizard/resources/graphics/favicon.ico" type="image/x-icon"> | |
| 4 | 5 | <title>KnowledgeTree Installer</title> |
| 5 | 6 | <script type="text/javascript" src="resources/jquery.js"></script> |
| 6 | 7 | <script type="text/javascript" src="resources/wizard.js" ></script> |
| 7 | 8 | <link rel="stylesheet" type="text/css" href="resources/wizard.css" /> |
| 8 | - | |
| 9 | 9 | </head> |
| 10 | 10 | |
| 11 | 11 | <body onload=""> |
| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | <div id="logo"><img src="resources/graphics/dame/installer-header_logo.png"/></div> |
| 15 | 15 | <div id="install_details"> |
| 16 | 16 | <span style="font-size:120%;"> 3.7 </span> |
| 17 | - <span style="font-size:80%;">Commercial Edition</span> | |
| 17 | + <span style="font-size:80%;">Community Edition</span> | |
| 18 | 18 | </div> |
| 19 | 19 | </div> |
| 20 | 20 | <div id="wrapper"> | ... | ... |
setup/migrate/templates/wizard.tpl
| 1 | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 2 | 2 | <html> |
| 3 | 3 | <head> |
| 4 | + <link rel="shortcut icon" href="../wizard/resources/graphics/favicon.ico" type="image/x-icon"> | |
| 4 | 5 | <title>KnowledgeTree Installer</title> |
| 5 | 6 | <?php echo $html->js('jquery.js'); ?> |
| 6 | 7 | <?php echo $html->js('jquery.form.js'); ?> | ... | ... |
setup/postcheckup.php
| ... | ... | @@ -38,7 +38,7 @@ |
| 38 | 38 | |
| 39 | 39 | $checkup = true; |
| 40 | 40 | error_reporting(E_ALL); |
| 41 | -require_once('../config/dmsDefaults.php'); | |
| 41 | +//require_once('../config/dmsDefaults.php'); | |
| 42 | 42 | |
| 43 | 43 | function writablePath($name, $path) { |
| 44 | 44 | $ret = sprintf('<tr><td>%s (%s)</td><td>', $name, $path); | ... | ... |
setup/precheckup.php
setup/upgrade/lib/UpgradeItems.inc.php
0 โ 100644
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * $Id$ | |
| 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 | + * Contributor( s): ______________________________________ | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + | |
| 39 | +// {{{ Format of the descriptor | |
| 40 | +/** | |
| 41 | + * Format of the descriptor | |
| 42 | + * | |
| 43 | + * type*version*phase*simple description for uniqueness | |
| 44 | + * | |
| 45 | + * type is: sql, function, subupgrade, upgrade | |
| 46 | + * version is: 1.2.4, 2.0.0rc5 | |
| 47 | + * phase is: 0, 1, 0pre. Phase is _only_ evaluated by describeUpgrades. | |
| 48 | + * description is: anything, unique in terms of version and type. | |
| 49 | + */ | |
| 50 | +// }}} | |
| 51 | + | |
| 52 | +//require_once(KT_LIB_DIR . '/upgrades/UpgradeFunctions.inc.php'); | |
| 53 | +require_once('sqlfile.inc.php'); | |
| 54 | +require_once('datetime.inc'); | |
| 55 | + | |
| 56 | +// {{{ Upgrade_Already_Applied | |
| 57 | +class Upgrade_Already_Applied { //extends PEAR_Error { | |
| 58 | + function Upgrade_Already_Applied($oUpgradeItem) { | |
| 59 | + $this->oUpgradeItem = $oUpgradeItem; | |
| 60 | + } | |
| 61 | +} | |
| 62 | +// }}} | |
| 63 | + | |
| 64 | +class UpgradeItem extends InstallUtil { | |
| 65 | + var $type = ""; | |
| 66 | + var $name; | |
| 67 | + var $version; | |
| 68 | + var $description; | |
| 69 | + var $phase; | |
| 70 | + var $priority = 0; | |
| 71 | + var $parent; | |
| 72 | + var $date; | |
| 73 | + var $result; | |
| 74 | + | |
| 75 | + function UpgradeItem($name, $version, $description = null, $phase = 0, $priority = 0) { | |
| 76 | + $this->name = $name; | |
| 77 | + $this->version = $version; | |
| 78 | + if (is_null($description)) { | |
| 79 | + $description = $this->type . " upgrade to version " . $version . " phase " . $phase; | |
| 80 | + } | |
| 81 | + $this->description = $description; | |
| 82 | + $this->phase = $phase; | |
| 83 | + $this->priority = $priority; | |
| 84 | + parent::__construct(); | |
| 85 | +// print_r($this); | |
| 86 | +// die; | |
| 87 | + } | |
| 88 | + | |
| 89 | + function setParent($parent) { | |
| 90 | + $this->parent = $parent; | |
| 91 | + } | |
| 92 | + function setDate($date) { | |
| 93 | + $this->date = $date; | |
| 94 | + } | |
| 95 | + | |
| 96 | + function getDescriptor() { | |
| 97 | + return join("*", array($this->type, $this->version, $this->phase, $this->name)); | |
| 98 | + } | |
| 99 | + | |
| 100 | + function getDescription() { | |
| 101 | + return $this->description; | |
| 102 | + } | |
| 103 | + | |
| 104 | + function getVersion() { | |
| 105 | + return $this->version; | |
| 106 | + } | |
| 107 | + | |
| 108 | + function getPhase() { | |
| 109 | + return $this->phase; | |
| 110 | + } | |
| 111 | + | |
| 112 | + function getPriority() { | |
| 113 | + return $this->priority; | |
| 114 | + } | |
| 115 | + | |
| 116 | + function getType() { | |
| 117 | + return $this->type; | |
| 118 | + } | |
| 119 | + | |
| 120 | + function runDBQuery($query, $checkResult = false, $typeCheck = false) { | |
| 121 | + require_once("../wizard/steps/configuration.php"); // configuration to read the ini path | |
| 122 | + $wizConfigHandler = new configuration(); | |
| 123 | + $configPath = $wizConfigHandler->readConfigPathIni(); | |
| 124 | + if(!is_object($this->iniUtilities)) { | |
| 125 | + parent::__construct(); | |
| 126 | + } | |
| 127 | + $this->iniUtilities->load($configPath); | |
| 128 | + $dconf = $this->iniUtilities->getSection('db'); | |
| 129 | + $this->dbUtilities->load($dconf['dbHost'], '', $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']); | |
| 130 | + $result = $this->dbUtilities->query($query); | |
| 131 | +// echo "$query<br/>"; | |
| 132 | +// echo '<pre>'; | |
| 133 | +// print_r($result); | |
| 134 | +// echo '</pre>'; | |
| 135 | + if($checkResult) { | |
| 136 | + $assArr = $this->dbUtilities->fetchAssoc($result); | |
| 137 | +// echo '<pre>'; | |
| 138 | +// print_r($assArr); | |
| 139 | +// echo '</pre>'; | |
| 140 | +// if(is_null($assArr)) { | |
| 141 | +// echo '=== null ===<br/>'; | |
| 142 | +// return false; | |
| 143 | +// } else { | |
| 144 | +// echo '=== not null ===<br/>'; | |
| 145 | +// } | |
| 146 | + if($typeCheck) { | |
| 147 | + return !is_null($assArr); | |
| 148 | + } else { | |
| 149 | + return is_null($assArr); | |
| 150 | + } | |
| 151 | + } | |
| 152 | +// echo '<pre>'; | |
| 153 | +// print_r($assArr); | |
| 154 | +// echo '</pre>'; | |
| 155 | + return !is_null($result); | |
| 156 | + } | |
| 157 | + | |
| 158 | + function _upgradeTableInstalled() { | |
| 159 | + $query = "SELECT COUNT(id) FROM upgrades"; | |
| 160 | + $res = $this->runDBQuery($query, true, true); | |
| 161 | + if($res) { | |
| 162 | + return true; | |
| 163 | + } | |
| 164 | + return false; | |
| 165 | + } | |
| 166 | + | |
| 167 | + function isAlreadyApplied() { | |
| 168 | + if (!$this->_upgradeTableInstalled()) { | |
| 169 | + return false; | |
| 170 | + } | |
| 171 | + $query = "SELECT id FROM upgrades WHERE descriptor = '".$this->getDescriptor()."' AND result = 1"; | |
| 172 | + $res = $this->runDBQuery($query, true, false); | |
| 173 | + | |
| 174 | + if(!$res) { | |
| 175 | + return true; | |
| 176 | + } | |
| 177 | + return false; | |
| 178 | + } | |
| 179 | + | |
| 180 | + function performUpgrade($force = false) { | |
| 181 | + $res = $this->isAlreadyApplied(); | |
| 182 | + if ($res === true) { | |
| 183 | + if ($force !== true) { | |
| 184 | + // PHP5: Exception | |
| 185 | + return new Upgrade_Already_Applied($this); | |
| 186 | + } | |
| 187 | + } | |
| 188 | +// if (!$res) { | |
| 189 | +// $this->error[] = 'An Error Has Occured'; | |
| 190 | +// } | |
| 191 | +// $oCache =& KTCache::getSingleton(); | |
| 192 | +// $save = $oCache->bEnabled; | |
| 193 | +// $oCache->bEnabled = false; | |
| 194 | + $res = $this->_performUpgrade(); | |
| 195 | +// $oCache->bEnabled = $save; | |
| 196 | + if (!$res) { | |
| 197 | + $this->_recordUpgrade(false); | |
| 198 | + $this->error[] = $this->dbUtilities->getErrors(); | |
| 199 | + return false; | |
| 200 | + } | |
| 201 | + $res = $this->_recordUpgrade(true); | |
| 202 | + if (!$res) { | |
| 203 | + $this->error[] = 'An Error Has Occured 1'; | |
| 204 | + return false; | |
| 205 | + } | |
| 206 | + return true; | |
| 207 | + } | |
| 208 | + | |
| 209 | + function _performUpgrade() { | |
| 210 | + $this->error[] = 'Unimplemented'; | |
| 211 | + return false; | |
| 212 | + } | |
| 213 | + | |
| 214 | + function _recordUpgrade($result) { | |
| 215 | + if (is_null($this->date)) { | |
| 216 | + $this->date = getCurrentDateTime(); | |
| 217 | + } | |
| 218 | + if ($this->parent) { | |
| 219 | + $parentid = $this->parent->getDescriptor(); | |
| 220 | + } else { | |
| 221 | + $parentid = null; | |
| 222 | + } | |
| 223 | + $sql = "INSERT INTO upgrades (`id`, `descriptor`, `description`, `date_performed`, `result`, `parent`) VALUES ('', '". $this->getDescriptor()."', '".$this->description."', '".$this->date."', '".$result."', '".$parentid."')"; | |
| 224 | + $this->dbUtilities->query($sql); | |
| 225 | + | |
| 226 | + return true; | |
| 227 | + } | |
| 228 | + | |
| 229 | + // STATIC | |
| 230 | + function getAllUpgrades() { | |
| 231 | + return array(); | |
| 232 | + } | |
| 233 | + | |
| 234 | + | |
| 235 | +} | |
| 236 | + | |
| 237 | +class SQLUpgradeItem extends UpgradeItem { | |
| 238 | + function SQLUpgradeItem($path, $version = null, $description = null, $phase = null, $priority = null) { | |
| 239 | + $this->type = "sql"; | |
| 240 | + $this->priority = 0; | |
| 241 | + $details = $this->_getDetailsFromFileName($path); | |
| 242 | + if (is_null($version)) { | |
| 243 | + $version = $details[1]; | |
| 244 | + } | |
| 245 | + if (is_null($description)) { | |
| 246 | + $description = $details[2]; | |
| 247 | + } | |
| 248 | + if (is_null($phase)) { | |
| 249 | + $phase = $details[3]; | |
| 250 | + } | |
| 251 | + if (is_null($priority)) { | |
| 252 | + $priority = isset($details[4]) ? $details[4] : 0; | |
| 253 | + } | |
| 254 | + $this->UpgradeItem($path, $version, $description, $phase, $priority); | |
| 255 | + } | |
| 256 | + | |
| 257 | + /** | |
| 258 | + * Describe the SQL scripts that will be used to upgrade KnowledgeTree | |
| 259 | + * | |
| 260 | + * Return an array of arrays with two components: a string identifier | |
| 261 | + * that uniquely describes the step to be taken and a string which is an | |
| 262 | + * HTML-formatted description of the step to be taken. These will be | |
| 263 | + * returned in any order - describeUpgrade performs the ordering. | |
| 264 | + * | |
| 265 | + * @param string Original version (e.g., "1.2.4") | |
| 266 | + * @param string Current version (e.g., "2.0.2") | |
| 267 | + * | |
| 268 | + * @return array Array of SQLUpgradeItem describing steps to be taken | |
| 269 | + * | |
| 270 | + * STATIC | |
| 271 | + */ | |
| 272 | + public static function getUpgrades($origVersion, $currVersion) { | |
| 273 | +// global $default; | |
| 274 | + | |
| 275 | +// $sqlupgradedir = KT_DIR . '/sql/' . $default->dbType . '/upgrade/'; | |
| 276 | + $dbType = 'mysql'; | |
| 277 | + $sqlupgradedir = KT_DIR . 'sql/' . $dbType . '/upgrade/'; | |
| 278 | + $ret = array(); | |
| 279 | + | |
| 280 | + if (!is_dir($sqlupgradedir)) { | |
| 281 | +// return PEAR::raiseError("SQL Upgrade directory ($sqlupgradedir) not accessible"); | |
| 282 | + } | |
| 283 | + if (!($dh = opendir($sqlupgradedir))) { | |
| 284 | +// return PEAR::raiseError("SQL Upgrade directory ($sqlupgradedir) not accessible"); | |
| 285 | + } | |
| 286 | + | |
| 287 | + while (($file = readdir($dh)) !== false) { | |
| 288 | + // Each entry can be a file or a directory | |
| 289 | + // | |
| 290 | + // A file is legacy before the upgrade system was created, but | |
| 291 | + // will be supported anyway. | |
| 292 | + // | |
| 293 | + // A directory is the end-result version: so, 2.0.5 contains | |
| 294 | + // every script that differentiates it from a previous version, | |
| 295 | + // say, 2.0.5rc1 or 2.0.4. | |
| 296 | + // | |
| 297 | + if (in_array($file, array('.', '..', 'CVS'))) { | |
| 298 | + continue; | |
| 299 | + } | |
| 300 | + $fullpath = $sqlupgradedir . $file; | |
| 301 | + if (is_file($fullpath)) { | |
| 302 | + // Legacy file support, will be in form of | |
| 303 | + // 1.2.4-to-2.0.0.sql. | |
| 304 | + $details = SQLUpgradeItem::_getDetailsFromFileName($file); | |
| 305 | + if ($details) { | |
| 306 | + if (!gte_version($details[0], $origVersion)) { | |
| 307 | + continue; | |
| 308 | + } | |
| 309 | + if (!lte_version($details[1], $currVersion)) { | |
| 310 | + continue; | |
| 311 | + } | |
| 312 | + //print "Will run $file\n"; | |
| 313 | +// print_r($this->util->dbUtilities); | |
| 314 | +// die; | |
| 315 | + $ret[] = new SQLUpgradeItem($file); | |
| 316 | + } | |
| 317 | + } | |
| 318 | + if (is_dir($fullpath)) { | |
| 319 | + $subdir = $file; | |
| 320 | + if (!($subdh = opendir($fullpath))) { | |
| 321 | + continue; | |
| 322 | + } | |
| 323 | + while (($file = readdir($subdh)) !== false) { | |
| 324 | + $relpath = $subdir . '/' . $file; | |
| 325 | + $details = SQLUpgradeItem::_getDetailsFromFileName($relpath); | |
| 326 | + if ($details) { | |
| 327 | + if (!gte_version($details[0], $origVersion)) { | |
| 328 | + continue; | |
| 329 | + } | |
| 330 | + if (!lte_version($details[1], $currVersion)) { | |
| 331 | + continue; | |
| 332 | + } | |
| 333 | + //print "Will run $file\n"; | |
| 334 | +// print_r(SQLUpgradeItem::); | |
| 335 | +// die; | |
| 336 | +// new InstallUtil(); | |
| 337 | + $ret[] = new SQLUpgradeItem($relpath); | |
| 338 | + } | |
| 339 | + } | |
| 340 | + } | |
| 341 | + } | |
| 342 | + closedir($dh); | |
| 343 | + return $ret; | |
| 344 | + } | |
| 345 | + | |
| 346 | + public static function _getDetailsFromFileName($path) { | |
| 347 | + // Old format (pre 2.0.6) | |
| 348 | + $matched = preg_match('#^([\d.]*)-to-([\d.]*).sql$#', $path, $matches); | |
| 349 | + if ($matched != 0) { | |
| 350 | + $fromVersion = $matches[1]; | |
| 351 | + $toVersion = $matches[2]; | |
| 352 | + $description = "Database upgrade from version $fromVersion to $toVersion"; | |
| 353 | + $phase = 0; | |
| 354 | + return array($fromVersion, $toVersion, $description, $phase); | |
| 355 | + } | |
| 356 | + $matched = preg_match('#^([\d.]*)/(?:(\d*)-)?(.*)\.sql$#', $path, $matches); | |
| 357 | + //$matched = preg_match('#^([\d.]*)/(?:(\d*)-)?(.*):(?:(\d*))\.sql$#', $path, $matches); | |
| 358 | + if ($matched != 0) { | |
| 359 | + $fromVersion = $matches[1]; | |
| 360 | + $toVersion = $matches[1]; | |
| 361 | + $in = array('_'); | |
| 362 | + $out = array(' '); | |
| 363 | + $phase = (int)$matches[2]; | |
| 364 | + | |
| 365 | + //$priority = (int)$matches[4]; | |
| 366 | + $priority = 0; | |
| 367 | + $iPriority = preg_match('#^(.*)-(\d*)$#', $matches[3], $priorities); | |
| 368 | + if($iPriority != 0){ | |
| 369 | + $priority = $priorities[2]; | |
| 370 | + $matches[3] = $priorities[1]; | |
| 371 | + } | |
| 372 | + | |
| 373 | + $description = "Database upgrade to version $toVersion: " . ucfirst(str_replace($in, $out, $matches[3])); | |
| 374 | + return array($fromVersion, $toVersion, $description, $phase, $priority); | |
| 375 | + } | |
| 376 | + // XXX: handle new format | |
| 377 | + return null; | |
| 378 | + } | |
| 379 | + | |
| 380 | + function _performUpgrade() { | |
| 381 | + $dbType = 'mysql'; | |
| 382 | + $sqlupgradedir = KT_DIR . 'sql/' . $dbType . '/upgrade/'; | |
| 383 | + $queries = SQLFile::sqlFromFile($sqlupgradedir . $this->name); | |
| 384 | + return $this->dbUtilities->runQueries($queries); | |
| 385 | + } | |
| 386 | + | |
| 387 | + | |
| 388 | +} | |
| 389 | + | |
| 390 | +class KTRebuildPermissionObserver { | |
| 391 | + function start() { | |
| 392 | + $this->lastBeat = time(); | |
| 393 | + } | |
| 394 | + function receiveMessage() { | |
| 395 | + $now = time(); | |
| 396 | + if ($this->lastBeat + 15 < $now) { | |
| 397 | + print "<!-- -->"; | |
| 398 | + ob_flush(); | |
| 399 | + flush(); | |
| 400 | + } | |
| 401 | + } | |
| 402 | + function end() { | |
| 403 | + } | |
| 404 | +} | |
| 405 | + | |
| 406 | +class RecordUpgradeItem extends UpgradeItem { | |
| 407 | + function RecordUpgradeItem ($version, $oldversion = null) { | |
| 408 | + $this->type = "upgrade"; | |
| 409 | + if (is_null($oldversion)) { | |
| 410 | + $this->description = "Upgrade to version $version"; | |
| 411 | + } else { | |
| 412 | + $this->description = "Upgrade from version $oldversion to $version"; | |
| 413 | + } | |
| 414 | + $this->phase = 99; | |
| 415 | + $this->version = $version; | |
| 416 | + $this->name = 'upgrade' . $version; | |
| 417 | + } | |
| 418 | + | |
| 419 | + function _performUpgrade() { | |
| 420 | +// $this->_deleteSmartyFiles(); | |
| 421 | +// $this->_deleteProxyFiles(); | |
| 422 | +// require_once(KT_LIB_DIR . '/cache/cache.inc.php'); | |
| 423 | +// $oCache =& KTCache::getSingleton(); | |
| 424 | +// $oCache->deleteAllCaches(); | |
| 425 | + // TODO : clear cache folder | |
| 426 | +// require_once(KT_LIB_DIR . '/permissions/permissionutil.inc.php'); | |
| 427 | + // TODO : What does this do | |
| 428 | +// $po =& new KTRebuildPermissionObserver($this); | |
| 429 | +// $po->start(); | |
| 430 | +// $oChannel =& KTPermissionChannel::getSingleton(); | |
| 431 | +// $oChannel->addObserver($po); | |
| 432 | + | |
| 433 | + set_time_limit(0); | |
| 434 | + ignore_user_abort(true); | |
| 435 | + | |
| 436 | +// KTPermissionUtil::rebuildPermissionLookups(true); | |
| 437 | +// $po->end(); | |
| 438 | + | |
| 439 | + $versionFile=KT_DIR . '/docs/VERSION-NAME.txt'; | |
| 440 | + $fp = fopen($versionFile,'rt'); | |
| 441 | + $systemVersion = fread($fp, filesize($versionFile)); | |
| 442 | + fclose($fp); | |
| 443 | + | |
| 444 | + $query = "UPDATE system_settings SET value = '$systemVersion' WHERE name = 'knowledgetreeVersion'"; | |
| 445 | + $this->runDBQuery($query); | |
| 446 | + $query = "UPDATE system_settings SET value = '{$this->version}' WHERE name = 'databaseVersion'"; | |
| 447 | + $result = $this->runDBQuery($query); | |
| 448 | + return $result; | |
| 449 | + } | |
| 450 | + | |
| 451 | + function _deleteSmartyFiles() { | |
| 452 | + $oConfig =& KTConfig::getSingleton(); | |
| 453 | + $dir = sprintf('%s/%s', $oConfig->get('urls/varDirectory'), 'tmp'); | |
| 454 | + | |
| 455 | + $dh = @opendir($dir); | |
| 456 | + if (empty($dh)) { | |
| 457 | + return; | |
| 458 | + } | |
| 459 | + $aFiles = array(); | |
| 460 | + while (false !== ($sFilename = readdir($dh))) { | |
| 461 | + if (substr($sFilename, -10) == "smarty.inc") { | |
| 462 | + $aFiles[] = sprintf('%s/%s', $dir, $sFilename); | |
| 463 | + } | |
| 464 | + if (substr($sFilename, -10) == "smarty.php") { | |
| 465 | + $aFiles[] = sprintf('%s/%s', $dir, $sFilename); | |
| 466 | + } | |
| 467 | + } | |
| 468 | + foreach ($aFiles as $sFile) { | |
| 469 | + @unlink($sFile); | |
| 470 | + } | |
| 471 | + } | |
| 472 | + | |
| 473 | + | |
| 474 | + function _deleteProxyFiles() { | |
| 475 | + $oKTConfig =& KTConfig::getSingleton(); | |
| 476 | + | |
| 477 | + | |
| 478 | + // from ktentityutil::_proxyCreate | |
| 479 | + $sDirectory = $oKTConfig->get('cache/proxyCacheDirectory'); | |
| 480 | + | |
| 481 | + if (!file_exists($sDirectory)) { | |
| 482 | + return; | |
| 483 | + } | |
| 484 | + $sRunningUser = KTUtil::running_user(); | |
| 485 | + if ($sRunningUser) { | |
| 486 | + $sDirectory = sprintf("%s/%s", $sDirectory, $sRunningUser); | |
| 487 | + } | |
| 488 | + if (!file_exists($sDirectory)) { | |
| 489 | + return ; | |
| 490 | + } | |
| 491 | + | |
| 492 | + $dh = @opendir($sDirectory); | |
| 493 | + if (empty($dh)) { | |
| 494 | + return; | |
| 495 | + } | |
| 496 | + $aFiles = array(); | |
| 497 | + while (false !== ($sFilename = readdir($dh))) { | |
| 498 | + | |
| 499 | + if (substr($sFilename, -8) == ".inc.php") { | |
| 500 | + $aFiles[] = sprintf('%s/%s', $sDirectory, $sFilename); | |
| 501 | + } | |
| 502 | + } | |
| 503 | + | |
| 504 | + foreach ($aFiles as $sFile) { | |
| 505 | + @unlink($sFile); | |
| 506 | + } | |
| 507 | + } | |
| 508 | +} | |
| 509 | + | |
| 510 | +?> | ... | ... |
setup/upgrade/lib/datetime.inc
0 โ 100644
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * $Id$ | |
| 4 | + * | |
| 5 | + * Contains datetime functions. | |
| 6 | + * | |
| 7 | + * KnowledgeTree Community Edition | |
| 8 | + * Document Management Made Simple | |
| 9 | + * Copyright (C) 2008, 2009 KnowledgeTree Inc. | |
| 10 | + * Portions copyright The Jam Warehouse Software (Pty) Limited | |
| 11 | + * | |
| 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 | |
| 14 | + * Free Software Foundation. | |
| 15 | + * | |
| 16 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
| 17 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 18 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 19 | + * details. | |
| 20 | + * | |
| 21 | + * You should have received a copy of the GNU General Public License | |
| 22 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 23 | + * | |
| 24 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 25 | + * California 94120-7775, or email info@knowledgetree.com. | |
| 26 | + * | |
| 27 | + * The interactive user interfaces in modified source and object code versions | |
| 28 | + * of this program must display Appropriate Legal Notices, as required under | |
| 29 | + * Section 5 of the GNU General Public License version 3. | |
| 30 | + * | |
| 31 | + * In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 32 | + * these Appropriate Legal Notices must retain the display of the "Powered by | |
| 33 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 34 | + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 35 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 36 | + * copyright notice. | |
| 37 | + * Contributor( s): ______________________________________ | |
| 38 | + */ | |
| 39 | + | |
| 40 | +/** | |
| 41 | + * Returns the current date time | |
| 42 | + * | |
| 43 | + * @return string the current date time (Y-m-d H:i:s) | |
| 44 | + */ | |
| 45 | +function getCurrentDateTime() { | |
| 46 | + return date("Y-m-d H:i:s", time()); | |
| 47 | +} | |
| 48 | + | |
| 49 | +/** | |
| 50 | + * Returns the specified date time, formatted as Y-m-d H:i:s | |
| 51 | + * | |
| 52 | + * @param int the date time to format | |
| 53 | + * @return string the formatted date time | |
| 54 | + */ | |
| 55 | +function formatDateTime($dateTime) { | |
| 56 | + return date("Y-m-d H:i:s", $dateTime); | |
| 57 | +} | |
| 58 | +?> | ... | ... |
setup/upgrade/lib/sqlfile.inc.php
0 โ 100644
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * $Id$ | |
| 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 | + * Contributor( s): ______________________________________ | |
| 36 | + * | |
| 37 | + */ | |
| 38 | + | |
| 39 | +class SQLFile { | |
| 40 | + function sqlFromFile($path) { | |
| 41 | + return SQLFile::splitSQL(file_get_contents($path)); | |
| 42 | + } | |
| 43 | + | |
| 44 | + function splitSQL($sql) { | |
| 45 | + $instring = false; | |
| 46 | + $i = 0; | |
| 47 | + $remaining = $sql; | |
| 48 | + $query = ""; | |
| 49 | + $aQueries = array(); | |
| 50 | + | |
| 51 | + $strlen = strlen($sql); | |
| 52 | + | |
| 53 | + for ($i = 0; $i < $strlen; $i++) { | |
| 54 | + $c = $remaining[$i]; | |
| 55 | + if ($c === ";") { | |
| 56 | + $query .= substr($remaining, 0, $i + 1); | |
| 57 | + $aQueries[] = $query; | |
| 58 | + $query = ""; | |
| 59 | + $remaining = trim(substr($remaining, $i + 1)); | |
| 60 | + $i = 0; | |
| 61 | + $strlen = strlen($remaining); | |
| 62 | + continue; | |
| 63 | + } | |
| 64 | + if ($c === "`") { | |
| 65 | + $next = strpos($remaining, "`", $i); | |
| 66 | + if ($next === false) { | |
| 67 | + $query .= $remaining; | |
| 68 | + $aQueries[] = $query; | |
| 69 | + return $aQueries; | |
| 70 | + } | |
| 71 | + $query .= substr($remaining, 0, $next); | |
| 72 | + $remaining = substr($remaining, $next); | |
| 73 | + $i = 0; | |
| 74 | + $strlen = strlen($remaining); | |
| 75 | + continue; | |
| 76 | + } | |
| 77 | + if (($c === "'") || ($c === '"')) { | |
| 78 | + $stringchar = $c; | |
| 79 | + $notfound = true; | |
| 80 | + | |
| 81 | + while ($notfound) { | |
| 82 | + $next = strpos($remaining, $stringchar, $i + 1); | |
| 83 | + if ($next === false) { | |
| 84 | + $query .= $remaining; | |
| 85 | + $aQueries[] = $query; | |
| 86 | + return $aQueries; | |
| 87 | + } | |
| 88 | + $i = $next + 1; | |
| 89 | + $quotes = true; | |
| 90 | + $b = 1; | |
| 91 | + while ($remaining[$next - $b] === "\\") { | |
| 92 | + $quotes = !$quotes; | |
| 93 | + $b++; | |
| 94 | + } | |
| 95 | + if ($quotes) { | |
| 96 | + $notfound = false; | |
| 97 | + } | |
| 98 | + } | |
| 99 | + $query .= substr($remaining, 0, $next); | |
| 100 | + $remaining = substr($remaining, $next); | |
| 101 | + $i = 0; | |
| 102 | + $strlen = strlen($remaining); | |
| 103 | + continue; | |
| 104 | + } | |
| 105 | + | |
| 106 | + $nextdelim = SQLFile::_nextDelim($remaining); | |
| 107 | + if ($nextdelim === false) { | |
| 108 | + $query .= $remaining; | |
| 109 | + $aQueries[] = $query; | |
| 110 | + return $aQueries; | |
| 111 | + } | |
| 112 | + // $query .= substr($remaining, 0, $nextdelim); | |
| 113 | + } | |
| 114 | + return $aQueries; | |
| 115 | + } | |
| 116 | + | |
| 117 | + function _nextDelim($string) { | |
| 118 | + $q = strpos($string, "'"); | |
| 119 | + $d = strpos($string, '"'); | |
| 120 | + $b = strpos($string, "`"); | |
| 121 | + $s = strpos($string, ";"); | |
| 122 | + | |
| 123 | + $min = false; | |
| 124 | + foreach (array($q, $d, $b, $s) as $c) { | |
| 125 | + if ($min === false) { | |
| 126 | + $min = $c; | |
| 127 | + continue; | |
| 128 | + } | |
| 129 | + if ($c === false) { | |
| 130 | + continue; | |
| 131 | + } | |
| 132 | + if ($c < $min) { | |
| 133 | + $min = $c; | |
| 134 | + continue; | |
| 135 | + } | |
| 136 | + } | |
| 137 | + return $min; | |
| 138 | + } | |
| 139 | +} | |
| 140 | + | |
| 141 | +?> | ... | ... |
setup/upgrade/lib/upgrade.inc.php
0 โ 100644
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * $Id$ | |
| 4 | + * | |
| 5 | + * Assists in discovering what needs to be done to upgrade one version | |
| 6 | + * of KnowledgeTree to another. | |
| 7 | + * | |
| 8 | + * KnowledgeTree Community Edition | |
| 9 | + * Document Management Made Simple | |
| 10 | + * Copyright (C) 2008, 2009 KnowledgeTree Inc. | |
| 11 | + * Portions copyright The Jam Warehouse Software (Pty) Limited | |
| 12 | + * | |
| 13 | + * This program is free software; you can redistribute it and/or modify it under | |
| 14 | + * the terms of the GNU General Public License version 3 as published by the | |
| 15 | + * Free Software Foundation. | |
| 16 | + * | |
| 17 | + * This program is distributed in the hope that it will be useful, but WITHOUT | |
| 18 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 19 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 20 | + * details. | |
| 21 | + * | |
| 22 | + * You should have received a copy of the GNU General Public License | |
| 23 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 24 | + * | |
| 25 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 26 | + * California 94120-7775, or email info@knowledgetree.com. | |
| 27 | + * | |
| 28 | + * The interactive user interfaces in modified source and object code versions | |
| 29 | + * of this program must display Appropriate Legal Notices, as required under | |
| 30 | + * Section 5 of the GNU General Public License version 3. | |
| 31 | + * | |
| 32 | + * In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 33 | + * these Appropriate Legal Notices must retain the display of the "Powered by | |
| 34 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 35 | + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 36 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 37 | + * copyright notice. | |
| 38 | + * Contributor( s): ______________________________________ | |
| 39 | + */ | |
| 40 | + | |
| 41 | +require_once('UpgradeItems.inc.php'); | |
| 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(); | |
| 68 | + | |
| 69 | +// {{{ Format of the descriptor | |
| 70 | +/** | |
| 71 | + * Format of the descriptor | |
| 72 | + * | |
| 73 | + * type*version*phase*simple description for uniqueness | |
| 74 | + * | |
| 75 | + * type is: sql, function, subupgrade, upgrade | |
| 76 | + * version is: 1.2.4, 2.0.0rc5 | |
| 77 | + * phase is: 0, 1, 0pre. Phase is _only_ evaluated by describeUpgrades. | |
| 78 | + * description is: anything, unique in terms of version and type. | |
| 79 | + */ | |
| 80 | +// }}} | |
| 81 | + | |
| 82 | +// {{{ describeUpgrade | |
| 83 | +/** | |
| 84 | + * Describe the upgrade path between two versions of KnowledgeTree. | |
| 85 | + * | |
| 86 | + * @param string Original version (e.g., "1.2.4") | |
| 87 | + * @param string Current version (e.g., "2.0.2") | |
| 88 | + * | |
| 89 | + * @return array Array of UpgradeItem describing steps to be taken | |
| 90 | + */ | |
| 91 | +function &describeUpgrade ($origVersion, $currVersion) { | |
| 92 | + // How to figure out what upgrades to do: | |
| 93 | + // | |
| 94 | + // 1. Get all SQL upgrades >= origVersion and <= currVersion | |
| 95 | + // 2. Categorise each into version they upgrade to | |
| 96 | + // 3. Sort each version subgroup into correct order | |
| 97 | + // 5. Add "recordSubUpgrade" for each version there. | |
| 98 | + // 5. Add back into one big list again | |
| 99 | + // 6. Add "recordUpgrade" for whole thing | |
| 100 | + | |
| 101 | + // $recordUpgrade = array('upgrade*' . $currVersion, 'Upgrade to ' . $currVersion, null); | |
| 102 | + | |
| 103 | + $steps = array(); | |
| 104 | + foreach (array('SQLUpgradeItem') as $itemgen) { | |
| 105 | + $f = array($itemgen, 'getUpgrades'); | |
| 106 | + $ssteps = call_user_func($f, $origVersion, $currVersion); | |
| 107 | + $scount = count($ssteps); | |
| 108 | + for ($i = 0; $i < $scount; $i++) { | |
| 109 | + $steps[] =& $ssteps[$i]; | |
| 110 | + } | |
| 111 | + } | |
| 112 | + $upgradestep = new RecordUpgradeItem($currVersion, $origVersion); | |
| 113 | + $steps[] =& $upgradestep; | |
| 114 | + $stepcount = count($steps); | |
| 115 | + for ($i = 0; $i < $stepcount; $i++) { | |
| 116 | + $step =& $steps[$i]; | |
| 117 | + $step->setParent($upgradestep); | |
| 118 | + } | |
| 119 | + usort($steps, 'step_sort_func'); | |
| 120 | + | |
| 121 | + return $steps; | |
| 122 | +} | |
| 123 | +// }}} | |
| 124 | + | |
| 125 | +// {{{ step_sort_func | |
| 126 | +function step_sort_func ($obj1, $obj2) { | |
| 127 | + // Ugly hack to ensure that upgrade table is made first... | |
| 128 | + if ($obj1->name === "2.0.6/create_upgrade_table.sql") { | |
| 129 | + return -1; | |
| 130 | + } | |
| 131 | + if ($obj2->name === "2.0.6/create_upgrade_table.sql") { | |
| 132 | + return 1; | |
| 133 | + } | |
| 134 | + | |
| 135 | + // Priority upgrades run first | |
| 136 | + if ($obj1->getPriority() < $obj2->getPriority()) { | |
| 137 | + return 1; | |
| 138 | + } | |
| 139 | + if ($obj1->getPriority() > $obj2->getPriority()) { | |
| 140 | + return -1; | |
| 141 | + } | |
| 142 | + | |
| 143 | + // early version run first | |
| 144 | + $res = compare_version($obj1->getVersion(), $obj2->getVersion()); | |
| 145 | + if ($res !== 0) { | |
| 146 | + return $res; | |
| 147 | + } | |
| 148 | + // Order by phase | |
| 149 | + if ($obj1->getPhase() > $obj2->getPhase()) { | |
| 150 | + return 1; | |
| 151 | + } | |
| 152 | + if ($obj1->getPhase() < $obj2->getPhase()) { | |
| 153 | + return -1; | |
| 154 | + } | |
| 155 | + // Order by name | |
| 156 | + if ($obj1->name < $obj2->name) { | |
| 157 | + return -1; | |
| 158 | + } | |
| 159 | + if ($obj1->name > $obj2->name) { | |
| 160 | + return 1; | |
| 161 | + } | |
| 162 | + return 0; | |
| 163 | +} | |
| 164 | +// }}} | |
| 165 | + | |
| 166 | +// {{{ compare_version | |
| 167 | +/** | |
| 168 | + * Compares two version numbers and returns a value based on this comparison | |
| 169 | + * | |
| 170 | + * Using standard software version rules, such as 2.0.5rc1 comes before | |
| 171 | + * 2.0.5, and 2.0.5rc1 comes after 2.0.5alpha1, compare two version | |
| 172 | + * numbers, and determine which is the higher. | |
| 173 | + * | |
| 174 | + * XXX: Actually, just does $version1 < $version2 | |
| 175 | + * | |
| 176 | + * @param string First version number | |
| 177 | + * @param string Second version number | |
| 178 | + * | |
| 179 | + * @return int -1, 0, 1 | |
| 180 | + */ | |
| 181 | +function compare_version($version1, $version2) { | |
| 182 | + // XXX: Version comparisons should be better. | |
| 183 | + if ($version1 < $version2) { | |
| 184 | + return -1; | |
| 185 | + } | |
| 186 | + if ($version1 > $version2) { | |
| 187 | + return 1; | |
| 188 | + } | |
| 189 | + return 0; | |
| 190 | +} | |
| 191 | +// }}} | |
| 192 | + | |
| 193 | +// {{{ lte_version | |
| 194 | +/** | |
| 195 | + * Quick-hand for checking if a version number is lower-than-or-equal-to | |
| 196 | + */ | |
| 197 | +function lte_version($version1, $version2) { | |
| 198 | + if (in_array(compare_version($version1, $version2), array(-1, 0))) { | |
| 199 | + return true; | |
| 200 | + } | |
| 201 | + return false; | |
| 202 | +} | |
| 203 | +// }} | |
| 204 | + | |
| 205 | +// {{ gte_version | |
| 206 | +/** | |
| 207 | + * Quick-hand for checking if a version number is greater-than-or-equal-to | |
| 208 | + */ | |
| 209 | +function gte_version($version1, $version2) { | |
| 210 | + if (in_array(compare_version($version1, $version2), array(0, 1))) { | |
| 211 | + return true; | |
| 212 | + } | |
| 213 | + return false; | |
| 214 | +} | |
| 215 | +// }}} | |
| 216 | + | |
| 217 | +?> | ... | ... |
setup/upgrade/session.php
setup/upgrade/step.php
setup/upgrade/stepAction.php
| ... | ... | @@ -382,12 +382,12 @@ class stepAction { |
| 382 | 382 | $step_errors = $this->action->getErrors(); // Get errors |
| 383 | 383 | $step_warnings = $this->action->getWarnings(); // Get warnings |
| 384 | 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 | 386 | } else { |
| 387 | 387 | if($this->displayFirst()) { |
| 388 | - $template = "templates/{$this->stepName}_confirm.tpl"; | |
| 388 | + $template = "templates" . DS . "{$this->stepName}_confirm.tpl"; | |
| 389 | 389 | } else { |
| 390 | - $template = "templates/{$this->stepName}.tpl"; | |
| 390 | + $template = "templates" . DS . "{$this->stepName}.tpl"; | |
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | $step_tpl = new Template($template); |
| ... | ... | @@ -402,7 +402,7 @@ class stepAction { |
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | $content = $step_tpl->fetch(); |
| 405 | - $tpl = new Template("templates/wizard.tpl"); | |
| 405 | + $tpl = new Template("templates" . DS . "wizard.tpl"); | |
| 406 | 406 | $vars = $this->getVars(); // Get template variables |
| 407 | 407 | $tpl->set("vars", $vars); // Set template errors |
| 408 | 408 | $tpl->set('content', $content); | ... | ... |
setup/upgrade/steps/upgradeBackup.php
| ... | ... | @@ -40,9 +40,8 @@ |
| 40 | 40 | * @version Version 0.1 |
| 41 | 41 | */ |
| 42 | 42 | |
| 43 | -//require_once('../../config/dmsDefaults.php'); | |
| 44 | - | |
| 45 | 43 | class upgradeBackup extends Step { |
| 44 | + | |
| 46 | 45 | protected $silent = false; |
| 47 | 46 | protected $temp_variables = array(); |
| 48 | 47 | |
| ... | ... | @@ -83,13 +82,14 @@ class upgradeBackup extends Step { |
| 83 | 82 | return 'landing'; |
| 84 | 83 | } |
| 85 | 84 | |
| 86 | - private function backupNow() | |
| 87 | - { | |
| 85 | + private function backupNow() { | |
| 88 | 86 | return isset($_POST['BackupNow']); |
| 89 | 87 | } |
| 90 | 88 | |
| 91 | 89 | private function doRun($action = null) { |
| 90 | + $this->readConfig(); | |
| 92 | 91 | $this->temp_variables['action'] = $action; |
| 92 | + $this->temp_variables['backupStatus'] = false; | |
| 93 | 93 | |
| 94 | 94 | if (is_null($action) || ($action == 'confirm')) { |
| 95 | 95 | $this->temp_variables['title'] = 'Confirm Backup'; |
| ... | ... | @@ -101,18 +101,11 @@ class upgradeBackup extends Step { |
| 101 | 101 | // TODO error checking (done in backupDone at the moment) |
| 102 | 102 | $this->backupDone(); |
| 103 | 103 | } |
| 104 | - $this->storeSilent();// Set silent mode variables | |
| 104 | +// $this->storeSilent();// Set silent mode variables | |
| 105 | 105 | |
| 106 | 106 | return true; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - /** | |
| 110 | - * Set all silent mode varibles | |
| 111 | - * | |
| 112 | - */ | |
| 113 | - private function storeSilent() { | |
| 114 | - } | |
| 115 | - | |
| 116 | 109 | private function backup() { |
| 117 | 110 | $targetfile = $_SESSION['backupFile']; |
| 118 | 111 | $stmt = $this->create_backup_stmt($targetfile); |
| ... | ... | @@ -126,11 +119,11 @@ class upgradeBackup extends Step { |
| 126 | 119 | $handle = popen($stmt['cmd'], 'r'); |
| 127 | 120 | $read = fread($handle, 10240); |
| 128 | 121 | pclose($handle); |
| 129 | - $_SESSION['backupOutput']=$read; | |
| 122 | + $_SESSION['backupOutput'] = $read; | |
| 130 | 123 | $dir = $this->util->resolveTempDir(); |
| 131 | - $_SESSION['backupFile'] = $stmt['target']; | |
| 124 | + $_SESSION['backupFile'] = $stmt['target']; | |
| 132 | 125 | |
| 133 | - if (OS_UNIX) { | |
| 126 | + if (!WINDOWS_OS) { | |
| 134 | 127 | chmod($stmt['target'],0600); |
| 135 | 128 | } |
| 136 | 129 | |
| ... | ... | @@ -151,7 +144,7 @@ class upgradeBackup extends Step { |
| 151 | 144 | |
| 152 | 145 | if ($status) |
| 153 | 146 | { |
| 154 | - $stmt = $this->util->create_restore_stmt($filename); | |
| 147 | + $stmt = $this->util->create_restore_stmt($filename, $this->dbSettings); | |
| 155 | 148 | $this->temp_variables['display'] = 'The backup file <nobr><i>"' . $filename . '"</i></nobr> has been created. |
| 156 | 149 | <P> It appears as though the <font color=green>backup has been successful</font>. |
| 157 | 150 | <P>'; |
| ... | ... | @@ -193,56 +186,54 @@ class upgradeBackup extends Step { |
| 193 | 186 | } |
| 194 | 187 | |
| 195 | 188 | 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')); | |
| 189 | + { | |
| 190 | + $adminUser = $this->dbSettings['dbAdminUser']; | |
| 191 | + $adminPwd = $this->dbSettings['dbAdminPass']; | |
| 192 | + $dbHost = $this->dbSettings['dbHost']; | |
| 193 | + $dbName = $this->dbSettings['dbName']; | |
| 194 | + | |
| 195 | + $dbPort = trim($this->dbSettings['dbPort']); | |
| 205 | 196 | if (empty($dbPort) || $dbPort=='default') $dbPort = get_cfg_var('mysql.default_port'); |
| 206 | 197 | if (empty($dbPort)) $dbPort='3306'; |
| 207 | - $dbSocket = trim($oKTConfig->get('db/dbSocket')); | |
| 198 | + // dbSocket doesn't exist as far as I can find, where was it coming from? | |
| 199 | + //$dbSocket = trim($this->dbSettings['dbSocket']); | |
| 200 | + $dbSocket = ''; | |
| 208 | 201 | if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); |
| 209 | 202 | if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; |
| 210 | 203 | |
| 211 | 204 | $date=date('Y-m-d-H-i-s'); |
| 212 | 205 | |
| 213 | - $dir=$this->util->resolveMysqlDir(); | |
| 206 | + $dir = $this->util->resolveMysqlDir(); | |
| 214 | 207 | |
| 215 | - $info['dir']=$dir; | |
| 216 | - | |
| 217 | - $prefix=''; | |
| 218 | - if (OS_UNIX) | |
| 208 | + $info['dir'] = $dir; | |
| 209 | + $prefix = ''; | |
| 210 | + if (!WINDOWS_OS) | |
| 219 | 211 | { |
| 220 | 212 | $prefix .= "./"; |
| 221 | 213 | } |
| 222 | 214 | |
| 223 | 215 | if (@stat($dbSocket) !== false) |
| 224 | 216 | { |
| 225 | - $mechanism="--socket=\"$dbSocket\""; | |
| 217 | + $mechanism = "--socket=\"$dbSocket\""; | |
| 226 | 218 | } |
| 227 | 219 | else |
| 228 | 220 | { |
| 229 | - $mechanism="--port=\"$dbPort\""; | |
| 221 | + $mechanism = "--port=\"$dbPort\""; | |
| 230 | 222 | } |
| 231 | 223 | |
| 232 | - $tmpdir=$this->util->resolveTempDir(); | |
| 224 | + $tmpdir = $this->util->resolveTempDir(); | |
| 233 | 225 | |
| 234 | 226 | if (is_null($targetfile)) |
| 235 | 227 | { |
| 236 | - $targetfile="$tmpdir/kt-backup-$date.sql"; | |
| 228 | + $targetfile = "$tmpdir/kt-backup-$date.sql"; | |
| 237 | 229 | } |
| 238 | 230 | |
| 239 | 231 | $stmt = $prefix . "mysqldump --user=\"$adminUser\" -p $mechanism \"$dbName\" > \"$targetfile\""; |
| 240 | - $info['display']=$stmt; | |
| 241 | - $info['target']=$targetfile; | |
| 242 | - | |
| 232 | + $info['display'] = $stmt; | |
| 233 | + $info['target'] = $targetfile; | |
| 243 | 234 | |
| 244 | 235 | $stmt = $prefix. "mysqldump --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" > \"$targetfile\""; |
| 245 | - $info['cmd']=$stmt; | |
| 236 | + $info['cmd'] = $stmt; | |
| 246 | 237 | return $info; |
| 247 | 238 | } |
| 248 | 239 | |
| ... | ... | @@ -255,5 +246,43 @@ class upgradeBackup extends Step { |
| 255 | 246 | $this->temp_variables['dir'] = $dir; |
| 256 | 247 | $this->temp_variables['display'] = $stmt['display']; |
| 257 | 248 | } |
| 249 | + | |
| 250 | + // TODO this function needs to be refactored out into the parent Step class?? | |
| 251 | + private function readConfig() { | |
| 252 | + require_once("../wizard/steps/configuration.php"); // configuration to read the ini path | |
| 253 | + $wizConfigHandler = new configuration(); | |
| 254 | + $path = $wizConfigHandler->readConfigPathIni(); | |
| 255 | + $this->util->iniUtilities->load($path); | |
| 256 | + $dbSettings = $this->util->iniUtilities->getSection('db'); | |
| 257 | + | |
| 258 | + $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'], | |
| 259 | + 'dbName'=> $dbSettings['dbName'], | |
| 260 | + 'dbUser'=> $dbSettings['dbUser'], | |
| 261 | + 'dbPass'=> $dbSettings['dbPass'], | |
| 262 | + 'dbPort'=> $dbSettings['dbPort'], | |
| 263 | + // dbSocket doesn't exist as far as I can find, where was it coming from? | |
| 264 | + //'dbSocket'=> $dbSettings['dbSocket'], | |
| 265 | + 'dbAdminUser'=> $dbSettings['dbAdminUser'], | |
| 266 | + 'dbAdminPass'=> $dbSettings['dbAdminPass'], | |
| 267 | + ); | |
| 268 | + $this->paths = $this->util->iniUtilities->getSection('urls'); | |
| 269 | + $this->paths = array_merge($this->paths, $this->util->iniUtilities->getSection('cache')); | |
| 270 | + $this->temp_variables['dbSettings'] = $this->dbSettings; | |
| 271 | + $this->sysVersion = $this->readVersion(); | |
| 272 | + $this->cachePath = $wizConfigHandler->readCachePath(); | |
| 273 | + } | |
| 274 | + | |
| 275 | + // TODO this function needs to be refactored out into the parent Step class | |
| 276 | + public function readVersion() { | |
| 277 | + $verFile = SYSTEM_DIR."docs".DS."VERSION.txt"; | |
| 278 | + if(file_exists($verFile)) { | |
| 279 | + $foundVersion = file_get_contents($verFile); | |
| 280 | + return $foundVersion; | |
| 281 | + } else { | |
| 282 | + $this->error[] = "KT installation version not found"; | |
| 283 | + } | |
| 284 | + | |
| 285 | + return false; | |
| 286 | + } | |
| 258 | 287 | } |
| 259 | 288 | ?> |
| 260 | 289 | \ No newline at end of file | ... | ... |
setup/upgrade/steps/upgradeComplete.php
| ... | ... | @@ -40,8 +40,6 @@ |
| 40 | 40 | * @version Version 0.1 |
| 41 | 41 | */ |
| 42 | 42 | |
| 43 | -//require_once('../../config/dmsDefaults.php'); | |
| 44 | - | |
| 45 | 43 | class upgradeComplete extends Step { |
| 46 | 44 | |
| 47 | 45 | protected $silent = false; |
| ... | ... | @@ -50,6 +48,7 @@ class upgradeComplete extends Step { |
| 50 | 48 | |
| 51 | 49 | public function doStep() { |
| 52 | 50 | $this->temp_variables = array("step_name"=>"complete", "silent"=>$this->silent); |
| 51 | + | |
| 53 | 52 | $this->doRun(); |
| 54 | 53 | return 'landing'; |
| 55 | 54 | } |
| ... | ... | @@ -63,6 +62,8 @@ class upgradeComplete extends Step { |
| 63 | 62 | * |
| 64 | 63 | */ |
| 65 | 64 | private 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,10 +40,9 @@ |
| 40 | 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 | -//require_once(KT_LIB_DIR . '/upgrades/upgrade.inc.php'); | |
| 43 | +define('KT_DIR', SYSTEM_DIR); | |
| 44 | +define('KT_LIB_DIR', SYSTEM_DIR.'lib'); | |
| 45 | +require_once(WIZARD_LIB . 'upgrade.inc.php'); | |
| 47 | 46 | |
| 48 | 47 | class upgradeDatabase extends Step |
| 49 | 48 | { |
| ... | ... | @@ -92,10 +91,12 @@ class upgradeDatabase extends Step |
| 92 | 91 | */ |
| 93 | 92 | public $storeInSession = true; |
| 94 | 93 | |
| 94 | + public $sysVersion = ''; | |
| 95 | 95 | protected $silent = false; |
| 96 | 96 | protected $temp_variables = array(); |
| 97 | - | |
| 98 | - /** | |
| 97 | + public $paths = ''; | |
| 98 | + | |
| 99 | + /** | |
| 99 | 100 | * Main control of database setup |
| 100 | 101 | * |
| 101 | 102 | * @author KnowledgeTree Team |
| ... | ... | @@ -141,16 +142,8 @@ class upgradeDatabase extends Step |
| 141 | 142 | } |
| 142 | 143 | |
| 143 | 144 | private function doRun($action = null) { |
| 144 | - $this->readConfig(KTConfig::getConfigFilename()); | |
| 145 | - | |
| 146 | - if($this->dbSettings['dbPort'] == '') { | |
| 147 | - $con = $this->dbhandler->load($this->dbSettings['dbHost'], $this->dbSettings['dbUser'], | |
| 148 | - $this->dbSettings['dbPass'], $this->dbSettings['dbName']); | |
| 149 | - } else { | |
| 150 | - $con = $this->dbhandler->load($this->dbSettings['dbHost'].":".$this->dbSettings['dbPort'], $this->dbSettings['dbUser'], | |
| 151 | - $this->dbSettings['dbPass'], $this->dbSettings['dbName']); | |
| 152 | - } | |
| 153 | - | |
| 145 | + $this->readConfig(); | |
| 146 | + $con = $this->util->dbUtilities->load($this->dbSettings['dbHost'], $this->dbSettings['dbPort'], $this->dbSettings['dbUser'],$this->dbSettings['dbPass'], $this->dbSettings['dbName']); | |
| 154 | 147 | $this->temp_variables['action'] = $action; |
| 155 | 148 | if (is_null($action) || ($action == 'preview')) { |
| 156 | 149 | $this->temp_variables['title'] = 'Preview Upgrade'; |
| ... | ... | @@ -173,20 +166,20 @@ class upgradeDatabase extends Step |
| 173 | 166 | } |
| 174 | 167 | |
| 175 | 168 | private function generateUpgradeTable() { |
| 176 | - global $default; | |
| 169 | + $this->sysVersion = $this->readVersion(); | |
| 170 | + $this->temp_variables['systemVersion'] = $this->sysVersion; | |
| 171 | + $dconf = $this->util->iniUtilities->getSection('db'); | |
| 172 | + $this->util->dbUtilities->load($dconf['dbHost'], '', $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']); | |
| 177 | 173 | |
| 178 | - $this->temp_variables['systemVersion'] = $default->systemVersion; | |
| 179 | - $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table); | |
| 180 | - | |
| 181 | - $result = $this->dbhandler->query($query); | |
| 174 | + $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', 'system_settings'); | |
| 175 | + $result = $this->util->dbUtilities->query($query); | |
| 176 | + $assArr = $this->util->dbUtilities->fetchAssoc($result); | |
| 182 | 177 | if ($result) { |
| 183 | - $lastVersionObj = $this->dbhandler->fetchNextObject($result); | |
| 184 | - $lastVersion = $lastVersionObj->value; | |
| 178 | + $lastVersion = $assArr[0]['value']; | |
| 185 | 179 | } |
| 186 | - $currentVersion = $default->systemVersion; | |
| 187 | - | |
| 180 | + $currentVersion = $this->sysVersion; | |
| 181 | + | |
| 188 | 182 | $upgrades = describeUpgrade($lastVersion, $currentVersion); |
| 189 | - | |
| 190 | 183 | $ret = "<table border=1 cellpadding=1 cellspacing=1 width='100%'>\n"; |
| 191 | 184 | $ret .= "<tr bgcolor='darkgrey'><th width='10'>Code</th><th width='100%'>Description</th><th width='30'>Applied</th></tr>\n"; |
| 192 | 185 | $i=0; |
| ... | ... | @@ -202,6 +195,18 @@ class upgradeDatabase extends Step |
| 202 | 195 | return $ret; |
| 203 | 196 | } |
| 204 | 197 | |
| 198 | + public function readVersion() { | |
| 199 | + $verFile = SYSTEM_DIR."docs".DS."VERSION.txt"; | |
| 200 | + if(file_exists($verFile)) { | |
| 201 | + $foundVersion = file_get_contents($verFile); | |
| 202 | + return $foundVersion; | |
| 203 | + } else { | |
| 204 | + $this->error[] = "KT installation version not found"; | |
| 205 | + } | |
| 206 | + | |
| 207 | + return false; | |
| 208 | + } | |
| 209 | + | |
| 205 | 210 | /** |
| 206 | 211 | * Stores varibles used by template |
| 207 | 212 | * |
| ... | ... | @@ -241,18 +246,34 @@ class upgradeDatabase extends Step |
| 241 | 246 | } |
| 242 | 247 | } |
| 243 | 248 | |
| 244 | - private function readConfig($path) { | |
| 245 | - $ini = $this->util->loadInstallIni($path); | |
| 246 | - $dbSettings = $ini->getSection('db'); | |
| 247 | - $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'], | |
| 249 | + private function readConfig() { | |
| 250 | + require_once("../wizard/steps/configuration.php"); // configuration to read the ini path | |
| 251 | + $wizConfigHandler = new configuration(); | |
| 252 | + $path = $wizConfigHandler->readConfigPathIni(); | |
| 253 | + $this->util->iniUtilities->load($path); | |
| 254 | + $dbSettings = $this->util->iniUtilities->getSection('db'); | |
| 255 | + $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'], | |
| 248 | 256 | 'dbName'=> $dbSettings['dbName'], |
| 249 | 257 | 'dbUser'=> $dbSettings['dbUser'], |
| 250 | 258 | 'dbPass'=> $dbSettings['dbPass'], |
| 251 | 259 | 'dbPort'=> $dbSettings['dbPort'], |
| 252 | 260 | 'dbAdminUser'=> $dbSettings['dbAdminUser'], |
| 253 | 261 | 'dbAdminPass'=> $dbSettings['dbAdminPass'], |
| 254 | - ); | |
| 255 | - $this->temp_variables['dbSettings'] = $this->dbSettings; | |
| 262 | + ); | |
| 263 | + $this->paths = $this->util->iniUtilities->getSection('urls'); | |
| 264 | + $this->paths = array_merge($this->paths, $this->util->iniUtilities->getSection('cache')); | |
| 265 | + $this->sysVersion = $this->readVersion(); | |
| 266 | + $this->cachePath = $wizConfigHandler->readCachePath(); | |
| 267 | + $this->proxyPath = $this->cachePath."/.."; // Total guess. | |
| 268 | + $this->proxyPath = realpath($this->proxyPath."/proxies"); | |
| 269 | + $this->storeSilent(); | |
| 270 | + } | |
| 271 | + | |
| 272 | + public function storeSilent() { | |
| 273 | + $this->temp_variables['paths'] = $this->paths; | |
| 274 | + $this->temp_variables['sysVersion'] = $this->sysVersion; | |
| 275 | + $this->temp_variables['sysVersion'] = $this->sysVersion; | |
| 276 | + $this->temp_variables['dbSettings'] = $this->dbSettings; | |
| 256 | 277 | } |
| 257 | 278 | |
| 258 | 279 | private function upgradeConfirm() |
| ... | ... | @@ -267,26 +288,17 @@ class upgradeDatabase extends Step |
| 267 | 288 | |
| 268 | 289 | private function doDatabaseUpgrade() |
| 269 | 290 | { |
| 270 | - global $default; | |
| 271 | - | |
| 272 | 291 | $errors = false; |
| 273 | 292 | |
| 274 | 293 | $this->temp_variables['detail'] = '<p>The table below describes the upgrades that have occurred to |
| 275 | - upgrade your KnowledgeTree installation to <strong>' . $default->systemVersion . '</strong>'; | |
| 294 | + upgrade your KnowledgeTree installation to <strong>' . $this->sysVersion . '</strong>'; | |
| 276 | 295 | |
| 277 | 296 | $pre_res = $this->performPreUpgradeActions(); |
| 278 | - if (PEAR::isError($pre_res)) { | |
| 279 | - $errors = true; | |
| 280 | - $this->temp_variables['preUpgrade'] = '<font color="red">Pre-Upgrade actions failed.</font>'; | |
| 281 | - } | |
| 282 | - else { | |
| 283 | - $this->temp_variables['preUpgrade'] = '<font color="green">Pre-Upgrade actions succeeded.</font>'; | |
| 284 | - | |
| 285 | - } | |
| 286 | 297 | |
| 287 | 298 | $res = $this->performAllUpgrades(); |
| 288 | - if (PEAR::isError($res) || PEAR::isError($pres)) { | |
| 299 | + if (!$res) { | |
| 289 | 300 | $errors = true; |
| 301 | + $this->error[] = 'An Error has occured'; | |
| 290 | 302 | // TODO instantiate error details hideable section? |
| 291 | 303 | $this->temp_variables['upgradeStatus'] = '<font color="red">Database upgrade failed</font> |
| 292 | 304 | <br/><br/> |
| ... | ... | @@ -300,13 +312,7 @@ class upgradeDatabase extends Step |
| 300 | 312 | } |
| 301 | 313 | |
| 302 | 314 | $post_pres = $this->performPostUpgradeActions(); |
| 303 | - if (PEAR::isError($post_res)) { | |
| 304 | - $errors = true; | |
| 305 | - $this->temp_variables['postUpgrade'] = '<font color="red">Post-Upgrade actions failed.</font>'; | |
| 306 | - } | |
| 307 | - else { | |
| 308 | - $this->temp_variables['postUpgrade'] = '<font color="green">Post-Upgrade actions succeeded.</font>'; | |
| 309 | - } | |
| 315 | + | |
| 310 | 316 | |
| 311 | 317 | return !$errors; |
| 312 | 318 | } |
| ... | ... | @@ -315,40 +321,63 @@ class upgradeDatabase extends Step |
| 315 | 321 | |
| 316 | 322 | // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works. |
| 317 | 323 | // It should idealy work the same as the upgrades. |
| 318 | - | |
| 319 | - global $default; | |
| 320 | - | |
| 321 | 324 | // Lock the scheduler |
| 322 | - $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock'; | |
| 323 | - touch($lockFile); | |
| 325 | + $lockFile = $this->cachePath . DIRECTORY_SEPARATOR . 'scheduler.lock'; | |
| 326 | + @touch($lockFile); | |
| 324 | 327 | return true; |
| 325 | 328 | |
| 326 | 329 | } |
| 327 | 330 | |
| 331 | + private function deleteDirectory($sPath) { | |
| 332 | + if (!WINDOWS_OS) { | |
| 333 | + if (file_exists('/bin/rm')) { | |
| 334 | + $this->util->pexec(array('/bin/rm', '-rf', $sPath)); | |
| 335 | + return; | |
| 336 | + } | |
| 337 | + } | |
| 338 | + if (WINDOWS_OS) { | |
| 339 | + // Potentially kills off all the files in the path, speeding | |
| 340 | + // things up a bit | |
| 341 | + exec("del /q /s " . escapeshellarg($sPath)); | |
| 342 | + } | |
| 343 | + $hPath = @opendir($sPath); | |
| 344 | + while (($sFilename = readdir($hPath)) !== false) { | |
| 345 | + if (in_array($sFilename, array('.', '..'))) { | |
| 346 | + continue; | |
| 347 | + } | |
| 348 | + $sFullFilename = sprintf("%s/%s", $sPath, $sFilename); | |
| 349 | + if (is_dir($sFullFilename)) { | |
| 350 | + $this->deleteDirectory($sFullFilename); | |
| 351 | + continue; | |
| 352 | + } | |
| 353 | + @chmod($sFullFilename, 0666); | |
| 354 | + @unlink($sFullFilename); | |
| 355 | + } | |
| 356 | + closedir($hPath); | |
| 357 | + @rmdir($sPath); | |
| 358 | + } | |
| 359 | + | |
| 328 | 360 | private function performPostUpgradeActions() { |
| 329 | 361 | |
| 330 | 362 | // This is just to test and needs to be updated to a more sane and error resistent architrcture if it works. |
| 331 | 363 | // It should idealy work the same as the upgrades. |
| 332 | 364 | |
| 333 | - global $default; | |
| 334 | - | |
| 335 | 365 | // Ensure all plugins are re-registered. |
| 336 | 366 | $sql = "TRUNCATE plugin_helper"; |
| 337 | - $res = DBUtil::runQuery($sql); | |
| 338 | - | |
| 367 | + //$res = DBUtil::runQuery($sql); | |
| 368 | + $res = $this->util->dbUtilities->query($sql); | |
| 369 | + | |
| 339 | 370 | // Clear out all caches and proxies - they need to be regenerated with the new code |
| 340 | - $proxyDir = $default->proxyCacheDirectory; | |
| 341 | - KTUtil::deleteDirectory($proxyDir); | |
| 342 | - | |
| 343 | - $oKTCache = new KTCache(); | |
| 344 | - $oKTCache->deleteAllCaches(); | |
| 345 | - | |
| 371 | + $this->deleteDirectory($this->proxyPath); | |
| 372 | +// $oKTCache = new KTCache(); | |
| 373 | +// $oKTCache->deleteAllCaches(); | |
| 374 | + $this->deleteDirectory($this->cachePath); | |
| 346 | 375 | // Clear the configuration cache, it'll regenerate on next load |
| 347 | - $oKTConfig = new KTConfig(); | |
| 348 | - $oKTConfig->clearCache(); | |
| 376 | +// $oKTConfig = new KTConfig(); | |
| 377 | +// $oKTConfig->clearCache(); | |
| 349 | 378 | |
| 350 | 379 | // Unlock the scheduler |
| 351 | - $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock'; | |
| 380 | + $lockFile = $this->cachePath . DIRECTORY_SEPARATOR . 'scheduler.lock'; | |
| 352 | 381 | if(file_exists($lockFile)){ |
| 353 | 382 | @unlink($lockFile); |
| 354 | 383 | } |
| ... | ... | @@ -358,18 +387,15 @@ class upgradeDatabase extends Step |
| 358 | 387 | } |
| 359 | 388 | |
| 360 | 389 | private function performAllUpgrades () { |
| 361 | - global $default; | |
| 362 | - | |
| 363 | 390 | $row = 1; |
| 364 | - | |
| 365 | - $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table); | |
| 366 | - $lastVersion = DBUtil::getOneResultKey($query, 'value'); | |
| 367 | - $currentVersion = $default->systemVersion; | |
| 368 | - | |
| 391 | + $table = 'system_settings'; | |
| 392 | + $query = "SELECT value FROM $table WHERE name = 'databaseVersion'"; | |
| 393 | + $result = $this->util->dbUtilities->query($query); | |
| 394 | + $assArr = $this->util->dbUtilities->fetchAssoc($result); | |
| 395 | + $lastVersion = $assArr[0]['value']; | |
| 396 | + $currentVersion = $this->sysVersion; | |
| 369 | 397 | $upgrades = describeUpgrade($lastVersion, $currentVersion); |
| 370 | - | |
| 371 | 398 | $this->temp_variables['upgradeTable'] = ''; |
| 372 | - | |
| 373 | 399 | foreach ($upgrades as $upgrade) { |
| 374 | 400 | if (($row % 2) == 1) { |
| 375 | 401 | $class = "odd"; |
| ... | ... | @@ -383,15 +409,17 @@ class upgradeDatabase extends Step |
| 383 | 409 | $this->temp_variables['upgradeTable'] .= sprintf('<div class="bar">%s</div>', $this->showResult($res)); |
| 384 | 410 | $this->temp_variables['upgradeTable'] .= '<br>' . "\n"; |
| 385 | 411 | $this->temp_variables['upgradeTable'] .= "</div>\n"; |
| 386 | - if (PEAR::isError($res)) { | |
| 387 | - if (!is_a($res, 'Upgrade_Already_Applied')) { | |
| 388 | - break; | |
| 389 | - } else { | |
| 390 | - $res = true; | |
| 391 | - } | |
| 392 | - } | |
| 412 | +// if (!$res) { | |
| 413 | +// if (!is_a($res, 'Upgrade_Already_Applied')) { | |
| 414 | +// $res = false; | |
| 415 | +// } else { | |
| 416 | +// $res = true; | |
| 417 | +// } | |
| 418 | +// } | |
| 393 | 419 | if ($res === false) { |
| 394 | - $res = PEAR::raiseError("Upgrade returned false"); | |
| 420 | + die; | |
| 421 | + $this->error = $this->util->dbUtilities->getErrors(); | |
| 422 | +// print_r($this->error); | |
| 395 | 423 | break; |
| 396 | 424 | } |
| 397 | 425 | } |
| ... | ... | @@ -400,11 +428,11 @@ class upgradeDatabase extends Step |
| 400 | 428 | } |
| 401 | 429 | |
| 402 | 430 | private function showResult($res) { |
| 403 | - if (PEAR::isError($res)) { | |
| 431 | + if ($res) { | |
| 404 | 432 | if (is_a($res, 'Upgrade_Already_Applied')) { |
| 405 | 433 | return '<span style="color: orange">Already applied</span>'; |
| 406 | 434 | } |
| 407 | - return sprintf('<span style="color: red">%s</span>', htmlspecialchars($res->toString())); | |
| 435 | +// return sprintf('<span style="color: red">%s</span>', htmlspecialchars($res)); | |
| 408 | 436 | } |
| 409 | 437 | if ($res === true) { |
| 410 | 438 | return '<span style="color: green">Success</span>'; |
| ... | ... | @@ -414,6 +442,5 @@ class upgradeDatabase extends Step |
| 414 | 442 | } |
| 415 | 443 | return $res; |
| 416 | 444 | } |
| 417 | - | |
| 418 | 445 | } |
| 419 | 446 | ?> |
| 420 | 447 | \ No newline at end of file | ... | ... |
setup/upgrade/steps/upgradeRestore.php
| ... | ... | @@ -40,18 +40,18 @@ |
| 40 | 40 | * @version Version 0.1 |
| 41 | 41 | */ |
| 42 | 42 | |
| 43 | -//require_once('../../config/dmsDefaults.php'); | |
| 44 | - | |
| 45 | 43 | class upgradeRestore extends Step { |
| 46 | 44 | |
| 47 | 45 | |
| 48 | 46 | protected $silent = false; |
| 49 | 47 | protected $temp_variables = array(); |
| 50 | 48 | |
| 51 | - public function doStep() { | |
| 49 | + public function doStep() { | |
| 52 | 50 | $this->temp_variables = array("step_name"=>"restore", "silent"=>$this->silent, |
| 53 | 51 | "loadingText"=>"The database restore is under way. Please wait until it completes"); |
| 54 | 52 | $this->temp_variables['restore'] = false; |
| 53 | + $this->temp_variables['display'] = ''; | |
| 54 | + $this->temp_variables['dir'] = ''; | |
| 55 | 55 | |
| 56 | 56 | if(!$this->inStep("restore")) { |
| 57 | 57 | $this->doRun(); |
| ... | ... | @@ -79,6 +79,8 @@ class upgradeRestore extends Step { |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | private function doRun($restore = false) { |
| 82 | + $this->readConfig(); | |
| 83 | + | |
| 82 | 84 | if (!$restore) { |
| 83 | 85 | $this->temp_variables['selected'] = false; |
| 84 | 86 | if ($this->select()) { |
| ... | ... | @@ -92,7 +94,7 @@ class upgradeRestore extends Step { |
| 92 | 94 | $this->restoreDatabase(); |
| 93 | 95 | } |
| 94 | 96 | |
| 95 | - $this->storeSilent();// Set silent mode variables | |
| 97 | +// $this->storeSilent();// Set silent mode variables | |
| 96 | 98 | |
| 97 | 99 | return true; |
| 98 | 100 | } |
| ... | ... | @@ -101,19 +103,12 @@ class upgradeRestore extends Step { |
| 101 | 103 | return isset($_POST['RestoreSelect']); |
| 102 | 104 | } |
| 103 | 105 | |
| 104 | - /** | |
| 105 | - * Set all silent mode varibles | |
| 106 | - * | |
| 107 | - */ | |
| 108 | - private function storeSilent() { | |
| 109 | - } | |
| 110 | - | |
| 111 | 106 | private function restoreDatabase() |
| 112 | 107 | { |
| 113 | 108 | $this->temp_variables['restore'] = true; |
| 114 | 109 | $status = $_SESSION['backupStatus']; |
| 115 | 110 | $filename = $_SESSION['backupFile']; |
| 116 | - $stmt = $this->util->create_restore_stmt($filename); | |
| 111 | + $stmt = $this->util->create_restore_stmt($filename, $this->dbSettings); | |
| 117 | 112 | $dir = $stmt['dir']; |
| 118 | 113 | |
| 119 | 114 | if (is_file($dir . '/mysql') || is_file($dir . '/mysql.exe')) |
| ... | ... | @@ -219,7 +214,7 @@ class upgradeRestore extends Step { |
| 219 | 214 | |
| 220 | 215 | $status = $_SESSION['backupStatus']; |
| 221 | 216 | $filename = $_SESSION['backupFile']; |
| 222 | - $stmt = $this->util->create_restore_stmt($filename); | |
| 217 | + $stmt = $this->util->create_restore_stmt($filename, $this->dbSettings); | |
| 223 | 218 | |
| 224 | 219 | $this->temp_variables['title'] = 'Confirm Restore'; |
| 225 | 220 | $this->temp_variables['dir'] = $stmt['dir']; |
| ... | ... | @@ -227,6 +222,44 @@ class upgradeRestore extends Step { |
| 227 | 222 | $this->temp_variables['availableBackups'] = true; |
| 228 | 223 | $this->temp_variables['selected'] = true; |
| 229 | 224 | } |
| 225 | + | |
| 226 | + // TODO this function needs to be refactored out into the parent Step class?? | |
| 227 | + private function readConfig() { | |
| 228 | + require_once("../wizard/steps/configuration.php"); // configuration to read the ini path | |
| 229 | + $wizConfigHandler = new configuration(); | |
| 230 | + $path = $wizConfigHandler->readConfigPathIni(); | |
| 231 | + $this->util->iniUtilities->load($path); | |
| 232 | + $dbSettings = $this->util->iniUtilities->getSection('db'); | |
| 233 | + | |
| 234 | + $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'], | |
| 235 | + 'dbName'=> $dbSettings['dbName'], | |
| 236 | + 'dbUser'=> $dbSettings['dbUser'], | |
| 237 | + 'dbPass'=> $dbSettings['dbPass'], | |
| 238 | + 'dbPort'=> $dbSettings['dbPort'], | |
| 239 | + // dbSocket doesn't exist as far as I can find, where was it coming from? | |
| 240 | + //'dbSocket'=> $dbSettings['dbSocket'], | |
| 241 | + 'dbAdminUser'=> $dbSettings['dbAdminUser'], | |
| 242 | + 'dbAdminPass'=> $dbSettings['dbAdminPass'], | |
| 243 | + ); | |
| 244 | + $this->paths = $this->util->iniUtilities->getSection('urls'); | |
| 245 | + $this->paths = array_merge($this->paths, $this->util->iniUtilities->getSection('cache')); | |
| 246 | + $this->temp_variables['dbSettings'] = $this->dbSettings; | |
| 247 | + $this->sysVersion = $this->readVersion(); | |
| 248 | + $this->cachePath = $wizConfigHandler->readCachePath(); | |
| 249 | + } | |
| 250 | + | |
| 251 | + // TODO this function needs to be refactored out into the parent Step class | |
| 252 | + public function readVersion() { | |
| 253 | + $verFile = SYSTEM_DIR."docs".DS."VERSION.txt"; | |
| 254 | + if(file_exists($verFile)) { | |
| 255 | + $foundVersion = file_get_contents($verFile); | |
| 256 | + return $foundVersion; | |
| 257 | + } else { | |
| 258 | + $this->error[] = "KT installation version not found"; | |
| 259 | + } | |
| 260 | + | |
| 261 | + return false; | |
| 262 | + } | |
| 230 | 263 | |
| 231 | 264 | } |
| 232 | 265 | ?> |
| 233 | 266 | \ No newline at end of file | ... | ... |
setup/upgrade/steps/upgradeWelcome.php
| ... | ... | @@ -42,10 +42,11 @@ |
| 42 | 42 | |
| 43 | 43 | class upgradeWelcome extends step { |
| 44 | 44 | |
| 45 | - protected $silent = false; | |
| 45 | + protected $silent = true; | |
| 46 | 46 | protected $temp_variables = array(); |
| 47 | 47 | protected $error = array() ; |
| 48 | - | |
| 48 | + protected $storeInSession = true; | |
| 49 | + | |
| 49 | 50 | public function doStep() { |
| 50 | 51 | $this->temp_variables = array("step_name"=>"welcome"); |
| 51 | 52 | if($this->next()) { |
| ... | ... | @@ -81,32 +82,46 @@ class upgradeWelcome extends step { |
| 81 | 82 | private function checkPassword($username, $password) { |
| 82 | 83 | $dconf = $this->getDataFromPackage('installers', 'database'); // Use info from install |
| 83 | 84 | if($dconf) { |
| 84 | - $this->dbhandler->load($dconf['dhost'], $dconf['duname'], $dconf['dpassword'], $dconf['dname']); | |
| 85 | + $this->util->dbUtilities->load($dconf['dhost'], $dbconf['dport'], $dconf['duname'], $dconf['dpassword'], $dconf['dname']); | |
| 85 | 86 | } else { |
| 86 | - require_once("../wizard/iniUtilities.php"); // ini to read the ini content | |
| 87 | 87 | require_once("../wizard/steps/configuration.php"); // configuration to read the ini path |
| 88 | 88 | $wizConfigHandler = new configuration(); |
| 89 | 89 | $configPath = $wizConfigHandler->readConfigPathIni(); |
| 90 | - $ini = new iniUtilities($configPath); | |
| 91 | - $dconf = $ini->getSection('db'); | |
| 92 | - $this->dbhandler->load($dconf['dbHost'], $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']); | |
| 90 | + $this->util->iniUtilities->load($configPath); | |
| 91 | + $dconf = $this->util->iniUtilities->getSection('db'); | |
| 92 | + $this->util->dbUtilities->load($dconf['dbHost'],$dconf['dbPort'], $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']); | |
| 93 | + $sQuery = "SELECT count(*) AS match_count FROM users WHERE username = '$username' AND password = '".md5($password)."'"; | |
| 94 | + $res = $this->util->dbUtilities->query($sQuery); | |
| 95 | + $ass = $this->util->dbUtilities->fetchAssoc($res); | |
| 96 | + if($ass[0]['match_count'] == 1) | |
| 97 | + return true; | |
| 93 | 98 | } |
| 94 | - $sQuery = "SELECT count(*) AS match_count FROM users WHERE username = '$username' AND password = '".md5($password)."'"; | |
| 95 | - $res = $this->dbhandler->query($sQuery); | |
| 96 | - $ass = $this->dbhandler->fetchAssoc($res); | |
| 97 | - if(isset($ass[0]['match_count'])) { | |
| 98 | - if($ass[0]['match_count']) | |
| 99 | - return true; | |
| 100 | - } | |
| 99 | + | |
| 101 | 100 | $this->error[] = 'Could Not Authenticate User'; |
| 102 | 101 | return false; |
| 103 | - } | |
| 104 | 102 | |
| 103 | + } | |
| 104 | + | |
| 105 | 105 | public function getErrors() { |
| 106 | 106 | return $this->error; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | + /** | |
| 110 | + * Returns step variables | |
| 111 | + * | |
| 112 | + * @author KnowledgeTree Team | |
| 113 | + * @param none | |
| 114 | + * @access public | |
| 115 | + * @return array | |
| 116 | + */ | |
| 117 | + public function getStepVars() | |
| 118 | + { | |
| 119 | + return $this->temp_variables; | |
| 120 | + } | |
| 109 | 121 | |
| 122 | + public function storeSilent() { | |
| 123 | + | |
| 124 | + } | |
| 110 | 125 | } |
| 111 | 126 | |
| 112 | 127 | ?> |
| 113 | 128 | \ No newline at end of file | ... | ... |
setup/upgrade/templates/backup.tpl
| ... | ... | @@ -46,7 +46,7 @@ You can continue to do the backup manually using the following process: |
| 46 | 46 | <P> |
| 47 | 47 | </div> |
| 48 | 48 | </div> |
| 49 | - <?php include 'templates/loading.tpl'; ?> | |
| 49 | + <?php include WIZARD_DIR . 'templates/loading.tpl'; ?> | |
| 50 | 50 | <div id="buttonBar"> |
| 51 | 51 | <input type="submit" name="Previous" value="Previous" class="button_previous"> |
| 52 | 52 | <?php | ... | ... |
setup/upgrade/templates/complete.tpl
| 1 | -<?php global $default; ?> | |
| 1 | +<?php //global $default; ?> | |
| 2 | 2 | <form> |
| 3 | 3 | <p class="title">Database Upgrade Completed</p> |
| 4 | 4 | |
| ... | ... | @@ -6,8 +6,8 @@ |
| 6 | 6 | <!-- Services --> |
| 7 | 7 | <br/><br/> |
| 8 | 8 | <div> |
| 9 | - Your database has been upgraded to <?php echo $default->systemVersion; ?> | |
| 9 | + Your database has been upgraded to <?php echo $sysVersion; ?> | |
| 10 | 10 | </div> |
| 11 | 11 | </div> |
| 12 | - <a href="../../" class="back button_next" style="width:90px;" onclick="javascript:{w.clearSessions();}">Goto Login</a> | |
| 12 | + <a href="../../login.php" class="back button_next" style="width:90px;" onclick="javascript:{w.clearSessions();}">Goto Login</a> | |
| 13 | 13 | </form> |
| 14 | 14 | \ No newline at end of file | ... | ... |
setup/upgrade/templates/database.tpl
| ... | ... | @@ -3,6 +3,13 @@ |
| 3 | 3 | <div id="database" class="step1" style="display:block;"> |
| 4 | 4 | <div class="description"> |
| 5 | 5 | This step performs the necessary Database Upgrades. |
| 6 | + <?php | |
| 7 | + echo "<br/>"; | |
| 8 | + foreach ($errors as $error) { | |
| 9 | + if($error != '') | |
| 10 | + echo "<span class = 'error'>$error</span><br/>"; | |
| 11 | + } | |
| 12 | + ?> | |
| 6 | 13 | </div> |
| 7 | 14 | <div id="step_content_database" class="step"> |
| 8 | 15 | <br/><br/> | ... | ... |
setup/upgrade/templates/error.tpl
| 1 | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 2 | 2 | <html> |
| 3 | 3 | <head> |
| 4 | + <link rel="shortcut icon" href="../wizard/resources/graphics/favicon.ico" type="image/x-icon"> | |
| 4 | 5 | <title>KnowledgeTree Installer</title> |
| 5 | 6 | <script type="text/javascript" src="resources/jquery.js"></script> |
| 6 | 7 | <script type="text/javascript" src="resources/wizard.js" ></script> |
| ... | ... | @@ -14,7 +15,7 @@ |
| 14 | 15 | <div id="logo"><img src="resources/graphics/dame/installer-header_logo.png"/></div> |
| 15 | 16 | <div id="install_details"> |
| 16 | 17 | <span style="font-size:120%;"> 3.7 </span> |
| 17 | - <span style="font-size:80%;">Commercial Edition</span> | |
| 18 | + <span style="font-size:80%;">Community Edition</span> | |
| 18 | 19 | </div> |
| 19 | 20 | </div> |
| 20 | 21 | <div id="wrapper"> | ... | ... |
setup/upgrade/templates/loading.tpl
setup/upgrade/templates/progress.tpl
| 1 | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 2 | 2 | <html> |
| 3 | 3 | <head> |
| 4 | + <link rel="shortcut icon" href="../wizard/resources/graphics/favicon.ico" type="image/x-icon"> | |
| 4 | 5 | <title>KnowledgeTree Upgrade Wizard</title> |
| 5 | 6 | <script type="text/javascript" src="resources/jquery.js"></script> |
| 6 | 7 | <script type="text/javascript" src="resources/wizard.js" ></script> |
| ... | ... | @@ -14,7 +15,7 @@ |
| 14 | 15 | <div id="logo"><img src="resources/graphics/dame/upgrader-header_logo.png"/></div> |
| 15 | 16 | <div id="install_details"> |
| 16 | 17 | <span style="font-size:120%;"> 3.7 </span> |
| 17 | - <span style="font-size:80%;">Commercial Edition</span> | |
| 18 | + <span style="font-size:80%;">Community Edition</span> | |
| 18 | 19 | </div> |
| 19 | 20 | </div> |
| 20 | 21 | <div id="wrapper"> | ... | ... |
setup/upgrade/templates/restore.tpl
| ... | ... | @@ -92,7 +92,7 @@ Press <i>Next</i> to attempt the command(s) above. |
| 92 | 92 | ?> |
| 93 | 93 | </div> |
| 94 | 94 | </div> |
| 95 | - <?php include 'templates/loading.tpl'; ?> | |
| 95 | + <?php include WIZARD_DIR . 'templates/loading.tpl'; ?> | |
| 96 | 96 | <div id="buttonBar"> |
| 97 | 97 | <input type="submit" name="Previous" value="Previous" class="button_previous"> |
| 98 | 98 | <?php if (($dir != '') && ($selected)) { ?> | ... | ... |
setup/upgrade/templates/wizard.tpl
| 1 | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 2 | 2 | <html> |
| 3 | 3 | <head> |
| 4 | + <link rel="shortcut icon" href="../wizard/resources/graphics/favicon.ico" type="image/x-icon"> | |
| 4 | 5 | <title>KnowledgeTree Upgrader</title> |
| 5 | 6 | <?php echo $html->js('jquery.js'); ?> |
| 6 | 7 | <?php echo $html->js('jquery.form.js'); ?> | ... | ... |
setup/upgrade/upgradeSession.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | -* Session Controller. | |
| 4 | -* | |
| 5 | -* KnowledgeTree Community Edition | |
| 6 | -* Document Management Made Simple | |
| 7 | -* Copyright(C) 2008,2009 KnowledgeTree Inc. | |
| 8 | -* Portions copyright The Jam Warehouse Software(Pty) Limited | |
| 9 | -* | |
| 10 | -* This program is free software; you can redistribute it and/or modify it under | |
| 11 | -* the terms of the GNU General Public License version 3 as published by the | |
| 12 | -* Free Software Foundation. | |
| 13 | -* | |
| 14 | -* This program is distributed in the hope that it will be useful, but WITHOUT | |
| 15 | -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 16 | -* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
| 17 | -* details. | |
| 18 | -* | |
| 19 | -* You should have received a copy of the GNU General Public License | |
| 20 | -* along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 21 | -* | |
| 22 | -* You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 23 | -* California 94120-7775, or email info@knowledgetree.com. | |
| 24 | -* | |
| 25 | -* The interactive user interfaces in modified source and object code versions | |
| 26 | -* of this program must display Appropriate Legal Notices, as required under | |
| 27 | -* Section 5 of the GNU General Public License version 3. | |
| 28 | -* | |
| 29 | -* In accordance with Section 7(b) of the GNU General Public License version 3, | |
| 30 | -* these Appropriate Legal Notices must retain the display of the "Powered by | |
| 31 | -* KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | -* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | |
| 33 | -* must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | -* copyright notice. | |
| 35 | -* | |
| 36 | -* @copyright 2008-2009, KnowledgeTree Inc. | |
| 37 | -* @license GNU General Public License version 3 | |
| 38 | -* @author KnowledgeTree Team | |
| 39 | -* @package Upgrader | |
| 40 | -* @version Version 0.1 | |
| 41 | -*/ | |
| 42 | -class UpgradeSession | |
| 43 | -{ | |
| 44 | - private $salt = 'upgrade'; | |
| 45 | - /** | |
| 46 | - * Constructs session object | |
| 47 | - * | |
| 48 | - * @author KnowledgeTree Team | |
| 49 | - * @access public | |
| 50 | - * @param none | |
| 51 | - */ | |
| 52 | - public function __construct() { | |
| 53 | - $this->startSession(); | |
| 54 | - } | |
| 55 | - | |
| 56 | - /** | |
| 57 | - * Starts a session if one does not exist | |
| 58 | - * | |
| 59 | - * @author KnowledgeTree Team | |
| 60 | - * @param none | |
| 61 | - * @access public | |
| 62 | - * @return void | |
| 63 | - */ | |
| 64 | - public function startSession() { | |
| 65 | - if(!isset($_SESSION[$this->salt]['ready'])) { | |
| 66 | - session_start(); | |
| 67 | - $_SESSION[$this->salt] ['ready'] = TRUE; | |
| 68 | - } | |
| 69 | - } | |
| 70 | - | |
| 71 | - /** | |
| 72 | - * Sets a value key pair in session | |
| 73 | - * | |
| 74 | - * @author KnowledgeTree Team | |
| 75 | - * @param string $fld | |
| 76 | - * @param string $val | |
| 77 | - * @access public | |
| 78 | - * @return void | |
| 79 | - */ | |
| 80 | - public function set($fld, $val) { | |
| 81 | - $this->startSession(); | |
| 82 | - $_SESSION[$this->salt] [$fld] = $val; | |
| 83 | - } | |
| 84 | - | |
| 85 | - /** | |
| 86 | - * Sets a value key pair in a class in session | |
| 87 | - * | |
| 88 | - * @author KnowledgeTree Team | |
| 89 | - * @param string $class | |
| 90 | - * @param string $fld | |
| 91 | - * @param string $val | |
| 92 | - * @access public | |
| 93 | - * @return void | |
| 94 | - */ | |
| 95 | - public function setClass($class , $k, $v) { | |
| 96 | - $this->startSession(); | |
| 97 | - $classArray = $this->get($class); | |
| 98 | - if(isset($classArray[$k])) { | |
| 99 | - $classArray[$k] = $v; | |
| 100 | - } else { | |
| 101 | - $classArray[$k] = $v; | |
| 102 | - } | |
| 103 | - $_SESSION[$this->salt] [ $class] = $classArray; | |
| 104 | - } | |
| 105 | - | |
| 106 | - /** | |
| 107 | - * Sets a error value key pair in a class in session | |
| 108 | - * | |
| 109 | - * @author KnowledgeTree Team | |
| 110 | - * @param string $class | |
| 111 | - * @param string $fld | |
| 112 | - * @param string $val | |
| 113 | - * @access public | |
| 114 | - * @return void | |
| 115 | - */ | |
| 116 | - public function setClassError($class, $k, $v) { | |
| 117 | - $this->startSession(); | |
| 118 | - $classArray = $this->get($class); | |
| 119 | - if(isset($classArray[$k])) { | |
| 120 | - $classArray[$k] = $v; | |
| 121 | - } else { | |
| 122 | - $classArray[$k] = $v; | |
| 123 | - } | |
| 124 | - $_SESSION[$this->salt] [ $class] = $classArray; | |
| 125 | - } | |
| 126 | - | |
| 127 | - /** | |
| 128 | - * Clear error values in a class session | |
| 129 | - * | |
| 130 | - * @author KnowledgeTree Team | |
| 131 | - * @param string $class | |
| 132 | - * @param string $fld | |
| 133 | - * @param string $val | |
| 134 | - * @access public | |
| 135 | - * @return void | |
| 136 | - */ | |
| 137 | - public function clearErrors($class) { | |
| 138 | - $classArray = $this->get($class); | |
| 139 | - unset($classArray['errors']); | |
| 140 | - $_SESSION[$this->salt] [ $class] = $classArray; | |
| 141 | - } | |
| 142 | - | |
| 143 | - /** | |
| 144 | - * Unset a value in session | |
| 145 | - * | |
| 146 | - * @author KnowledgeTree Team | |
| 147 | - * @param string $fld | |
| 148 | - * @access public | |
| 149 | - * @return void | |
| 150 | - */ | |
| 151 | - public function un_set($fld) { | |
| 152 | - $this->startSession(); | |
| 153 | - unset($_SESSION[$this->salt] [$fld]); | |
| 154 | - } | |
| 155 | - | |
| 156 | - /** | |
| 157 | - * Unset a class value in session | |
| 158 | - * | |
| 159 | - * @author KnowledgeTree Team | |
| 160 | - * @param string $class | |
| 161 | - * @access public | |
| 162 | - * @return void | |
| 163 | - */ | |
| 164 | - public function un_setClass($class) { | |
| 165 | - $this->startSession(); | |
| 166 | - if(isset($_SESSION[$this->salt] [$class])) | |
| 167 | - unset($_SESSION[$this->salt] [$class]); | |
| 168 | - } | |
| 169 | - | |
| 170 | - /** | |
| 171 | - * Destroy the session | |
| 172 | - * | |
| 173 | - * @author KnowledgeTree Team | |
| 174 | - * @param none | |
| 175 | - * @access public | |
| 176 | - * @return void | |
| 177 | - */ | |
| 178 | - public function destroy() { | |
| 179 | - $this->startSession(); | |
| 180 | - unset($_SESSION[$this->salt]); | |
| 181 | - session_destroy(); | |
| 182 | - } | |
| 183 | - | |
| 184 | - /** | |
| 185 | - * Get a session value | |
| 186 | - * | |
| 187 | - * @author KnowledgeTree Team | |
| 188 | - * @param string $fld | |
| 189 | - * @access public | |
| 190 | - * @return string | |
| 191 | - */ | |
| 192 | - public function get($fld) { | |
| 193 | - $this->startSession(); | |
| 194 | - if(isset($_SESSION[$this->salt] [$fld])) | |
| 195 | - return $_SESSION[$this->salt] [$fld]; | |
| 196 | - return false; | |
| 197 | - } | |
| 198 | - | |
| 199 | - /** | |
| 200 | - * Check if a field exists in session | |
| 201 | - * | |
| 202 | - * @author KnowledgeTree Team | |
| 203 | - * @param string $fld | |
| 204 | - * @access public | |
| 205 | - * @return string | |
| 206 | - */ | |
| 207 | - public function is_set($fld) { | |
| 208 | - $this->startSession(); | |
| 209 | - return isset($_SESSION[$this->salt] [$fld]); | |
| 210 | - } | |
| 211 | - | |
| 212 | - /** | |
| 213 | - * Return a class from session | |
| 214 | - * | |
| 215 | - * @author KnowledgeTree Team | |
| 216 | - * @param string $fld | |
| 217 | - * @access public | |
| 218 | - * @return string | |
| 219 | - */ | |
| 220 | - public function getClass($class) { | |
| 221 | - return $_SESSION[$this->salt][$class]; | |
| 222 | - } | |
| 223 | -} | |
| 224 | -?> | |
| 225 | 0 | \ No newline at end of file |
setup/upgrade/upgradeUtil.php
| ... | ... | @@ -40,10 +40,9 @@ |
| 40 | 40 | * @version Version 0.1 |
| 41 | 41 | */ |
| 42 | 42 | |
| 43 | -//require_once('../../config/dmsDefaults.php'); | |
| 44 | 43 | require_once("../wizard/installUtil.php"); |
| 45 | 44 | |
| 46 | -class UpgradeUtil extends InstallUtil { | |
| 45 | +class UpgradeUtil extends InstallUtil { | |
| 47 | 46 | /** |
| 48 | 47 | * Check if system needs to be upgraded |
| 49 | 48 | * |
| ... | ... | @@ -75,16 +74,6 @@ class UpgradeUtil extends InstallUtil { |
| 75 | 74 | echo $contents; |
| 76 | 75 | } |
| 77 | 76 | |
| 78 | - public function loadInstallIni($path) { | |
| 79 | - require_once("../wizard/iniUtilities.php"); | |
| 80 | - return new iniUtilities($path); | |
| 81 | - } | |
| 82 | - | |
| 83 | - public function loadInstallDBUtil() { | |
| 84 | - require_once("../wizard/dbUtilities.php"); | |
| 85 | - return new dbUtilities(); | |
| 86 | - } | |
| 87 | - | |
| 88 | 77 | /** |
| 89 | 78 | * Function to send output to the browser prior to normal dynamic loading of a template after code execution |
| 90 | 79 | * |
| ... | ... | @@ -127,35 +116,35 @@ class UpgradeUtil extends InstallUtil { |
| 127 | 116 | return true; |
| 128 | 117 | } |
| 129 | 118 | |
| 130 | - public function create_restore_stmt($targetfile) | |
| 119 | + public function create_restore_stmt($targetfile, $dbConfig) | |
| 131 | 120 | { |
| 132 | - $oKTConfig =& KTConfig::getSingleton(); | |
| 121 | +// $oKTConfig =& KTConfig::getSingleton(); | |
| 133 | 122 | |
| 134 | - $adminUser = $oKTConfig->get('db/dbAdminUser'); | |
| 135 | - $adminPwd = $oKTConfig->get('db/dbAdminPass'); | |
| 136 | - $dbHost = $oKTConfig->get('db/dbHost'); | |
| 137 | - $dbName = $oKTConfig->get('db/dbName'); | |
| 138 | - $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']); | |
| 139 | 128 | if ($dbPort=='' || $dbPort=='default')$dbPort = get_cfg_var('mysql.default_port'); |
| 140 | 129 | if (empty($dbPort)) $dbPort='3306'; |
| 141 | - $dbSocket = trim($oKTConfig->get('db/dbSocket')); | |
| 130 | + $dbSocket = ''; | |
| 142 | 131 | if (empty($dbSocket) || $dbSocket=='default') $dbSocket = get_cfg_var('mysql.default_socket'); |
| 143 | 132 | if (empty($dbSocket)) $dbSocket='../tmp/mysql.sock'; |
| 144 | 133 | |
| 145 | 134 | $dir = $this->resolveMysqlDir(); |
| 146 | 135 | |
| 147 | - $info['dir']=$dir; | |
| 136 | + $info['dir'] = $dir; | |
| 148 | 137 | |
| 149 | - $prefix=''; | |
| 150 | - if (OS_UNIX) { | |
| 138 | + $prefix = ''; | |
| 139 | + if (!WINDOWS_OS) { | |
| 151 | 140 | $prefix .= "./"; |
| 152 | 141 | } |
| 153 | 142 | |
| 154 | 143 | if (@stat($dbSocket) !== false) { |
| 155 | - $mechanism="--socket=\"$dbSocket\""; | |
| 144 | + $mechanism = "--socket=\"$dbSocket\""; | |
| 156 | 145 | } |
| 157 | 146 | else { |
| 158 | - $mechanism="--port=\"$dbPort\""; | |
| 147 | + $mechanism = "--port=\"$dbPort\""; | |
| 159 | 148 | } |
| 160 | 149 | |
| 161 | 150 | $tmpdir = $this->resolveTempDir(); |
| ... | ... | @@ -163,16 +152,14 @@ class UpgradeUtil extends InstallUtil { |
| 163 | 152 | $stmt = $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism drop \"$dbName\"<br/>"; |
| 164 | 153 | $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" -p $mechanism create \"$dbName\"<br/>"; |
| 165 | 154 | |
| 166 | - | |
| 167 | 155 | $stmt .= $prefix ."mysql --user=\"$adminUser\" -p $mechanism \"$dbName\" < \"$targetfile\"\n"; |
| 168 | 156 | $info['display']=$stmt; |
| 169 | 157 | |
| 170 | - | |
| 171 | 158 | $stmt = $prefix ."mysqladmin --user=\"$adminUser\" --force --password=\"$adminPwd\" $mechanism drop \"$dbName\"\n"; |
| 172 | 159 | $stmt .= $prefix ."mysqladmin --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism create \"$dbName\"\n"; |
| 173 | 160 | |
| 174 | 161 | $stmt .= $prefix ."mysql --user=\"$adminUser\" --password=\"$adminPwd\" $mechanism \"$dbName\" < \"$targetfile\""; |
| 175 | - $info['cmd']=$stmt; | |
| 162 | + $info['cmd'] = $stmt; | |
| 176 | 163 | return $info; |
| 177 | 164 | } |
| 178 | 165 | |
| ... | ... | @@ -180,7 +167,7 @@ class UpgradeUtil extends InstallUtil { |
| 180 | 167 | { |
| 181 | 168 | // possibly detect existing installations: |
| 182 | 169 | |
| 183 | - if (OS_UNIX) { | |
| 170 | + if (!WINDOWS_OS) { | |
| 184 | 171 | $dirs = array('/opt/mysql/bin','/usr/local/mysql/bin'); |
| 185 | 172 | $mysqlname ='mysql'; |
| 186 | 173 | } |
| ... | ... | @@ -192,8 +179,9 @@ class UpgradeUtil extends InstallUtil { |
| 192 | 179 | $mysqlname ='mysql.exe'; |
| 193 | 180 | } |
| 194 | 181 | |
| 195 | - $oKTConfig =& KTConfig::getSingleton(); | |
| 196 | - $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 = ''; | |
| 197 | 185 | $dirs[] = $mysqldir; |
| 198 | 186 | |
| 199 | 187 | if (strpos(__FILE__,'knowledgeTree') !== false && strpos(__FILE__,'ktdms') != false) { |
| ... | ... | @@ -213,14 +201,16 @@ class UpgradeUtil extends InstallUtil { |
| 213 | 201 | |
| 214 | 202 | public function resolveTempDir() |
| 215 | 203 | { |
| 216 | - if (OS_UNIX) { | |
| 204 | + $dir = ''; | |
| 205 | + if (!WINDOWS_OS) { | |
| 217 | 206 | $dir='/tmp/kt-db-backup'; |
| 218 | 207 | } |
| 219 | 208 | else { |
| 220 | 209 | $dir='c:/kt-db-backup'; |
| 221 | 210 | } |
| 222 | - $oKTConfig =& KTConfig::getSingleton(); | |
| 223 | - $dir = $oKTConfig->get('backup/backupDirectory',$dir); | |
| 211 | + | |
| 212 | +// $oKTConfig =& KTConfig::getSingleton(); | |
| 213 | +// $dir = $oKTConfig->get('backup/backupDirectory',$dir); | |
| 224 | 214 | |
| 225 | 215 | if (!is_dir($dir)) { |
| 226 | 216 | mkdir($dir); | ... | ... |
setup/upgrade/upgradeWizard.php
| ... | ... | @@ -50,8 +50,8 @@ include("../wizard/path.php"); // Paths |
| 50 | 50 | function __autoload($class) { // Attempt and autoload classes |
| 51 | 51 | $class = strtolower(substr($class,0,1)).substr($class,1); // Linux Systems. |
| 52 | 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 | 55 | return ; |
| 56 | 56 | } |
| 57 | 57 | if(file_exists(WIZARD_DIR."$class.php")) { | ... | ... |
setup/wizard/dbUtil.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | -* Installer Database Control. | |
| 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 Installer | |
| 40 | -* @version Version 0.1 | |
| 41 | -*/ | |
| 42 | -class dbUtil { | |
| 43 | - /** | |
| 44 | - * Host | |
| 45 | - * | |
| 46 | - * @author KnowledgeTree Team | |
| 47 | - * @access protected | |
| 48 | - * @var string | |
| 49 | - */ | |
| 50 | - protected $dbhost = ''; | |
| 51 | - | |
| 52 | - /** | |
| 53 | - * Host | |
| 54 | - * | |
| 55 | - * @author KnowledgeTree Team | |
| 56 | - * @access protected | |
| 57 | - * @var string | |
| 58 | - */ | |
| 59 | - protected $dbname = ''; | |
| 60 | - | |
| 61 | - /** | |
| 62 | - * Host | |
| 63 | - * | |
| 64 | - * @author KnowledgeTree Team | |
| 65 | - * @access protected | |
| 66 | - * @var string | |
| 67 | - */ | |
| 68 | - protected $dbuname = ''; | |
| 69 | - | |
| 70 | - /** | |
| 71 | - * Host | |
| 72 | - * | |
| 73 | - * @author KnowledgeTree Team | |
| 74 | - * @access protected | |
| 75 | - * @var string | |
| 76 | - */ | |
| 77 | - protected $dbpassword = ''; | |
| 78 | - | |
| 79 | - /** | |
| 80 | - * Host | |
| 81 | - * | |
| 82 | - * @author KnowledgeTree Team | |
| 83 | - * @access protected | |
| 84 | - * @var object mysql connection | |
| 85 | - */ | |
| 86 | - protected $dbconnection = ''; | |
| 87 | - | |
| 88 | - /** | |
| 89 | - * Any errors encountered | |
| 90 | - * | |
| 91 | - * @author KnowledgeTree Team | |
| 92 | - * @access protected | |
| 93 | - * @var array | |
| 94 | - */ | |
| 95 | - protected $error = array(); | |
| 96 | - | |
| 97 | - /** | |
| 98 | - * Constructs database connection object | |
| 99 | - * | |
| 100 | - * @author KnowledgeTree Team | |
| 101 | - * @access public | |
| 102 | - */ | |
| 103 | - public function __construct() { | |
| 104 | - | |
| 105 | - } | |
| 106 | - | |
| 107 | - public function load($dhost = 'localhost', $duname, $dpassword, $dbname) { | |
| 108 | - $this->dbhost = $dhost; | |
| 109 | - $this->dbuname = $duname; | |
| 110 | - $this->dbpassword = $dpassword; | |
| 111 | - $this->dbconnection = @mysql_connect($dhost, $duname, $dpassword); | |
| 112 | - if(!$this->dbconnection) { | |
| 113 | - $this->error[] = @mysql_error(); | |
| 114 | - } | |
| 115 | - $this->dbname = $dbname; | |
| 116 | - } | |
| 117 | - | |
| 118 | - public function getDatabaseLink() { | |
| 119 | - return $this->dbconnection; | |
| 120 | - } | |
| 121 | - /** | |
| 122 | - * Choose a database to use | |
| 123 | - * | |
| 124 | - * @param string $dbname name of the database | |
| 125 | - * @access public | |
| 126 | - * @return boolean | |
| 127 | - */ | |
| 128 | - public function useDb() { | |
| 129 | - if(@mysql_select_db($this->dbname, $this->dbconnection)) | |
| 130 | - return true; | |
| 131 | - else { | |
| 132 | - $this->error[] = @mysql_error($this->dbconnection); | |
| 133 | - return false; | |
| 134 | - } | |
| 135 | - } | |
| 136 | - | |
| 137 | - public function setDb($dbname) { | |
| 138 | - $this->dbname = $dbname; | |
| 139 | - } | |
| 140 | - | |
| 141 | - /** | |
| 142 | - * Query the database. | |
| 143 | - * | |
| 144 | - * @param $query the sql query. | |
| 145 | - * @access public | |
| 146 | - * @return object The result of the query. | |
| 147 | - */ | |
| 148 | - public function query($query) { | |
| 149 | - $this->useDb(); | |
| 150 | - $result = mysql_query($query, $this->dbconnection); | |
| 151 | - if($result) { | |
| 152 | - return $result; | |
| 153 | - } else { | |
| 154 | - $this->error[] = @mysql_error($this->dbconnection); | |
| 155 | - return false; | |
| 156 | - } | |
| 157 | - } | |
| 158 | - | |
| 159 | - /** | |
| 160 | - * Do the same as query. | |
| 161 | - * | |
| 162 | - * @param $query the sql query. | |
| 163 | - * @access public | |
| 164 | - * @return boolean | |
| 165 | - */ | |
| 166 | - public function execute($query) { | |
| 167 | - $this->useDb(); | |
| 168 | - $result = @mysql_query($query, $this->dbconnection); | |
| 169 | - if(!$result) { | |
| 170 | - $this->error[] = @mysql_error($this->dbconnection); | |
| 171 | - } | |
| 172 | - | |
| 173 | - return $result; | |
| 174 | - } | |
| 175 | - | |
| 176 | - /** | |
| 177 | - * Convenience method for mysql_fetch_object(). | |
| 178 | - * | |
| 179 | - * @param $result The resource returned by query(). | |
| 180 | - * @access public | |
| 181 | - * @return object An object representing a data row. | |
| 182 | - */ | |
| 183 | - public function fetchNextObject($result = NULL) { | |
| 184 | - if ($result == NULL || @mysql_num_rows($result) < 1) | |
| 185 | - return NULL; | |
| 186 | - else | |
| 187 | - return @mysql_fetch_object($result); | |
| 188 | - } | |
| 189 | - | |
| 190 | - /** | |
| 191 | - * Convenience method for mysql_fetch_assoc(). | |
| 192 | - * | |
| 193 | - * @param $result The resource returned by query(). | |
| 194 | - * @access public | |
| 195 | - * @return array Returns an associative array of strings. | |
| 196 | - */ | |
| 197 | - public function fetchAssoc($result = NULL) { | |
| 198 | - $r = array(); | |
| 199 | - if ($result == NULL || @mysql_num_rows($result) < 1) | |
| 200 | - return NULL; | |
| 201 | - else { | |
| 202 | - while(($r[] = mysql_fetch_assoc($result)) || array_pop($r)); | |
| 203 | - return $r; | |
| 204 | - } | |
| 205 | - } | |
| 206 | - | |
| 207 | - /** | |
| 208 | - * Close the connection with the database server. | |
| 209 | - * | |
| 210 | - * @param none. | |
| 211 | - * @access public | |
| 212 | - * @return void. | |
| 213 | - */ | |
| 214 | - public function close() { | |
| 215 | - @mysql_close($this->dbconnection); | |
| 216 | - } | |
| 217 | - | |
| 218 | - /** | |
| 219 | - * Get database errors. | |
| 220 | - * | |
| 221 | - * @param none. | |
| 222 | - * @access public | |
| 223 | - * @return array. | |
| 224 | - */ | |
| 225 | - public function getErrors() { | |
| 226 | - return $this->error; | |
| 227 | - } | |
| 228 | - | |
| 229 | - public function clearErrors() { | |
| 230 | - return $this->error = array(); | |
| 231 | - } | |
| 232 | - | |
| 233 | - /** | |
| 234 | - * Fetches the last generated error | |
| 235 | - | |
| 236 | - * @return string | |
| 237 | - */ | |
| 238 | - function getLastError() { | |
| 239 | - return end($this->error); | |
| 240 | - } | |
| 241 | - | |
| 242 | - /** | |
| 243 | - * Start a database transaction | |
| 244 | - */ | |
| 245 | - public function startTransaction() { | |
| 246 | - $this->query("START TRANSACTION"); | |
| 247 | - } | |
| 248 | - | |
| 249 | - /** | |
| 250 | - * Roll back a database transaction | |
| 251 | - */ | |
| 252 | - public function rollback() { | |
| 253 | - $this->query("ROLLBACK"); | |
| 254 | - } | |
| 255 | -} | |
| 256 | -?> | |
| 257 | 0 | \ No newline at end of file |
setup/wizard/dbUtilities.php
| ... | ... | @@ -101,20 +101,32 @@ class dbUtilities { |
| 101 | 101 | * @access public |
| 102 | 102 | */ |
| 103 | 103 | public function __construct() { |
| 104 | - | |
| 104 | + | |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - public function load($dhost = 'localhost', $duname, $dpassword, $dbname) { | |
| 108 | - $this->dbhost = $dhost; | |
| 109 | - $this->dbuname = $duname; | |
| 110 | - $this->dbpassword = $dpassword; | |
| 111 | - $this->dbconnection = @mysql_connect($dhost, $duname, $dpassword); | |
| 112 | - if(!$this->dbconnection) { | |
| 113 | - $this->error[] = @mysql_error(); | |
| 107 | + public function load($dhost = 'localhost', $dport = 'default', $duname, $dpassword, $dbname) { | |
| 108 | + if(!$this->isConnected($dhost, $duname, $dpassword, $dbname)) { | |
| 109 | + if($dport == 'default' || $dport == '') | |
| 110 | + $dport = '3306'; | |
| 111 | + $this->dbhost = $dhost.":".$dport; | |
| 112 | + $this->dbuname = $duname; | |
| 113 | + $this->dbpassword = $dpassword; | |
| 114 | + $this->dbconnection = @mysql_connect($dhost, $duname, $dpassword); | |
| 115 | + $this->dbname = $dbname; | |
| 114 | 116 | } |
| 115 | - $this->dbname = $dbname; | |
| 116 | 117 | } |
| 117 | 118 | |
| 119 | + public function isConnected($dhost = 'localhost', $duname, $dpassword, $dbname) { | |
| 120 | + $current = array($this->dbhost, $this->dbuname, $this->dbpassword, $this->dbname); | |
| 121 | + $new = array($dhost, $duname, $dpassword, $dbname); | |
| 122 | + $diff = array_diff($new, $current); | |
| 123 | + if(count($diff) == 0) { | |
| 124 | + if($this->getDatabaseLink()) // Make sure theres a link | |
| 125 | + return true; // Already connected | |
| 126 | + } | |
| 127 | + return false; // Reconnect | |
| 128 | + } | |
| 129 | + | |
| 118 | 130 | public function getDatabaseLink() { |
| 119 | 131 | return $this->dbconnection; |
| 120 | 132 | } |
| ... | ... | @@ -223,6 +235,9 @@ class dbUtilities { |
| 223 | 235 | * @return array. |
| 224 | 236 | */ |
| 225 | 237 | public function getErrors() { |
| 238 | + if(!$this->dbconnection) { | |
| 239 | + $this->error[] = @mysql_error(); | |
| 240 | + } | |
| 226 | 241 | return $this->error; |
| 227 | 242 | } |
| 228 | 243 | |
| ... | ... | @@ -252,5 +267,15 @@ class dbUtilities { |
| 252 | 267 | public function rollback() { |
| 253 | 268 | $this->query("ROLLBACK"); |
| 254 | 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 | + } | |
| 255 | 280 | } |
| 256 | 281 | ?> |
| 257 | 282 | \ No newline at end of file | ... | ... |
setup/wizard/ini.php deleted
| 1 | -<?php | |
| 2 | -/** | |
| 3 | - * $Id:$ | |
| 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 | - * Contributor( s): ______________________________________ | |
| 36 | - * | |
| 37 | - */ | |
| 38 | - | |
| 39 | -class Ini { | |
| 40 | - | |
| 41 | - private $cleanArray = array(); | |
| 42 | - private $iniFile = ''; | |
| 43 | - private $lineNum = 0; | |
| 44 | - private $exists = ''; | |
| 45 | - | |
| 46 | - function Ini($iniFile = '../../config.ini') { | |
| 47 | - $this->iniFile = $iniFile; | |
| 48 | - $this->backupIni($iniFile); | |
| 49 | - $this->read($iniFile); | |
| 50 | - } | |
| 51 | - | |
| 52 | - /** | |
| 53 | - * Create a backup with the date as an extension in the same location as the original config.ini | |
| 54 | - * | |
| 55 | - * @param string $iniFile | |
| 56 | - * @return boolean | |
| 57 | - */ | |
| 58 | - function backupIni($iniFile) | |
| 59 | - { | |
| 60 | - $content = file_get_contents($iniFile); | |
| 61 | - if ($content === false) | |
| 62 | - { | |
| 63 | - return false; | |
| 64 | - } | |
| 65 | - $date = date('YmdHis'); | |
| 66 | - | |
| 67 | - $backupFile = $iniFile . '.' .$date; | |
| 68 | - if (is_writeable($backupFile)) { | |
| 69 | - file_put_contents($backupFile, $content); | |
| 70 | - } | |
| 71 | - } | |
| 72 | - | |
| 73 | - function read($iniFile) { | |
| 74 | - | |
| 75 | - $iniArray = file($iniFile); | |
| 76 | - $section = ''; | |
| 77 | - foreach($iniArray as $iniLine) { | |
| 78 | - $this->lineNum++; | |
| 79 | - $iniLine = trim($iniLine); | |
| 80 | - $firstChar = substr($iniLine, 0, 1); | |
| 81 | - if($firstChar == ';') { | |
| 82 | - if($section == ''){ | |
| 83 | - $this->cleanArray['_comment_'.$this->lineNum]=$iniLine; | |
| 84 | - }else { | |
| 85 | - $this->cleanArray[$section]['_comment_'.$this->lineNum]=$iniLine; | |
| 86 | - } | |
| 87 | - continue; | |
| 88 | - } | |
| 89 | - if($iniLine == '') { | |
| 90 | - if($section == ''){ | |
| 91 | - $this->cleanArray['_blankline_'.$this->lineNum]=''; | |
| 92 | - }else { | |
| 93 | - $this->cleanArray[$section]['_blankline_'.$this->lineNum]=''; | |
| 94 | - } | |
| 95 | - continue; | |
| 96 | - } | |
| 97 | - | |
| 98 | - if ($firstChar == '[' && substr($iniLine, -1, 1) == ']') { | |
| 99 | - $section = substr($iniLine, 1, -1); | |
| 100 | - $this->sections[] = $section; | |
| 101 | - } else { | |
| 102 | - $equalsPos = strpos($iniLine, '='); | |
| 103 | - if ($equalsPos > 0 && $equalsPos != sizeof($iniLine)) { | |
| 104 | - $key = trim(substr($iniLine, 0, $equalsPos)); | |
| 105 | - $value = trim(substr($iniLine, $equalsPos+1)); | |
| 106 | - if (substr($value, 1, 1) == '"' && substr( $value, -1, 1) == '"') { | |
| 107 | - $value = substr($value, 1, -1); | |
| 108 | - } | |
| 109 | - $this->cleanArray[$section][$key] = stripcslashes($value); | |
| 110 | - } else { | |
| 111 | - $this->cleanArray[$section][trim($iniLine)]=''; | |
| 112 | - } | |
| 113 | - } | |
| 114 | - } | |
| 115 | - return $this->cleanArray; | |
| 116 | - } | |
| 117 | - | |
| 118 | - function write($iniFile = "") { | |
| 119 | - | |
| 120 | - if(empty($iniFile)) { | |
| 121 | - $iniFile = $this->iniFile; | |
| 122 | - } | |
| 123 | - if (!is_writeable($iniFile)) { | |
| 124 | - return; | |
| 125 | - } | |
| 126 | - | |
| 127 | - $fileHandle = fopen($iniFile, 'wb'); | |
| 128 | - foreach ($this->cleanArray as $section => $items) { | |
| 129 | - if (substr($section, 0, strlen('_blankline_')) === '_blankline_' ) { | |
| 130 | - fwrite ($fileHandle, "\r\n"); | |
| 131 | - continue; | |
| 132 | - } | |
| 133 | - if (substr($section, 0, strlen('_comment_')) === '_comment_' ) { | |
| 134 | - fwrite ($fileHandle, "$items\r\n"); | |
| 135 | - continue; | |
| 136 | - } | |
| 137 | - fwrite ($fileHandle, "[".$section."]\r\n"); | |
| 138 | - foreach ($items as $key => $value) { | |
| 139 | - if (substr($key, 0, strlen('_blankline_')) === '_blankline_' ) { | |
| 140 | - fwrite ($fileHandle, "\r\n"); | |
| 141 | - continue; | |
| 142 | - } | |
| 143 | - if (substr($key, 0, strlen('_comment_')) === '_comment_' ) { | |
| 144 | - fwrite ($fileHandle, "$value\r\n"); | |
| 145 | - continue; | |
| 146 | - } | |
| 147 | - | |
| 148 | - $value = addcslashes($value,''); | |
| 149 | - //fwrite ($fileHandle, $key.' = "'.$value."\"\r\n"); | |
| 150 | - fwrite ($fileHandle, $key.' = '.$value."\r\n"); | |
| 151 | - } | |
| 152 | - } | |
| 153 | - fclose($fileHandle); | |
| 154 | - } | |
| 155 | - | |
| 156 | - function itemExists($checkSection, $checkItem) { | |
| 157 | - | |
| 158 | - $this->exists = ''; | |
| 159 | - foreach($this->cleanArray as $section => $items) { | |
| 160 | - if($section == $checkSection) { | |
| 161 | - $this->exists = 'section'; | |
| 162 | - foreach ($items as $key => $value) { | |
| 163 | - if($key == $checkItem) { | |
| 164 | - return true; | |
| 165 | - } | |
| 166 | - } | |
| 167 | - } | |
| 168 | - } | |
| 169 | - return false; | |
| 170 | - } | |
| 171 | - | |
| 172 | - function addItem($addSection, $addItem, $value, $itemComment = '', $sectionComment = '') { | |
| 173 | - | |
| 174 | - if($this->itemExists($addSection, $addItem)) { | |
| 175 | - $this->delItem($addSection, $addItem); | |
| 176 | - } | |
| 177 | - | |
| 178 | - if($this->exists != 'section') { | |
| 179 | - $this->cleanArray['_blankline_'.$this->lineNum++]=''; | |
| 180 | - if(!empty($sectionComment)) $this->cleanArray['_comment_'.$this->lineNum++] = '; '.$sectionComment; | |
| 181 | - } | |
| 182 | - if(!empty($itemComment)) { | |
| 183 | - $this->cleanArray[$addSection]['_comment_'.$this->lineNum++] = '; '.$itemComment; | |
| 184 | - } | |
| 185 | - $this->cleanArray[$addSection][$addItem] = stripcslashes($value); | |
| 186 | - return true; | |
| 187 | - } | |
| 188 | - | |
| 189 | - function updateItem($addSection, $addItem, $value) { | |
| 190 | - | |
| 191 | - $this->cleanArray[$addSection][$addItem] = stripcslashes($value); | |
| 192 | - return true; | |
| 193 | - } | |
| 194 | - | |
| 195 | - function delItem($delSection, $delItem) { | |
| 196 | - | |
| 197 | - if(!$this->itemExists($delSection, $delItem)) return false; | |
| 198 | - | |
| 199 | - unset($this->cleanArray[$delSection][$delItem]); | |
| 200 | - return true; | |
| 201 | - } | |
| 202 | - | |
| 203 | - function delSection($delSection) { | |
| 204 | - | |
| 205 | - unset($this->cleanArray[$delSection]); | |
| 206 | - return true; | |
| 207 | - } | |
| 208 | - | |
| 209 | - // Return file line by line | |
| 210 | - public function getFileByLine() { | |
| 211 | - $data = $this->read($this->iniFile); | |
| 212 | - return $data['']; | |
| 213 | - } | |
| 214 | - | |
| 215 | - public function getSection($section) { | |
| 216 | - if (isset($this->cleanArray[$section])) { | |
| 217 | - return $this->cleanArray[$section]; | |
| 218 | - } | |
| 219 | - | |
| 220 | - return false; | |
| 221 | - } | |
| 222 | -} | |
| 223 | -?> | |
| 224 | 0 | \ No newline at end of file |
setup/wizard/iniUtilities.php
| ... | ... | @@ -43,12 +43,21 @@ class iniUtilities { |
| 43 | 43 | private $lineNum = 0; |
| 44 | 44 | private $exists = ''; |
| 45 | 45 | |
| 46 | - function iniUtilities($iniFile = '../../config.ini') { | |
| 46 | + | |
| 47 | + function load($iniFile) { | |
| 48 | +// if($this->iniFile != $iniFile) { | |
| 49 | +// $this->cleanArray = array(); | |
| 50 | +// $this->lineNum = 0; | |
| 51 | +// $this->exists = ''; | |
| 52 | +// } | |
| 47 | 53 | $this->iniFile = $iniFile; |
| 48 | 54 | $this->backupIni($iniFile); |
| 49 | 55 | $this->read($iniFile); |
| 50 | 56 | } |
| 51 | - | |
| 57 | + | |
| 58 | +// function __construct() { | |
| 59 | +// } | |
| 60 | + | |
| 52 | 61 | /** |
| 53 | 62 | * Create a backup with the date as an extension in the same location as the original config.ini |
| 54 | 63 | * |
| ... | ... | @@ -58,23 +67,23 @@ class iniUtilities { |
| 58 | 67 | function backupIni($iniFile) |
| 59 | 68 | { |
| 60 | 69 | $content = file_get_contents($iniFile); |
| 61 | - if ($content === false) | |
| 70 | + if (!$content === false) | |
| 62 | 71 | { |
| 63 | - return false; | |
| 64 | - } | |
| 65 | - $date = date('YmdHis'); | |
| 66 | - | |
| 67 | - $backupFile = $iniFile . '.' .$date; | |
| 68 | - if (is_writeable($backupFile)) { | |
| 69 | - file_put_contents($backupFile, $content); | |
| 70 | - } | |
| 72 | + $date = date('YmdHis'); | |
| 73 | + | |
| 74 | + $backupFile = $iniFile . '.' .$date; | |
| 75 | + if (is_writeable($backupFile)) { | |
| 76 | + file_put_contents($backupFile, $content); | |
| 77 | + } | |
| 78 | + } | |
| 79 | + return false; | |
| 71 | 80 | } |
| 72 | 81 | |
| 73 | 82 | function read($iniFile) { |
| 74 | 83 | $iniArray = file($iniFile); |
| 75 | 84 | $section = ''; |
| 76 | 85 | foreach($iniArray as $iniLine) { |
| 77 | - $this->lineNum++; | |
| 86 | + ++$this->lineNum; | |
| 78 | 87 | $iniLine = trim($iniLine); |
| 79 | 88 | $firstChar = substr($iniLine, 0, 1); |
| 80 | 89 | if($firstChar == ';') { |
| ... | ... | @@ -111,6 +120,7 @@ class iniUtilities { |
| 111 | 120 | } |
| 112 | 121 | } |
| 113 | 122 | } |
| 123 | + | |
| 114 | 124 | return $this->cleanArray; |
| 115 | 125 | } |
| 116 | 126 | |
| ... | ... | @@ -153,12 +163,12 @@ class iniUtilities { |
| 153 | 163 | } |
| 154 | 164 | |
| 155 | 165 | function itemExists($checkSection, $checkItem) { |
| 156 | - | |
| 157 | 166 | $this->exists = ''; |
| 158 | 167 | foreach($this->cleanArray as $section => $items) { |
| 159 | 168 | if($section == $checkSection) { |
| 160 | 169 | $this->exists = 'section'; |
| 161 | - foreach ($items as $key => $value) { | |
| 170 | + $items = array_flip($items); | |
| 171 | + foreach ($items as $key) { | |
| 162 | 172 | if($key == $checkItem) { |
| 163 | 173 | return true; |
| 164 | 174 | } | ... | ... |
setup/wizard/installUtil.php
| ... | ... | @@ -39,9 +39,13 @@ |
| 39 | 39 | * @package Installer |
| 40 | 40 | * @version Version 0.1 |
| 41 | 41 | */ |
| 42 | +require_once("iniUtilities.php"); | |
| 43 | +require_once("dbUtilities.php"); | |
| 44 | + | |
| 42 | 45 | class InstallUtil { |
| 43 | - | |
| 44 | 46 | private $salt = 'installers'; |
| 47 | + public $dbUtilities = null; | |
| 48 | + public $iniUtilities = null; | |
| 45 | 49 | |
| 46 | 50 | /** |
| 47 | 51 | * Constructs installation object |
| ... | ... | @@ -50,6 +54,8 @@ class InstallUtil { |
| 50 | 54 | * @access public |
| 51 | 55 | */ |
| 52 | 56 | public function __construct() { |
| 57 | + $this->dbUtilities = new dbUtilities(); | |
| 58 | + $this->iniUtilities = new iniUtilities(); | |
| 53 | 59 | } |
| 54 | 60 | |
| 55 | 61 | /** |
| ... | ... | @@ -70,15 +76,17 @@ class InstallUtil { |
| 70 | 76 | public function error($error) { |
| 71 | 77 | $template_vars['error'] = $error; |
| 72 | 78 | $file = "templates/error.tpl"; |
| 73 | - if (!file_exists($file)) { | |
| 74 | - return false; | |
| 79 | + if (file_exists($file)) { | |
| 80 | + extract($template_vars); // Extract the vars to local namespace | |
| 81 | + ob_start(); | |
| 82 | + include($file); | |
| 83 | + $contents = ob_get_contents(); | |
| 84 | + ob_end_clean(); | |
| 85 | + echo $contents; | |
| 75 | 86 | } |
| 76 | - extract($template_vars); // Extract the vars to local namespace | |
| 77 | - ob_start(); | |
| 78 | - include($file); | |
| 79 | - $contents = ob_get_contents(); | |
| 80 | - ob_end_clean(); | |
| 81 | - echo $contents; | |
| 87 | + | |
| 88 | + return false; | |
| 89 | + | |
| 82 | 90 | } |
| 83 | 91 | /** |
| 84 | 92 | * Check if system needs to be installed |
| ... | ... | @@ -165,7 +173,7 @@ class InstallUtil { |
| 165 | 173 | return $url; |
| 166 | 174 | } |
| 167 | 175 | if (!empty($protocol)) { |
| 168 | - $url = $protocol .':'. end($array = explode(':', $url, 2)); | |
| 176 | + $url = $protocol .':'. end(explode(':', $url, 2)); | |
| 169 | 177 | } |
| 170 | 178 | if (!empty($port)) { |
| 171 | 179 | $url = preg_replace('!^(([a-z0-9]+)://[^/:]+)(:[\d]+)?!i', |
| ... | ... | @@ -325,9 +333,11 @@ class InstallUtil { |
| 325 | 333 | return false; |
| 326 | 334 | elseif(!is_dir($fullpath)) { |
| 327 | 335 | $perms = substr(sprintf('%o', fileperms($fullpath)), -4); |
| 328 | - if($perms != $filemode) | |
| 329 | - if (!chmod($fullpath, $filemode)) | |
| 336 | + if($perms != $filemode) { | |
| 337 | + if (!chmod($fullpath, $filemode)) { | |
| 330 | 338 | return false; |
| 339 | + } | |
| 340 | + } | |
| 331 | 341 | } elseif(!$this->chmodRecursive($fullpath, $filemode)) |
| 332 | 342 | return false; |
| 333 | 343 | } |
| ... | ... | @@ -354,7 +364,8 @@ class InstallUtil { |
| 354 | 364 | */ |
| 355 | 365 | public function canWriteFile($filename) { |
| 356 | 366 | $fh = fopen($filename, "w+"); |
| 357 | - if($fr = fwrite($fh, 'test') === false) { | |
| 367 | + $fr = fwrite($fh, 'test'); | |
| 368 | + if($fr === false) { | |
| 358 | 369 | return false; |
| 359 | 370 | } |
| 360 | 371 | |
| ... | ... | @@ -372,9 +383,9 @@ class InstallUtil { |
| 372 | 383 | */ |
| 373 | 384 | public function javaBridge() { |
| 374 | 385 | try { |
| 375 | - $javaSystem = new Java('java.lang.System'); | |
| 386 | + new Java('java.lang.System'); | |
| 376 | 387 | } catch (JavaException $e) { |
| 377 | - return false; | |
| 388 | + return $e; | |
| 378 | 389 | } |
| 379 | 390 | return true; |
| 380 | 391 | } |
| ... | ... | @@ -449,6 +460,8 @@ class InstallUtil { |
| 449 | 460 | return preg_replace('/java:/', '', $r); |
| 450 | 461 | } |
| 451 | 462 | } |
| 463 | + | |
| 464 | + return ''; | |
| 452 | 465 | } |
| 453 | 466 | |
| 454 | 467 | /** |
| ... | ... | @@ -726,6 +739,7 @@ class InstallUtil { |
| 726 | 739 | * @return string |
| 727 | 740 | */ |
| 728 | 741 | public function installEnvironment() { |
| 742 | + $matches = false; | |
| 729 | 743 | preg_match('/Zend/', SYSTEM_DIR, $matches); // Install Type |
| 730 | 744 | if($matches) { |
| 731 | 745 | return 'Zend'; |
| ... | ... | @@ -753,7 +767,7 @@ class InstallUtil { |
| 753 | 767 | array_pop($sysdir); |
| 754 | 768 | array_pop($sysdir); |
| 755 | 769 | $zendsys = ''; |
| 756 | - foreach ($sysdir as $k=>$v) { | |
| 770 | + foreach ($sysdir as $v) { | |
| 757 | 771 | $zendsys .= $v.DS; |
| 758 | 772 | } |
| 759 | 773 | $bin = $zendsys."ZendServer".DS."bin".DS; |
| ... | ... | @@ -778,15 +792,16 @@ class InstallUtil { |
| 778 | 792 | if(WINDOWS_OS) { // Mysql bin [Windows] |
| 779 | 793 | $serverPaths = explode(';',$_SERVER['PATH']); |
| 780 | 794 | foreach ($serverPaths as $apath) { |
| 795 | + $matches = false; | |
| 781 | 796 | preg_match('/mysql/i', $apath, $matches); |
| 782 | 797 | if($matches) { |
| 783 | 798 | return $apath.DS; |
| 784 | 799 | break; |
| 785 | 800 | } |
| 786 | 801 | } |
| 787 | - } else { | |
| 788 | - return "mysql"; // Assume its linux and can be executed from command line | |
| 789 | 802 | } |
| 803 | + | |
| 804 | + return "mysql"; // Assume its linux and can be executed from command line | |
| 790 | 805 | } |
| 791 | 806 | |
| 792 | 807 | public function sqlInstallDir() { | ... | ... |
setup/wizard/installWizard.php
| ... | ... | @@ -63,8 +63,8 @@ function __autoload($class) { // Attempt and autoload classes |
| 63 | 63 | if(preg_match('/Helper/', $class)) { |
| 64 | 64 | require_once(HELPER_DIR."$class.php"); |
| 65 | 65 | } |
| 66 | - return null; | |
| 67 | 66 | } |
| 67 | + return false; | |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | class InstallWizard { |
| ... | ... | @@ -263,8 +263,6 @@ class InstallWizard { |
| 263 | 263 | return true; |
| 264 | 264 | break; |
| 265 | 265 | } |
| 266 | - | |
| 267 | - return $res; | |
| 268 | 266 | } |
| 269 | 267 | |
| 270 | 268 | /** |
| ... | ... | @@ -284,7 +282,7 @@ class InstallWizard { |
| 284 | 282 | } |
| 285 | 283 | if(!$this->isSystemInstalled()) { // Check if the systems not installed |
| 286 | 284 | if($this->util->migrationSpecified()) { // Check if the migrator needs to be accessed |
| 287 | - $this->util->redirect('../migrate'); | |
| 285 | + $this->util->redirect('../migrate/index.php'); | |
| 288 | 286 | } elseif ($this->util->upgradeSpecified()) { |
| 289 | 287 | $this->util->redirect('../upgrade/index.php?action=installer'); |
| 290 | 288 | } | ... | ... |
setup/wizard/installer.php
| ... | ... | @@ -157,7 +157,7 @@ class Installer { |
| 157 | 157 | $this->simpleXmlObj = simplexml_load_file(CONF_DIR.$name); |
| 158 | 158 | } catch (Exception $e) { |
| 159 | 159 | $util = new InstallUtil(); |
| 160 | - $util->error("Error reading configuration file: $name"); | |
| 160 | + $util->error("Error reading configuration file: $e"); | |
| 161 | 161 | exit(); |
| 162 | 162 | } |
| 163 | 163 | } |
| ... | ... | @@ -431,8 +431,7 @@ class Installer { |
| 431 | 431 | if($class->runInstall()) { // Check if step needs to be installed |
| 432 | 432 | $class->setDataFromSession($className); // Set Session Information |
| 433 | 433 | $class->setPostConfig(); // Set any posted variables |
| 434 | - $response = $class->installStep(); // Run install step | |
| 435 | - // TODO : Break on error response | |
| 434 | + $class->installStep(); // Run install step | |
| 436 | 435 | } |
| 437 | 436 | } else { |
| 438 | 437 | $util = new InstallUtil(); | ... | ... |
setup/wizard/lib/helpers/htmlHelper.php
| ... | ... | @@ -41,7 +41,7 @@ |
| 41 | 41 | */ |
| 42 | 42 | class htmlHelper { |
| 43 | 43 | |
| 44 | - var $tags = array( | |
| 44 | + private $tags = array( | |
| 45 | 45 | 'meta' => '<meta%s/>', |
| 46 | 46 | 'metalink' => '<link href="%s"%s/>', |
| 47 | 47 | 'link' => '<a href="%s"%s>%s</a>', |
| ... | ... | @@ -114,6 +114,10 @@ class htmlHelper { |
| 114 | 114 | return $image; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | + function url() { | |
| 118 | + | |
| 119 | + } | |
| 120 | + | |
| 117 | 121 | function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) { |
| 118 | 122 | if (is_array($options)) { |
| 119 | 123 | $options = array_merge(array('escape' => true), $options); | ... | ... |
setup/wizard/lib/services/unixLucene.php
| ... | ... | @@ -59,7 +59,7 @@ class unixLucene extends unixService { |
| 59 | 59 | * @param string |
| 60 | 60 | * @return void |
| 61 | 61 | */ |
| 62 | - public function load($options = null) { | |
| 62 | + public function load() { | |
| 63 | 63 | $this->setLuceneSource("ktlucene.jar"); |
| 64 | 64 | $this->setLuceneDir(SYSTEM_DIR."bin".DS."luceneserver".DS); |
| 65 | 65 | $this->setIndexerDir(SYSTEM_DIR."search2".DS."indexing".DS."bin".DS); |
| ... | ... | @@ -148,14 +148,13 @@ class unixLucene extends unixService { |
| 148 | 148 | * @return array |
| 149 | 149 | */ |
| 150 | 150 | public function stop() { |
| 151 | - // TODO: Breaks things | |
| 152 | 151 | $state = $this->status(); |
| 153 | 152 | if($state != '') { |
| 154 | 153 | $cmd = "pkill -f ".$this->getLuceneSource(); |
| 155 | 154 | $response = $this->util->pexec($cmd); |
| 156 | 155 | return $response; |
| 157 | 156 | } |
| 158 | - | |
| 157 | + return $state; | |
| 159 | 158 | } |
| 160 | 159 | |
| 161 | 160 | public function install() { |
| ... | ... | @@ -173,6 +172,7 @@ class unixLucene extends unixService { |
| 173 | 172 | if(is_array($response['out'])) { |
| 174 | 173 | if(count($response['out']) > 1) { |
| 175 | 174 | foreach ($response['out'] as $r) { |
| 175 | + $matches = false; | |
| 176 | 176 | preg_match('/grep/', $r, $matches); // Ignore grep |
| 177 | 177 | if(!$matches) { |
| 178 | 178 | return 'STARTED'; |
| ... | ... | @@ -201,26 +201,20 @@ class unixLucene extends unixService { |
| 201 | 201 | public function start() { |
| 202 | 202 | $state = $this->status(); |
| 203 | 203 | if($state != 'STARTED') { |
| 204 | - $logFile = $this->outputDir."lucene.log"; | |
| 204 | + $logFile = $this->outputDir.DS."lucene.log"; | |
| 205 | 205 | @unlink($logFile); |
| 206 | 206 | $cmd = "cd ".$this->getLuceneDir()."; "; |
| 207 | 207 | $cmd .= "nohup java {$this->getJavaXmx()} {$this->getJavaXmx()} -jar ".$this->getLuceneSource()." > ".$logFile." 2>&1 & echo $!"; |
| 208 | 208 | if(DEBUG) { |
| 209 | 209 | echo "Command : $cmd<br/>"; |
| 210 | - return ; | |
| 210 | + return false; | |
| 211 | 211 | } |
| 212 | 212 | $response = $this->util->pexec($cmd); |
| 213 | 213 | |
| 214 | 214 | return $response; |
| 215 | - } elseif ($state == '') { | |
| 216 | - // Start Service | |
| 217 | - return true; | |
| 218 | - } else { | |
| 219 | - // Service Running Already | |
| 220 | - return true; | |
| 221 | 215 | } |
| 222 | 216 | |
| 223 | - return false; | |
| 217 | + return true; | |
| 224 | 218 | } |
| 225 | 219 | |
| 226 | 220 | public function getName() { | ... | ... |
setup/wizard/lib/services/unixOpenOffice.php
| ... | ... | @@ -106,13 +106,14 @@ class unixOpenOffice extends unixService { |
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - public function status($updrade = false) { | |
| 109 | + public function status() { | |
| 110 | 110 | sleep(1); |
| 111 | 111 | $cmd = "ps ax | grep soffice"; |
| 112 | 112 | $response = $this->util->pexec($cmd); |
| 113 | 113 | if(is_array($response['out'])) { |
| 114 | 114 | if(count($response['out']) > 1) { |
| 115 | 115 | foreach ($response['out'] as $r) { |
| 116 | + $matches = false; | |
| 116 | 117 | preg_match('/grep/', $r, $matches); // Ignore grep |
| 117 | 118 | if(!$matches) { |
| 118 | 119 | return 'STARTED'; |
| ... | ... | @@ -140,20 +141,13 @@ class unixOpenOffice extends unixService { |
| 140 | 141 | $cmd = "nohup ".$this->getBin().' -nofirststartwizard -nologo -headless -"accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" '." > /dev/null 2>&1 & echo $!"; |
| 141 | 142 | if(DEBUG) { |
| 142 | 143 | echo "Command : $cmd<br/>"; |
| 143 | - return ; | |
| 144 | + return false; | |
| 144 | 145 | } |
| 145 | - $response = $this->util->pexec($cmd); | |
| 146 | - | |
| 147 | - return $response; | |
| 148 | - } elseif ($state == '') { | |
| 149 | - // Start Service | |
| 150 | - return true; | |
| 151 | - } else { | |
| 152 | - // Service Running Already | |
| 153 | - return true; | |
| 146 | + | |
| 147 | + return $this->util->pexec($cmd); | |
| 154 | 148 | } |
| 155 | 149 | |
| 156 | - return false; | |
| 150 | + return true; | |
| 157 | 151 | } |
| 158 | 152 | |
| 159 | 153 | /** | ... | ... |
setup/wizard/lib/services/unixScheduler.php
| ... | ... | @@ -180,7 +180,7 @@ class unixScheduler extends unixService { |
| 180 | 180 | // TODO : Write sh on the fly? Not sure the reasoning here |
| 181 | 181 | $source = $this->getSchedulerSourceLoc(); |
| 182 | 182 | $this->writeSchedulerTask(); |
| 183 | - $logFile = $this->outputDir."scheduler.log"; | |
| 183 | + $logFile = $this->outputDir.DS."scheduler.log"; | |
| 184 | 184 | @unlink($logFile); |
| 185 | 185 | if($source) { // Source |
| 186 | 186 | $cmd = "nohup ".$source." > ".$logFile." 2>&1 & echo $!"; | ... | ... |
setup/wizard/lib/validation/openofficeValidation.php
| ... | ... | @@ -154,7 +154,7 @@ class openofficeValidation extends serviceValidation { |
| 154 | 154 | $bin = "soffice"; |
| 155 | 155 | } |
| 156 | 156 | foreach ($locations as $loc) { |
| 157 | - $pathToBinary = $loc.$bin; | |
| 157 | + $pathToBinary = $loc.DS.$bin; | |
| 158 | 158 | if(file_exists($pathToBinary)) { |
| 159 | 159 | return $pathToBinary; |
| 160 | 160 | } | ... | ... |
setup/wizard/resources/graphics/favicon.ico
0 โ 100644
No preview for this file type
setup/wizard/resources/graphics/greenit.jpg
0 โ 100644
35 KB
setup/wizard/resources/js/wizard.js
| ... | ... | @@ -4,14 +4,29 @@ function wizard() { |
| 4 | 4 | |
| 5 | 5 | // Toggle Advance Database options |
| 6 | 6 | wizard.prototype.toggleClass = function(ele, option) { //adv_options|php_details|php_ext_details|php_con_details |
| 7 | - if($('.'+ele).attr('style') == 'display: none;') { | |
| 8 | - $('.'+ele).attr('style', 'display: block;'); | |
| 9 | - if($('#'+option).attr('innerHTML') != ' Advanced Options') | |
| 10 | - $('#'+option).attr('innerHTML', 'Hide Details'); | |
| 11 | - } else { | |
| 12 | - $('.'+ele).attr('style', 'display: none;'); | |
| 13 | - if($('#'+option).attr('innerHTML') != ' Advanced Options') | |
| 14 | - $('#'+option).attr('innerHTML', 'Show Details'); | |
| 7 | + var style = $('.'+ele).attr('style'); | |
| 8 | + style = w.trim(style); | |
| 9 | + switch(style) { | |
| 10 | + case 'display: none;': | |
| 11 | + $('.'+ele).attr('style', 'display: block;'); | |
| 12 | + if($('#'+option).attr('innerHTML') != ' Advanced Options') | |
| 13 | + $('#'+option).attr('innerHTML', 'Hide Details'); | |
| 14 | + break; | |
| 15 | + case 'DISPLAY: none;': | |
| 16 | + $('.'+ele).attr('style', 'DISPLAY: block'); | |
| 17 | + if($('#'+option).attr('innerHTML') != ' Advanced Options') | |
| 18 | + $('#'+option).attr('innerHTML', 'Hide Details'); | |
| 19 | + break; | |
| 20 | + case 'display: block;': | |
| 21 | + $('.'+ele).attr('style', 'display: none;'); | |
| 22 | + if($('#'+option).attr('innerHTML') != ' Advanced Options') | |
| 23 | + $('#'+option).attr('innerHTML', 'Show Details'); | |
| 24 | + break; | |
| 25 | + case 'DISPLAY: block;': | |
| 26 | + $('.'+ele).attr('style', 'DISPLAY: none'); | |
| 27 | + if($('#'+option).attr('innerHTML') != ' Advanced Options') | |
| 28 | + $('#'+option).attr('innerHTML', 'Show Details'); | |
| 29 | + break; | |
| 15 | 30 | } |
| 16 | 31 | } |
| 17 | 32 | ... | ... |
setup/wizard/step.php
| ... | ... | @@ -117,17 +117,7 @@ class Step |
| 117 | 117 | */ |
| 118 | 118 | public $util; |
| 119 | 119 | |
| 120 | - /** | |
| 121 | - * Reference to utility object | |
| 122 | - * | |
| 123 | - * @author KnowledgeTree Team | |
| 124 | - * @access protected | |
| 125 | - * @var object | |
| 126 | - */ | |
| 127 | - public $dbhandler; | |
| 128 | - | |
| 129 | 120 | public function __construct() { |
| 130 | - $this->dbhandler = new dbUtilities(); | |
| 131 | 121 | $this->util = new InstallUtil(); |
| 132 | 122 | } |
| 133 | 123 | /** | ... | ... |
setup/wizard/steps/complete.php
| ... | ... | @@ -142,8 +142,8 @@ class complete extends Step { |
| 142 | 142 | // retrieve database information from session |
| 143 | 143 | $dbconf = $this->getDataFromSession("database"); |
| 144 | 144 | // make db connection - admin |
| 145 | - $this->dbhandler->load($dbconf['dhost'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']); | |
| 146 | - $loaded = $this->dbhandler->getDatabaseLink(); | |
| 145 | + $this->util->dbUtilities->load($dbconf['dhost'], $dbconf['dport'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']); | |
| 146 | + $loaded = $this->util->dbUtilities->getDatabaseLink(); | |
| 147 | 147 | if (!$loaded) { |
| 148 | 148 | $this->temp_variables['dbConnectAdmin'] .= '<td><div class="cross"></div></td>' |
| 149 | 149 | . '<td class="error">Unable to connect to database (user: ' |
| ... | ... | @@ -157,20 +157,20 @@ class complete extends Step { |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | // make db connection - user |
| 160 | - $this->dbhandler->load($dbconf['dhost'], $dbconf['dmsusername'], $dbconf['dmsuserpassword'], $dbconf['dname']); | |
| 161 | - $loaded = $this->dbhandler->getDatabaseLink(); | |
| 160 | + $this->util->dbUtilities->load($dbconf['dhost'], $dbconf['dport'], $dbconf['dmsusername'], $dbconf['dmsuserpassword'], $dbconf['dname']); | |
| 161 | + $loaded = $this->util->dbUtilities->getDatabaseLink(); | |
| 162 | 162 | // if we can log in to the database, check access |
| 163 | 163 | // TODO check write access? |
| 164 | 164 | if ($loaded) |
| 165 | 165 | { |
| 166 | 166 | $this->temp_variables['dbConnectUser'] .= sprintf($html, 'tick', '', 'Database connectivity successful (user: ' . $dbconf['dmsusername'] . ')'); |
| 167 | 167 | |
| 168 | - $qresult = $this->dbhandler->query('SELECT COUNT(id) FROM documents'); | |
| 168 | + $qresult = $this->util->dbUtilities->query('SELECT COUNT(id) FROM documents'); | |
| 169 | 169 | if (!$qresult) |
| 170 | 170 | { |
| 171 | 171 | $this->temp_variables['dbPrivileges'] .= '<td style="width:15px;"><div class="cross" style="float:left;"></div></td>' |
| 172 | 172 | . '<td class="error" style="width:500px;">' |
| 173 | - . 'Unable to do a basic database query. Error: ' . $this->dbhandler->getLastError() | |
| 173 | + . 'Unable to do a basic database query. Error: ' . $this->util->dbUtilities->getLastError() | |
| 174 | 174 | . '</td>'; |
| 175 | 175 | $this->privileges_check = 'cross'; |
| 176 | 176 | $this->privileges_check = 'cross'; |
| ... | ... | @@ -183,17 +183,17 @@ class complete extends Step { |
| 183 | 183 | |
| 184 | 184 | // check transaction support |
| 185 | 185 | $sTable = 'system_settings'; |
| 186 | - $this->dbhandler->startTransaction(); | |
| 187 | - $this->dbhandler->query('INSERT INTO ' . $sTable . ' (name, value) VALUES ("transactionTest", "1")'); | |
| 188 | - $this->dbhandler->rollback(); | |
| 189 | - $res = $this->dbhandler->query("SELECT id FROM $sTable WHERE name = 'transactionTest' LIMIT 1"); | |
| 186 | + $this->util->dbUtilities->startTransaction(); | |
| 187 | + $this->util->dbUtilities->query('INSERT INTO ' . $sTable . ' (name, value) VALUES ("transactionTest", "1")'); | |
| 188 | + $this->util->dbUtilities->rollback(); | |
| 189 | + $res = $this->util->dbUtilities->query("SELECT id FROM $sTable WHERE name = 'transactionTest' LIMIT 1"); | |
| 190 | 190 | if (!$res) { |
| 191 | 191 | $this->temp_variables['dbTransaction'] .= sprintf($html, 'cross', 'class="error"', 'Transaction support not available in database'); |
| 192 | 192 | $this->privileges_check = 'cross'; |
| 193 | 193 | } else { |
| 194 | 194 | $this->temp_variables['dbTransaction'] .= sprintf($html, 'tick', '', 'Database has transaction support'); |
| 195 | 195 | } |
| 196 | - $this->dbhandler->query('DELETE FROM ' . $sTable . ' WHERE name = "transactionTest"'); | |
| 196 | + $this->util->dbUtilities->query('DELETE FROM ' . $sTable . ' WHERE name = "transactionTest"'); | |
| 197 | 197 | } |
| 198 | 198 | else |
| 199 | 199 | { | ... | ... |
setup/wizard/steps/configuration.php
| ... | ... | @@ -307,41 +307,38 @@ class configuration extends Step |
| 307 | 307 | { |
| 308 | 308 | $conf = $this->getDataFromSession("configuration"); // get data from the server |
| 309 | 309 | $dbconf = $this->getDataFromSession("database"); |
| 310 | - $this->dbhandler->load($dbconf['dhost'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']); | |
| 310 | + $this->util->dbUtilities->load($dbconf['dhost'], $dbconf['dport'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']); | |
| 311 | 311 | $server = $conf['server']; |
| 312 | 312 | $paths = $conf['paths']; |
| 313 | 313 | if ($this->util->isMigration()) { // Check if its an upgrade |
| 314 | 314 | $this->readInstallation(); |
| 315 | - $configPath = $paths['configFile']['path']; | |
| 315 | + $this->confpaths['configIni'] = $paths['configFile']['path']; | |
| 316 | 316 | } else { |
| 317 | 317 | $this->readConfigPath(); // initialise writing to config.ini |
| 318 | 318 | } |
| 319 | 319 | $this->getFromConfigPath(); // Sets config Paths |
| 320 | - $ini = false; | |
| 321 | - if(file_exists($configPath)) { | |
| 322 | - $ini = new iniUtilities($configPath); | |
| 320 | + if(file_exists($this->confpaths['configIni'])) { | |
| 321 | + $this->util->iniUtilities->load($this->confpaths['configIni']); | |
| 323 | 322 | } |
| 324 | - $this->writeUrlSection($ini); | |
| 325 | - $this->writeDBSection($ini, $server); | |
| 326 | - $this->writeDBPathSection($ini, $paths); | |
| 327 | - if(!$ini === false){ // write out the config.ini file | |
| 328 | - $ini->write(); | |
| 323 | + if(!$this->util->iniUtilities=== false){ // write out the config.ini file | |
| 324 | + $this->writeUrlSection(); | |
| 325 | + $this->writeDBSection($server); | |
| 326 | + $this->writeDBPathSection($paths); | |
| 327 | + $this->util->iniUtilities->write(); | |
| 329 | 328 | } |
| 330 | - $this->dbhandler->close(); // close the database connection | |
| 331 | - $this->writeCachePath(); // Write cache path file | |
| 332 | - $this->writeConfigPath($configPath); // Write config file | |
| 329 | + $this->util->dbUtilities->close(); // close the database connection | |
| 330 | + $this->writeCachePath($this->getCachePath(), $paths['cacheDirectory']['path']); // Write cache path file | |
| 331 | + $this->writeConfigPath($this->getContentPath(), $this->confpaths['configIni']); // Write config file | |
| 333 | 332 | } |
| 334 | 333 | |
| 335 | - private function writeUrlSection($ini) { | |
| 334 | + private function writeUrlSection() { | |
| 336 | 335 | $directories = $this->registerDirs(); |
| 337 | 336 | foreach($directories as $item) { // write server settings to config_settings table and config.ini |
| 338 | - if(!$ini === false) { | |
| 339 | - $ini->updateItem($item['section'], $item['setting'], $item['value']); | |
| 340 | - } | |
| 337 | + $this->util->iniUtilities->updateItem($item['section'], $item['setting'], $item['value']); | |
| 341 | 338 | } |
| 342 | 339 | } |
| 343 | 340 | |
| 344 | - private function writeDBPathSection($ini, $paths) { | |
| 341 | + private function writeDBPathSection($paths) { | |
| 345 | 342 | $table = 'config_settings'; |
| 346 | 343 | if(is_array($paths)) { // write the paths to the config_settings table |
| 347 | 344 | foreach ($paths as $item){ |
| ... | ... | @@ -351,14 +348,14 @@ class configuration extends Step |
| 351 | 348 | $value = mysql_real_escape_string($item['path']); |
| 352 | 349 | $setting = mysql_real_escape_string($item['setting']); |
| 353 | 350 | $sql = "UPDATE {$table} SET value = '{$value}' WHERE item = '{$setting}'"; |
| 354 | - $this->dbhandler->query($sql); | |
| 351 | + $this->util->dbUtilities->query($sql); | |
| 355 | 352 | } |
| 356 | 353 | } |
| 357 | 354 | } |
| 358 | 355 | |
| 359 | - private function writeDBSection($ini, $server) { | |
| 356 | + private function writeDBSection($server) { | |
| 360 | 357 | $dbconf = $this->getDataFromSession("database"); // retrieve database information from session |
| 361 | - $this->dbhandler->load($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); // initialise the db connection | |
| 358 | + $this->util->dbUtilities->load($dbconf['dhost'], $dbconf['dport'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); // initialise the db connection | |
| 362 | 359 | $server = $this->registerDBConfig($server, $dbconf); // add db config to server variables |
| 363 | 360 | $table = 'config_settings'; |
| 364 | 361 | foreach($server as $item) { // write server settings to config_settings table and config.ini |
| ... | ... | @@ -371,16 +368,14 @@ class configuration extends Step |
| 371 | 368 | if($value == 'no'){ |
| 372 | 369 | $value = 'false'; |
| 373 | 370 | } |
| 374 | - if(!$ini === false){ | |
| 375 | - $ini->updateItem($item['section'], $item['setting'], $value); | |
| 376 | - } | |
| 371 | + $this->util->iniUtilities->updateItem($item['section'], $item['setting'], $value); | |
| 377 | 372 | break; |
| 378 | 373 | case 'db': |
| 379 | 374 | $value = mysql_real_escape_string($item['value']); |
| 380 | 375 | $setting = mysql_real_escape_string($item['setting']); |
| 381 | 376 | |
| 382 | 377 | $sql = "UPDATE {$table} SET value = '{$value}' WHERE item = '{$setting}'"; |
| 383 | - $this->dbhandler->query($sql); | |
| 378 | + $this->util->dbUtilities->query($sql); | |
| 384 | 379 | break; |
| 385 | 380 | } |
| 386 | 381 | } |
| ... | ... | @@ -578,15 +573,45 @@ class configuration extends Step |
| 578 | 573 | |
| 579 | 574 | public function readConfigPathIni() { |
| 580 | 575 | if(isset($this->temp_variables['paths']['configFile']['path'])) { |
| 581 | - return $this->temp_variables['paths']['configFile']['path']; | |
| 576 | + if($this->temp_variables['paths']['configFile']['path'] != '') | |
| 577 | + return $this->temp_variables['paths']['configFile']['path']; | |
| 582 | 578 | } |
| 583 | 579 | $configPath = $this->getContentPath(); |
| 584 | - if(!$configPath) return false; | |
| 585 | - $ini = new iniUtilities($configPath); | |
| 586 | - $data = $ini->getFileByLine(); | |
| 580 | + if(!$configPath) { | |
| 581 | + return false; | |
| 582 | + } | |
| 583 | + $this->util->iniUtilities->load($configPath); | |
| 584 | + $data = $this->util->iniUtilities->getFileByLine(); | |
| 587 | 585 | $firstline = true; |
| 588 | 586 | foreach ($data as $k=>$v) { |
| 589 | 587 | if(preg_match('/config.ini/', $k)) { // Find config.ini |
| 588 | + if($k == "config/config.ini") { // Source install and source upgrades | |
| 589 | + $configIniPath = realpath(SYSTEM_DIR.$k); | |
| 590 | + if($configIniPath) | |
| 591 | + return $configIniPath; | |
| 592 | + } | |
| 593 | + return $k; | |
| 594 | + } | |
| 595 | + } | |
| 596 | + | |
| 597 | + return false; | |
| 598 | + } | |
| 599 | + | |
| 600 | + public function readCachePath() { | |
| 601 | + $cachePath = $this->getCachePath(); | |
| 602 | + if(!$cachePath) { | |
| 603 | + return false; | |
| 604 | + } | |
| 605 | + $this->util->iniUtilities->load($cachePath); | |
| 606 | + $data = $this->util->iniUtilities->getFileByLine(); | |
| 607 | + $firstline = true; | |
| 608 | + foreach ($data as $k=>$v) { | |
| 609 | + if(preg_match('/cache/', $k)) { // Find config.ini | |
| 610 | + if($k == "var/cache") { // Source install and source upgrades | |
| 611 | + $configIniPath = realpath(SYSTEM_DIR.$k); | |
| 612 | + if($configIniPath) | |
| 613 | + return $configIniPath; | |
| 614 | + } | |
| 590 | 615 | return $k; |
| 591 | 616 | } |
| 592 | 617 | } |
| ... | ... | @@ -605,8 +630,8 @@ class configuration extends Step |
| 605 | 630 | private function readConfigPath() { |
| 606 | 631 | $configPath = $this->getContentPath(); |
| 607 | 632 | if(!$configPath) return false; |
| 608 | - $ini = new iniUtilities($configPath); | |
| 609 | - $data = $ini->getFileByLine(); | |
| 633 | + $this->util->iniUtilities->load($configPath); | |
| 634 | + $data = $this->util->iniUtilities->getFileByLine(); | |
| 610 | 635 | $firstline = true; |
| 611 | 636 | foreach ($data as $k=>$v) { |
| 612 | 637 | if($firstline) { // First line holds the var directory |
| ... | ... | @@ -645,46 +670,48 @@ class configuration extends Step |
| 645 | 670 | * @param none |
| 646 | 671 | * @return boolean |
| 647 | 672 | */ |
| 648 | - private function writeConfigPath($configPath = '') { | |
| 649 | - $conf = $this->getDataFromSession("configuration"); // get data from the server | |
| 650 | - $paths = $conf['paths']; | |
| 651 | - if(isset($paths['configFile']['path'])) { | |
| 652 | - $configPath = $this->getContentPath(); | |
| 653 | - $configContent = $paths['configFile']['path']; | |
| 654 | - } else { | |
| 655 | - $configPath = $this->getContentPath(); | |
| 656 | - if(!$configPath) return false; | |
| 657 | - $ini = new iniUtilities($configPath); | |
| 658 | - $data = $ini->getFileByLine(); | |
| 659 | - $configContent = ''; | |
| 660 | - foreach ($data as $k=>$v) { | |
| 661 | - if(preg_match('/config.ini/', $k)) { | |
| 662 | - $configContent = $k; | |
| 663 | - break; | |
| 664 | - } | |
| 665 | - } | |
| 666 | - } | |
| 667 | - $fp = fopen($configPath, 'w'); | |
| 673 | + private function writeConfigPath($configPath, $configContent) { | |
| 674 | +// $conf = $this->getDataFromSession("configuration"); // get data from the server | |
| 675 | +// $paths = $conf['paths']; | |
| 676 | +// if(isset($paths['configFile']['path'])) { | |
| 677 | +// $configPath = $this->getContentPath(); | |
| 678 | +// $configContent = $paths['configFile']['path']; | |
| 679 | +// } else { | |
| 680 | +// $configPath = $this->getContentPath(); | |
| 681 | +// if(!$configPath) return false; | |
| 682 | +// $this->util->iniHandler->load($configPath); | |
| 683 | +// $data = $this->util->iniHandler->getFileByLine(); | |
| 684 | +// $configContent = ''; | |
| 685 | +// foreach ($data as $k=>$v) { | |
| 686 | +// if(preg_match('/config.ini/', $k)) { | |
| 687 | +// $configContent = $k; | |
| 688 | +// break; | |
| 689 | +// } | |
| 690 | +// } | |
| 691 | +// } | |
| 692 | +// print_r($configPath); | |
| 693 | +// print_r($configContent); | |
| 694 | + $fp = fopen($configPath, 'w+'); | |
| 668 | 695 | if(fwrite($fp, $configContent)) |
| 669 | 696 | return true; |
| 670 | 697 | return false; |
| 671 | 698 | } |
| 672 | 699 | |
| 673 | - private function writeCachePath() { | |
| 674 | - $cachePath = $this->getCachePath(); | |
| 675 | - if(!$cachePath) return false; | |
| 676 | - $configPath = $this->getContentPath(); | |
| 677 | - if(!$configPath) return false; | |
| 678 | - $ini = new iniUtilities($configPath); | |
| 679 | - $data = $ini->getFileByLine(); | |
| 680 | - $cacheContent = ''; | |
| 681 | - foreach ($data as $k=>$v) { | |
| 682 | - if(preg_match('/cache/', $k)) { | |
| 683 | - $cacheContent = $k; | |
| 684 | - break; | |
| 685 | - } | |
| 686 | - } | |
| 687 | - $fp = fopen($cachePath, 'w'); | |
| 700 | + private function writeCachePath($cachePath, $cacheContent) { | |
| 701 | +// $cachePath = $this->getCachePath(); | |
| 702 | +// if(!$cachePath) return false; | |
| 703 | +// $configPath = $this->getContentPath(); | |
| 704 | +// if(!$configPath) return false; | |
| 705 | +// $this->util->iniHandler->load($configPath); | |
| 706 | +// $data = $this->util->iniHandler->getFileByLine(); | |
| 707 | +// $cacheContent = ''; | |
| 708 | +// foreach ($data as $k=>$v) { | |
| 709 | +// if(preg_match('/cache/', $k)) { | |
| 710 | +// $cacheContent = $k; | |
| 711 | +// break; | |
| 712 | +// } | |
| 713 | +// } | |
| 714 | + $fp = fopen($cachePath, 'w+'); | |
| 688 | 715 | if($cacheContent != '') { |
| 689 | 716 | if(fwrite($fp, $cacheContent)) |
| 690 | 717 | return true; | ... | ... |
setup/wizard/steps/database.php
| ... | ... | @@ -319,12 +319,12 @@ class database extends Step |
| 319 | 319 | $this->error['dmsuserpassword'] = "Passwords do not match: " . $this->dmsuserpassword." ". $this->getPassword2(); |
| 320 | 320 | return false; |
| 321 | 321 | } |
| 322 | - if($this->dport == '') { | |
| 323 | - $this->dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); | |
| 324 | - } else { | |
| 325 | - $this->dbhandler->load($this->dhost.":".$this->dport, $this->duname, $this->dpassword, $this->dname); | |
| 326 | - } | |
| 327 | - if (!$this->dbhandler->getDatabaseLink()) { | |
| 322 | +// if($this->dport == '') { | |
| 323 | +// $this->util->dbUtilities->load($this->dhost, $this->duname, $this->dpassword, $this->dname); | |
| 324 | +// } else { | |
| 325 | + $this->util->dbUtilities->load($this->dhost, $this->dport, $this->duname, $this->dpassword, $this->dname); | |
| 326 | +// } | |
| 327 | + if (!$this->util->dbUtilities->getDatabaseLink()) { | |
| 328 | 328 | $this->error['con'] = "Could not connect to the database, please check username and password"; |
| 329 | 329 | return false; |
| 330 | 330 | } else { |
| ... | ... | @@ -339,7 +339,7 @@ class database extends Step |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | public function dbExists() { |
| 342 | - return $this->dbhandler->useDb(); | |
| 342 | + return $this->util->dbUtilities->useDb(); | |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | public function match($str1, $str2) { |
| ... | ... | @@ -500,7 +500,6 @@ class database extends Step |
| 500 | 500 | * @return object SimpleXmlObject |
| 501 | 501 | */ |
| 502 | 502 | public function readXml() { |
| 503 | -// echo CONF_DIR."databases.xml"; | |
| 504 | 503 | $simplexml = simplexml_load_file(CONF_DIR."databases.xml"); |
| 505 | 504 | |
| 506 | 505 | return $simplexml; |
| ... | ... | @@ -583,7 +582,7 @@ class database extends Step |
| 583 | 582 | * @return object mysql connection |
| 584 | 583 | */ |
| 585 | 584 | private function connectMysql() { |
| 586 | - $this->dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); | |
| 585 | + $this->util->dbUtilities->load($this->dhost, $this->dport, $this->duname, $this->dpassword, $this->dname); | |
| 587 | 586 | } |
| 588 | 587 | |
| 589 | 588 | /** |
| ... | ... | @@ -642,7 +641,7 @@ class database extends Step |
| 642 | 641 | $this->error['con'] = "Could not create database: "; |
| 643 | 642 | } |
| 644 | 643 | } |
| 645 | - $this->dbhandler->clearErrors(); | |
| 644 | + $this->util->dbUtilities->clearErrors(); | |
| 646 | 645 | if(!$this->createDmsUser()) { // Create dms users |
| 647 | 646 | $this->error['con'] = "Could not create database users "; |
| 648 | 647 | } |
| ... | ... | @@ -666,8 +665,7 @@ class database extends Step |
| 666 | 665 | */ |
| 667 | 666 | private function create() { |
| 668 | 667 | $sql = "CREATE DATABASE {$this->dname}"; |
| 669 | - if ($this->dbhandler->query($sql)) { | |
| 670 | - | |
| 668 | + if ($this->util->dbUtilities->query($sql)) { | |
| 671 | 669 | return true; |
| 672 | 670 | } |
| 673 | 671 | |
| ... | ... | @@ -683,7 +681,7 @@ class database extends Step |
| 683 | 681 | * @return boolean |
| 684 | 682 | */ |
| 685 | 683 | private function usedb() { |
| 686 | - if($this->dbhandler->useDb()) { | |
| 684 | + if($this->util->dbUtilities->useDb()) { | |
| 687 | 685 | return true; |
| 688 | 686 | } else { |
| 689 | 687 | $this->error['con'] = "Error using database: {$this->dname}"; |
| ... | ... | @@ -702,7 +700,7 @@ class database extends Step |
| 702 | 700 | private function dropdb() { |
| 703 | 701 | if($this->ddrop) { |
| 704 | 702 | $sql = "DROP DATABASE {$this->dname};"; |
| 705 | - if(!$this->dbhandler->query($sql)) { | |
| 703 | + if(!$this->util->dbUtilities->query($sql)) { | |
| 706 | 704 | $this->error['con'] = "Cannot drop database: {$this->dname}"; |
| 707 | 705 | return false; |
| 708 | 706 | } |
| ... | ... | @@ -724,7 +722,7 @@ class database extends Step |
| 724 | 722 | private function createDmsUser() { |
| 725 | 723 | $user1 = "GRANT SELECT, INSERT, UPDATE, DELETE ON {$this->dname}.* TO {$this->dmsusername}@{$this->dhost} IDENTIFIED BY \"{$this->dmsuserpassword}\";"; |
| 726 | 724 | $user2 = "GRANT ALL PRIVILEGES ON {$this->dname}.* TO {$this->dmsname}@{$this->dhost} IDENTIFIED BY \"{$this->dmspassword}\";"; |
| 727 | - if ($this->dbhandler->query($user1) && $this->dbhandler->query($user2)) { | |
| 725 | + if ($this->util->dbUtilities->query($user1) && $this->util->dbUtilities->query($user2)) { | |
| 728 | 726 | return true; |
| 729 | 727 | } else { |
| 730 | 728 | $this->error['con'] = "Could not create users for database: {$this->dname}"; |
| ... | ... | @@ -751,7 +749,7 @@ class database extends Step |
| 751 | 749 | while (!feof($handle)) { |
| 752 | 750 | $query.= fgets($handle, 4096); |
| 753 | 751 | if (substr(rtrim($query), -1) == ';') { |
| 754 | - $this->dbhandler->query($query); | |
| 752 | + $this->util->dbUtilities->query($query); | |
| 755 | 753 | $query = ''; |
| 756 | 754 | } |
| 757 | 755 | } |
| ... | ... | @@ -778,9 +776,9 @@ class database extends Step |
| 778 | 776 | $sqlFile = $dbMigrate['dumpLocation']; |
| 779 | 777 | $this->parse_mysql_dump($sqlFile); |
| 780 | 778 | $dropPluginHelper = "TRUNCATE plugin_helper;"; |
| 781 | - $this->dbhandler->query($dropPluginHelper); | |
| 779 | + $this->util->dbUtilities->query($dropPluginHelper); | |
| 782 | 780 | $updateUrls = 'UPDATE config_settings c SET c.value = "default" where c.group_name = "urls";'; |
| 783 | - $this->dbhandler->query($updateUrls); | |
| 781 | + $this->util->dbUtilities->query($updateUrls); | |
| 784 | 782 | return true; |
| 785 | 783 | } |
| 786 | 784 | /** |
| ... | ... | @@ -793,7 +791,7 @@ class database extends Step |
| 793 | 791 | */ |
| 794 | 792 | private function closeMysql() { |
| 795 | 793 | try { |
| 796 | - $this->dbhandler->close(); | |
| 794 | + $this->util->dbUtilities->close(); | |
| 797 | 795 | } catch (Exeption $e) { |
| 798 | 796 | $this->error['con'] = "Could not close: " . $e; |
| 799 | 797 | } |
| ... | ... | @@ -844,7 +842,7 @@ class database extends Step |
| 844 | 842 | $this->dpassword = 'root'; |
| 845 | 843 | $this->dname = 'dms_install'; |
| 846 | 844 | $this->dbbinary = 'mysql'; |
| 847 | - $this->dbhandler->load($this->dhost, $this->duname, $this->dpassword, $this->dname); | |
| 845 | + $this->util->dbUtilities->load($this->dhost, '', $this->duname, $this->dpassword, $this->dname); | |
| 848 | 846 | $this->createSchema(); |
| 849 | 847 | echo 'Schema loaded<br>'; |
| 850 | 848 | } | ... | ... |
setup/wizard/steps/install.php
| ... | ... | @@ -107,14 +107,14 @@ class install extends step |
| 107 | 107 | public function callHome() { |
| 108 | 108 | $conf = $this->getDataFromSession("install"); // retrieve database information from session |
| 109 | 109 | $dbconf = $this->getDataFromSession("database"); |
| 110 | - $this->dbhandler->load($dbconf['dhost'], $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); // initialise the db connection | |
| 110 | + $this->util->dbUtilities->load($dbconf['dhost'], '', $dbconf['duname'], $dbconf['dpassword'], $dbconf['dname']); // initialise the db connection | |
| 111 | 111 | $complete = 1; |
| 112 | 112 | if($conf['call_home'] == 'enable'){ |
| 113 | 113 | $complete = 0; |
| 114 | 114 | } |
| 115 | 115 | $query = "UPDATE scheduler_tasks SET is_complete = {$complete} WHERE task = 'Call Home'"; |
| 116 | - $this->dbhandler->query($query); | |
| 117 | - $this->dbhandler->close(); // close the database connection | |
| 116 | + $this->util->dbUtilities->query($query); | |
| 117 | + $this->util->dbUtilities->close(); // close the database connection | |
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | ?> |
| 121 | 121 | \ No newline at end of file | ... | ... |
setup/wizard/template.php
| ... | ... | @@ -96,6 +96,8 @@ class Template |
| 96 | 96 | public function fetch($file = null) |
| 97 | 97 | { |
| 98 | 98 | if (is_null($file)) $file = $this->file; |
| 99 | + | |
| 100 | + $file = WIZARD_DIR . $file; | |
| 99 | 101 | if (!file_exists($file)) { |
| 100 | 102 | trigger_error('Template file '.$file.' does not exist ', E_USER_ERROR); |
| 101 | 103 | } | ... | ... |
setup/wizard/templates/complete.tpl
| ... | ... | @@ -136,13 +136,13 @@ |
| 136 | 136 | <?php if($migrate_check) { ?> |
| 137 | 137 | <a href="../upgrade/index.php" class="back button_next" style="width:190px;" onclick="javascript:{w.clearSessions();}">Goto Database Upgrade</a> |
| 138 | 138 | <?php } else { ?> |
| 139 | - <a href="../../login.php?redirect=<?php echo $redirect; ?>" class="back button_next" style="width:90px;" onclick="javascript:{w.clearSessions();}">Goto Login</a> | |
| 139 | + <a href="../../login.php?" class="back button_next" style="width:90px;" onclick="javascript:{w.clearSessions();}">Goto Login</a> | |
| 140 | 140 | <?php } ?> |
| 141 | 141 | <?php |
| 142 | 142 | if ($install_environment == 'Zend') { |
| 143 | 143 | ?> |
| 144 | 144 | <!-- <input type="submit" name="type" value="Zend Server Configuration" class="button_previous"/>--> |
| 145 | - <a href="<?php echo "http://".$_SERVER['HTTP_HOST'].":10081/ZendServer/Index"; ?>" class="back" target="_blank" onclick="javascript:{w.clearSessions();}">Zend Server Configuration</a> | |
| 145 | +<!-- <a href="<?php //echo "http://".$_SERVER['HTTP_HOST'].":10081/ZendServer/Index"; ?>" class="back" target="_blank" onclick="javascript:{w.clearSessions();}">Zend Server Configuration</a>--> | |
| 146 | 146 | <?php |
| 147 | 147 | } |
| 148 | 148 | ?> | ... | ... |
setup/wizard/templates/error.tpl
| 1 | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 2 | 2 | <html> |
| 3 | 3 | <head> |
| 4 | + <link rel="shortcut icon" href="../wizard/resources/graphics/favicon.ico" type="image/x-icon"> | |
| 4 | 5 | <title>KnowledgeTree Installer</title> |
| 5 | 6 | <script type="text/javascript" src="resources/js/jquery-tooltip/lib/jquery.js"></script> |
| 6 | 7 | <script type="text/javascript" src="resources/js/wizard.js" ></script> |
| ... | ... | @@ -15,7 +16,7 @@ |
| 15 | 16 | <div id="logo"><img src="resources/graphics/dame/installer-header_logo.png"/></div> |
| 16 | 17 | <div id="install_details"> |
| 17 | 18 | <span style="font-size:120%;"> 3.7 </span> |
| 18 | - <span style="font-size:80%;">Commercial Edition</span> | |
| 19 | + <span style="font-size:80%;">Community Edition</span> | |
| 19 | 20 | </div> |
| 20 | 21 | </div> |
| 21 | 22 | <div id="wrapper"> | ... | ... |
setup/wizard/templates/install.tpl
| ... | ... | @@ -5,12 +5,10 @@ |
| 5 | 5 | <p class="empty_space"> |
| 6 | 6 | We would greatly appreciate it if you would allow us to collect anonymous usage statistics to help us provide a better quality product. The information includes a unique identification number, number of users you have created, your operating system type and your IP address. Your privacy is protected by the <a href="http://www.knowledgetree.com/about/legal" target="_blank">KnowledgeTree Privacy and Data Protection Agreements.</a> |
| 7 | 7 | </p> |
| 8 | - <p class="empty_space""> | |
| 9 | - KnowledgeTree, in partnership with <a href="http://www.trees.co.za/" target="_blank">Food & Trees for Africa</a>, and as a contributor to the National Tree Distribution Program, will also commit to planting one tree in Africa for every 1000 vertified installations of the product. | |
| 10 | - </p> | |
| 11 | - <div class="demo"><?php echo $html->image('img_fatlogo.jpg'); ?></div> | |
| 8 | + <div class="demo"><?php echo $html->image('greenit.jpg'); ?></div> | |
| 12 | 9 | <br/><br/> |
| 13 | - <p><input type='checkbox' name='call_home' value='enable' checked /> Help to improve KnowledgeTree by providing anonymous usage statistics</p> | |
| 10 | +<p> <input class="" type='checkbox' name='call_home' value='enable' checked style="float:left;"/> | |
| 11 | + Help to improve KnowledgeTree by providing anonymous usage statistics</p> | |
| 14 | 12 | </div> |
| 15 | 13 | <input type="submit" name="Previous" value="Previous" class="button_previous"/> |
| 16 | 14 | <input type="submit" name="Install" value="Install" class="button_next"/> | ... | ... |
setup/wizard/templates/welcome.tpl
| ... | ... | @@ -4,7 +4,7 @@ |
| 4 | 4 | <p class="empty_space"> This wizard will lead you through all the steps required to install and configure KnowledgeTree on your server.</p> |
| 5 | 5 | <p class="empty_space"> |
| 6 | 6 | Press <b>Next</b> to continue.</p> |
| 7 | - <div class="demo"><?php echo $html->image('kt_browse.png'); ?> </div> | |
| 7 | + <div class="demo"><?php //echo $html->image('kt_browse.png'); ?> </div> | |
| 8 | 8 | </div> |
| 9 | 9 | <input type="submit" name="Next" value="Next" class="button_next"/> |
| 10 | 10 | <!-- <input type="submit" name="Migrate" value="Migrate" class="button_next"/>--> | ... | ... |
setup/wizard/templates/wizard.tpl
| 1 | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 2 | 2 | <html> |
| 3 | 3 | <head> |
| 4 | + <link rel="shortcut icon" href="../wizard/resources/graphics/favicon.ico" type="image/x-icon"> | |
| 4 | 5 | <title>KnowledgeTree Installer</title> |
| 5 | 6 | <?php echo $html->js('jquery.js'); ?> |
| 6 | 7 | <?php echo $html->js('jquery.form.js'); ?> | ... | ... |
templates/ktcore/forms/widgets/date.smarty
| 1 | 1 | <!-------------------------------------- |
| 2 | 2 | ---- Changes for Custom Fields ----- |
| 3 | 3 | --------------------------------------> |
| 4 | -<div name="div_{$name}" id="div_{$name}" class="kt_date_field"></div> | |
| 4 | +<div name="{$name}" id="div_{$name}" class="kt_date_field"></div> | |
| 5 | 5 | |
| 6 | 6 | {literal} |
| 7 | 7 | <script type="text/javascript"> | ... | ... |
thirdparty/Smarty/internals/core.write_compiled_resource.php
| ... | ... | @@ -17,7 +17,7 @@ function smarty_core_write_compiled_resource($params, &$smarty) |
| 17 | 17 | if(!@is_writable($smarty->compile_dir)) { |
| 18 | 18 | // compile_dir not writable, see if it exists |
| 19 | 19 | if(!@is_dir($smarty->compile_dir)) { |
| 20 | - $smarty->trigger_error('the $compile_dir ' . $smarty->compile_dir . ' does not exist, or is not a directory.', E_USER_ERROR); | |
| 20 | + $smarty->trigger_error('the '.$compile_dir.' ' . $smarty->compile_dir . ' does not exist, or is not a directory.', E_USER_ERROR); | |
| 21 | 21 | return false; |
| 22 | 22 | } |
| 23 | 23 | $smarty->trigger_error('unable to write to $compile_dir \'' . realpath($smarty->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR); | ... | ... |
webservice/clienttools/services/0.2/kt.php
| ... | ... | @@ -362,12 +362,8 @@ class kt extends client_service { |
| 362 | 362 | $items[]=array("name"=>"__document_extension", "index"=>0, "value"=>strtolower($fileParts['extension']), "control_type"=>"lookup", "selection"=>explode(',', str_replace('.', '', $params['extensions']))); |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - $document_types=$this->get_documenttypes($params); | |
| 366 | - $json_document_types=array(); | |
| 367 | - foreach($document_types['items'] as $val) { | |
| 368 | - $json_document_types[]=$val['name']; | |
| 369 | - } | |
| 370 | - $items[]=array("name"=>"__document_type", "index"=>0, "value"=>$document_type, "control_type"=>"lookup", "selection"=>$json_document_types); | |
| 365 | + $document_types=$kt->get_documenttypes($params); | |
| 366 | + $items[]=array("name"=>"__document_type", "index"=>0, "value"=>$document_type, "control_type"=>"lookup", "selection"=>$document_types); | |
| 371 | 367 | |
| 372 | 368 | foreach ($detail as $fieldset) { |
| 373 | 369 | foreach ($fieldset['fields'] as $field) { |
| ... | ... | @@ -605,9 +601,10 @@ class kt extends client_service { |
| 605 | 601 | $filename=$params['filename']; |
| 606 | 602 | $reason=$params['reason']; |
| 607 | 603 | $tempfilename=$params['tempfilename']; |
| 604 | + $major_update=$params['major_update']; | |
| 608 | 605 | $application=$this->AuthInfo['appType']; |
| 609 | 606 | |
| 610 | - $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)"); | |
| 611 | 608 | $kt=&$this->KT; |
| 612 | 609 | |
| 613 | 610 | // we need to add some security to ensure that people don't frig the checkin process to access restricted files. |
| ... | ... | @@ -626,7 +623,7 @@ class kt extends client_service { |
| 626 | 623 | } |
| 627 | 624 | |
| 628 | 625 | // checkin |
| 629 | - $result=$document->checkin($filename, $reason, $tempfilename, false); | |
| 626 | + $result=$document->checkin($filename, $reason, $tempfilename, $major_update); | |
| 630 | 627 | if (PEAR::isError($result)) |
| 631 | 628 | { |
| 632 | 629 | $this->setResponse(array('status_code'=>14)); |
| ... | ... | @@ -682,7 +679,7 @@ class kt extends client_service { |
| 682 | 679 | $status_code=$update_result['status_code']; |
| 683 | 680 | if ($status_code != 0) |
| 684 | 681 | { |
| 685 | - $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'])); | |
| 686 | 683 | $this->response= $update_result; |
| 687 | 684 | } |
| 688 | 685 | |
| ... | ... | @@ -743,6 +740,43 @@ class kt extends client_service { |
| 743 | 740 | $this->setResponse($finalArray); |
| 744 | 741 | return true; |
| 745 | 742 | } |
| 743 | + | |
| 744 | + function get_all_explorer_policies(){ | |
| 745 | + $config=KTConfig::getSingleton(); | |
| 746 | + $this->addDebug('KTConfig Singleton',$config); | |
| 747 | + | |
| 748 | + $policies=array('allowRememberPassword', 'explorerMetadataCapture', 'officeMetadataCapture', 'captureReasonsCheckin', 'captureReasonsCheckout', 'captureReasonsDelete', 'captureReasonsCancelCheckout', 'captureReasonsCopyInKT', 'captureReasonsMoveInKT'); | |
| 749 | + | |
| 750 | + $returnPolicies=array(); | |
| 751 | + $test = $config->get('clientToolPolicies/allowRememberPassword'); | |
| 752 | + global $default; | |
| 753 | + $default->log->error('I am here-'.$test); | |
| 754 | + foreach ($policies as $policy_name) | |
| 755 | + { | |
| 756 | + $policyInfo=array( | |
| 757 | + 'name'=>$policy_name, | |
| 758 | + 'value'=>serviceHelper::bool2str($config->get('clientToolPolicies/'.$policy_name)), | |
| 759 | + 'type'=>'boolean' | |
| 760 | + ); | |
| 761 | + | |
| 762 | + $returnPolicies[$policy_name] =$policyInfo; | |
| 763 | + } | |
| 764 | + | |
| 765 | + $languages=$this->get_languages(true); | |
| 766 | + | |
| 767 | + $metadata=array('totalProperty'=>'resultsCounter', 'root'=>'languages', 'fields'=>array('isoCode', 'language')); | |
| 768 | + | |
| 769 | + $finalArray=array(); | |
| 770 | + $finalArray['metaData']=$metadata; | |
| 771 | + $finalArray['policies']=$returnPolicies; | |
| 772 | + $finalArray['languages']=$languages['languages']; | |
| 773 | + $finalArray['defaultLanguage']=$languages['defaultLanguage']; | |
| 774 | + $finalArray['resultsCounter']=$languages['count']; | |
| 775 | + | |
| 776 | + | |
| 777 | + $this->setResponse($finalArray); | |
| 778 | + return true; | |
| 779 | + } | |
| 746 | 780 | |
| 747 | 781 | public function switchlang($params){ |
| 748 | 782 | setcookie("kt_language", $params['lang'], 2147483647, '/'); |
| ... | ... | @@ -793,7 +827,12 @@ class kt extends client_service { |
| 793 | 827 | $this->setResponse($detail); |
| 794 | 828 | } |
| 795 | 829 | |
| 796 | - 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 | + | |
| 797 | 836 | $kt=&$this->KT; |
| 798 | 837 | |
| 799 | 838 | $document=&$kt->get_document_by_id($document_id); |
| ... | ... | @@ -1082,7 +1121,7 @@ class kt extends client_service { |
| 1082 | 1121 | function copydocument($params){ |
| 1083 | 1122 | $kt=&$this->KT; |
| 1084 | 1123 | |
| 1085 | - $response=$kt->copy_document($params['documentid'], $params['destfolderid']); | |
| 1124 | + $response=$kt->copy_document($params['documentid'], $params['destfolderid'], $params['reason']); | |
| 1086 | 1125 | if ($response['status_code']==0) { |
| 1087 | 1126 | $this->setResponse(array('status_code'=>0, 'status'=>'itemupdated', 'icon'=>'success', 'title'=>$this->xlate('Document Copied'), 'message'=>$this->xlate('Document has been successfully copied'))); |
| 1088 | 1127 | return true; |
| ... | ... | @@ -1095,7 +1134,7 @@ class kt extends client_service { |
| 1095 | 1134 | function movedocument($params){ |
| 1096 | 1135 | $kt=$this->KT; |
| 1097 | 1136 | |
| 1098 | - $response=$kt->move_document($params['documentid'], $params['destfolderid']); | |
| 1137 | + $response=$kt->move_document($params['documentid'], $params['destfolderid'], $params['reason']); | |
| 1099 | 1138 | if ($response['status_code']==0) { |
| 1100 | 1139 | $this->setResponse(array('status_code'=>0, 'status'=>'itemupdated', 'icon'=>'success', 'title'=>$this->xlate('Document Moved'), 'message'=>$this->xlate('Document has been successfully moved'))); |
| 1101 | 1140 | return true; |
| ... | ... | @@ -1109,7 +1148,7 @@ class kt extends client_service { |
| 1109 | 1148 | function copyfolder($params){ |
| 1110 | 1149 | $kt=&$this->KT; |
| 1111 | 1150 | |
| 1112 | - $response=$kt->copy_folder($params['sourcefolderid'], $params['destfolderid']); | |
| 1151 | + $response=$kt->copy_folder($params['sourcefolderid'], $params['destfolderid'], $params['reason']); | |
| 1113 | 1152 | if ($response['status_code']==0) { |
| 1114 | 1153 | $this->setResponse(array('status_code'=>0, 'status'=>'itemupdated', 'icon'=>'success', 'title'=>$this->xlate('Folder Copied'), 'message'=>$this->xlate('Folder has been successfully copied'))); |
| 1115 | 1154 | return true; |
| ... | ... | @@ -1123,7 +1162,7 @@ class kt extends client_service { |
| 1123 | 1162 | function movefolder($params){ |
| 1124 | 1163 | $kt=&$this->KT; |
| 1125 | 1164 | |
| 1126 | - $response=$kt->move_folder($params['sourcefolderid'], $params['destfolderid']); | |
| 1165 | + $response=$kt->move_folder($params['sourcefolderid'], $params['destfolderid'], $params['reason']); | |
| 1127 | 1166 | if ($response['status_code']==0) { |
| 1128 | 1167 | $this->setResponse(array('status_code'=>0, 'status'=>'itemupdated', 'icon'=>'success', 'title'=>$this->xlate('Folder Moved'), 'message'=>$this->xlate('Folder has been successfully moved'))); |
| 1129 | 1168 | return true; |
| ... | ... | @@ -1158,7 +1197,7 @@ class kt extends client_service { |
| 1158 | 1197 | function deletefolder($params){ |
| 1159 | 1198 | $kt=&$this->KT; |
| 1160 | 1199 | |
| 1161 | - $response=$kt->delete_folder($params['folderid'], 'Deleted from office addin'); | |
| 1200 | + $response=$kt->delete_folder($params['folderid'], $params['reason']); | |
| 1162 | 1201 | if ($response['status_code']==0) { |
| 1163 | 1202 | $this->setResponse(array('status_code'=>0, 'status'=>'folderdeleted', 'icon'=>'success', 'title'=>$this->xlate('Folder Deleted'), 'message'=>$this->xlate('Folder has been successfully deleted'))); |
| 1164 | 1203 | return true; | ... | ... |