Commit e6210b1273822d47f4321d3cecb7aa981a4cf0c7
Merge branch 'edge' of git@github.com:ktgit/knowledgetree into edge
Showing
21 changed files
with
1048 additions
and
80 deletions
plugins/multiselect/BulkImport.php
100644 → 100755
| @@ -292,14 +292,17 @@ class InetBulkImportFolderMultiSelectAction extends KTFolderAction { | @@ -292,14 +292,17 @@ class InetBulkImportFolderMultiSelectAction extends KTFolderAction { | ||
| 292 | // name='metadata[fieldset][metadata_9]' | 292 | // name='metadata[fieldset][metadata_9]' |
| 293 | 293 | ||
| 294 | $aData = $_REQUEST['data']; | 294 | $aData = $_REQUEST['data']; |
| 295 | + $data = $aData; | ||
| 295 | 296 | ||
| 297 | + /* | ||
| 296 | $oForm = $this->getBulkImportForm(); | 298 | $oForm = $this->getBulkImportForm(); |
| 297 | $res = $oForm->validate(); | 299 | $res = $oForm->validate(); |
| 298 | if (!empty($res['errors'])) { | 300 | if (!empty($res['errors'])) { |
| 299 | return $oForm->handleError(); | 301 | return $oForm->handleError(); |
| 300 | } | 302 | } |
| 301 | $data = $res['results']; | 303 | $data = $res['results']; |
| 302 | - | 304 | + */ |
| 305 | + | ||
| 303 | $doctypeid = $requestDocumentType; | 306 | $doctypeid = $requestDocumentType; |
| 304 | $aGenericFieldsetIds = KTFieldset::getGenericFieldsets(array('ids' => false)); | 307 | $aGenericFieldsetIds = KTFieldset::getGenericFieldsets(array('ids' => false)); |
| 305 | $aSpecificFieldsetIds = KTFieldset::getForDocumentType($doctypeid, array('ids' => false)); | 308 | $aSpecificFieldsetIds = KTFieldset::getForDocumentType($doctypeid, array('ids' => false)); |
| @@ -312,6 +315,7 @@ class InetBulkImportFolderMultiSelectAction extends KTFolderAction { | @@ -312,6 +315,7 @@ class InetBulkImportFolderMultiSelectAction extends KTFolderAction { | ||
| 312 | 315 | ||
| 313 | foreach ($fields as $oField) { | 316 | foreach ($fields as $oField) { |
| 314 | $val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId()); | 317 | $val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId()); |
| 318 | + | ||
| 315 | if ($oFieldset->getIsConditional()) | 319 | if ($oFieldset->getIsConditional()) |
| 316 | { | 320 | { |
| 317 | if ($val == _kt('No selection.')) | 321 | if ($val == _kt('No selection.')) |
| @@ -319,16 +323,16 @@ class InetBulkImportFolderMultiSelectAction extends KTFolderAction { | @@ -319,16 +323,16 @@ class InetBulkImportFolderMultiSelectAction extends KTFolderAction { | ||
| 319 | $val = null; | 323 | $val = null; |
| 320 | } | 324 | } |
| 321 | } | 325 | } |
| 322 | - | 326 | + |
| 323 | if (!is_null($val)) { | 327 | if (!is_null($val)) { |
| 324 | $MDPack[] = array( | 328 | $MDPack[] = array( |
| 325 | $oField, | 329 | $oField, |
| 326 | $val | 330 | $val |
| 327 | ); | 331 | ); |
| 328 | } | 332 | } |
| 329 | - | 333 | + |
| 330 | } | 334 | } |
| 331 | - } | 335 | + } |
| 332 | 336 | ||
| 333 | $aOptions = array( | 337 | $aOptions = array( |
| 334 | 'documenttype' => $oDocumentType, | 338 | 'documenttype' => $oDocumentType, |
| @@ -340,7 +344,7 @@ class InetBulkImportFolderMultiSelectAction extends KTFolderAction { | @@ -340,7 +344,7 @@ class InetBulkImportFolderMultiSelectAction extends KTFolderAction { | ||
| 340 | $po->start(); | 344 | $po->start(); |
| 341 | $oUploadChannel =& KTUploadChannel::getSingleton(); | 345 | $oUploadChannel =& KTUploadChannel::getSingleton(); |
| 342 | $oUploadChannel->addObserver($po); | 346 | $oUploadChannel->addObserver($po); |
| 343 | - | 347 | + |
| 344 | $fs =& new KTFSImportStorage($sPath); | 348 | $fs =& new KTFSImportStorage($sPath); |
| 345 | $bm =& new KTBulkImportManager($this->oFolder, $fs, $this->oUser, $aOptions); | 349 | $bm =& new KTBulkImportManager($this->oFolder, $fs, $this->oUser, $aOptions); |
| 346 | if(KTPluginUtil::pluginIsActive('inet.foldermetadata.plugin')) | 350 | if(KTPluginUtil::pluginIsActive('inet.foldermetadata.plugin')) |
plugins/multiselect/BulkUpload.php
100644 → 100755
| @@ -330,7 +330,6 @@ class InetBulkUploadFolderAction extends KTFolderAction { | @@ -330,7 +330,6 @@ class InetBulkUploadFolderAction extends KTFolderAction { | ||
| 330 | foreach ($fields as $oField) { | 330 | foreach ($fields as $oField) { |
| 331 | //var_dump($oField->getId()); | 331 | //var_dump($oField->getId()); |
| 332 | $val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId()); | 332 | $val = KTUtil::arrayGet($values, 'metadata_' . $oField->getId()); |
| 333 | - //var_dump($val); | ||
| 334 | if ($oFieldset->getIsConditional()) | 333 | if ($oFieldset->getIsConditional()) |
| 335 | { | 334 | { |
| 336 | if ($val == _kt('No selection.')) | 335 | if ($val == _kt('No selection.')) |
resources/js/kt_bulkupload.js
| @@ -30,7 +30,7 @@ function swapInItem(docId, elementId, req) { | @@ -30,7 +30,7 @@ function swapInItem(docId, elementId, req) { | ||
| 30 | var elems = jQuery(document).find(".kt_date_field"); | 30 | var elems = jQuery(document).find(".kt_date_field"); |
| 31 | for (i = 0; i < elems.length; i++) { | 31 | for (i = 0; i < elems.length; i++) { |
| 32 | var fieldName = elems[i].id; | 32 | var fieldName = elems[i].id; |
| 33 | - //alert(fieldName); | 33 | + |
| 34 | isGeneric = false; | 34 | isGeneric = false; |
| 35 | if (genericFields.indexOf(fieldName.match('metadata_[0-9]+')) >= 0){ | 35 | if (genericFields.indexOf(fieldName.match('metadata_[0-9]+')) >= 0){ |
| 36 | isGeneric = true; | 36 | isGeneric = true; |
| @@ -38,7 +38,7 @@ function swapInItem(docId, elementId, req) { | @@ -38,7 +38,7 @@ function swapInItem(docId, elementId, req) { | ||
| 38 | 38 | ||
| 39 | if (!isGeneric){ | 39 | if (!isGeneric){ |
| 40 | var dp = new Ext.form.DateField({ | 40 | var dp = new Ext.form.DateField({ |
| 41 | - name: fieldName, | 41 | + name: fieldName.replace('div_', ''), |
| 42 | allowBlank:false, | 42 | allowBlank:false, |
| 43 | size:10, | 43 | size:10, |
| 44 | format: 'Y-m-d', | 44 | format: 'Y-m-d', |
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) { | ||
| 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 | + $assArr = $this->dbUtilities->fetchAssoc($result); | ||
| 132 | + return $assArr; | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + function _upgradeTableInstalled() { | ||
| 136 | + $query = "SELECT COUNT(id) FROM upgrades"; | ||
| 137 | + $res = $this->runDBQuery($query); | ||
| 138 | + if($res) { | ||
| 139 | + return true; | ||
| 140 | + } | ||
| 141 | + return false; | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + function isAlreadyApplied() { | ||
| 145 | + if (!$this->_upgradeTableInstalled()) { | ||
| 146 | + return false; | ||
| 147 | + } | ||
| 148 | + $query = "SELECT id FROM upgrades WHERE descriptor = '".$this->getDescriptor()."' AND result = 1"; | ||
| 149 | + $res = $this->runDBQuery($query); | ||
| 150 | + if($res) { | ||
| 151 | + return true; | ||
| 152 | + } | ||
| 153 | + return false; | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + function performUpgrade($force = false) { | ||
| 157 | + $res = $this->isAlreadyApplied(); | ||
| 158 | + if ($res === true) { | ||
| 159 | + if ($force !== true) { | ||
| 160 | + // PHP5: Exception | ||
| 161 | + return new Upgrade_Already_Applied($this); | ||
| 162 | + } | ||
| 163 | + } | ||
| 164 | +// if (PEAR::isError($res)) { | ||
| 165 | +// return $res; | ||
| 166 | +// } | ||
| 167 | + $oCache =& KTCache::getSingleton(); | ||
| 168 | + $save = $oCache->bEnabled; | ||
| 169 | + $oCache->bEnabled = false; | ||
| 170 | + $res = $this->_performUpgrade(); | ||
| 171 | + $oCache->bEnabled = $save; | ||
| 172 | +// if (PEAR::isError($res)) { | ||
| 173 | +// $this->_recordUpgrade(false); | ||
| 174 | +// return $res; | ||
| 175 | +// } | ||
| 176 | + $res = $this->_recordUpgrade(true); | ||
| 177 | +// if (PEAR::isError($res)) { | ||
| 178 | +// return $res; | ||
| 179 | +// } | ||
| 180 | + return true; | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + function _performUpgrade() { | ||
| 184 | +// return PEAR::raiseError("Unimplemented"); | ||
| 185 | + } | ||
| 186 | + | ||
| 187 | + function _recordUpgrade($result) { | ||
| 188 | + if (is_null($this->date)) { | ||
| 189 | + $this->date = getCurrentDateTime(); | ||
| 190 | + } | ||
| 191 | + if ($this->parent) { | ||
| 192 | + $parentid = $this->parent->getDescriptor(); | ||
| 193 | + } else { | ||
| 194 | + $parentid = null; | ||
| 195 | + } | ||
| 196 | + //TODO: Where is the code? | ||
| 197 | + exit("add code"); | ||
| 198 | + /*return $this->autoInsert(); | ||
| 199 | + | ||
| 200 | + DBUtil::autoInsert("upgrades", array( | ||
| 201 | + "descriptor" => $this->getDescriptor(), | ||
| 202 | + "description" => $this->description, | ||
| 203 | + "date_performed" => $this->date, | ||
| 204 | + "result" => $result, | ||
| 205 | + "parent" => $parentid, | ||
| 206 | + ));*/ | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + // STATIC | ||
| 210 | + function getAllUpgrades() { | ||
| 211 | + return array(); | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + | ||
| 215 | +} | ||
| 216 | + | ||
| 217 | +class SQLUpgradeItem extends UpgradeItem { | ||
| 218 | + function SQLUpgradeItem($path, $version = null, $description = null, $phase = null, $priority = null) { | ||
| 219 | + $this->type = "sql"; | ||
| 220 | + $this->priority = 0; | ||
| 221 | + $details = $this->_getDetailsFromFileName($path); | ||
| 222 | + if (is_null($version)) { | ||
| 223 | + $version = $details[1]; | ||
| 224 | + } | ||
| 225 | + if (is_null($description)) { | ||
| 226 | + $description = $details[2]; | ||
| 227 | + } | ||
| 228 | + if (is_null($phase)) { | ||
| 229 | + $phase = $details[3]; | ||
| 230 | + } | ||
| 231 | + if (is_null($priority)) { | ||
| 232 | + $priority = isset($details[4]) ? $details[4] : 0; | ||
| 233 | + } | ||
| 234 | + $this->UpgradeItem($path, $version, $description, $phase, $priority); | ||
| 235 | + } | ||
| 236 | + | ||
| 237 | + /** | ||
| 238 | + * Describe the SQL scripts that will be used to upgrade KnowledgeTree | ||
| 239 | + * | ||
| 240 | + * Return an array of arrays with two components: a string identifier | ||
| 241 | + * that uniquely describes the step to be taken and a string which is an | ||
| 242 | + * HTML-formatted description of the step to be taken. These will be | ||
| 243 | + * returned in any order - describeUpgrade performs the ordering. | ||
| 244 | + * | ||
| 245 | + * @param string Original version (e.g., "1.2.4") | ||
| 246 | + * @param string Current version (e.g., "2.0.2") | ||
| 247 | + * | ||
| 248 | + * @return array Array of SQLUpgradeItem describing steps to be taken | ||
| 249 | + * | ||
| 250 | + * STATIC | ||
| 251 | + */ | ||
| 252 | + function getUpgrades($origVersion, $currVersion) { | ||
| 253 | +// global $default; | ||
| 254 | + | ||
| 255 | +// $sqlupgradedir = KT_DIR . '/sql/' . $default->dbType . '/upgrade/'; | ||
| 256 | + $dbType = 'mysql'; | ||
| 257 | + $sqlupgradedir = KT_DIR . 'sql/' . $dbType . '/upgrade/'; | ||
| 258 | + $ret = array(); | ||
| 259 | + | ||
| 260 | + if (!is_dir($sqlupgradedir)) { | ||
| 261 | +// return PEAR::raiseError("SQL Upgrade directory ($sqlupgradedir) not accessible"); | ||
| 262 | + } | ||
| 263 | + if (!($dh = opendir($sqlupgradedir))) { | ||
| 264 | +// return PEAR::raiseError("SQL Upgrade directory ($sqlupgradedir) not accessible"); | ||
| 265 | + } | ||
| 266 | + | ||
| 267 | + while (($file = readdir($dh)) !== false) { | ||
| 268 | + // Each entry can be a file or a directory | ||
| 269 | + // | ||
| 270 | + // A file is legacy before the upgrade system was created, but | ||
| 271 | + // will be supported anyway. | ||
| 272 | + // | ||
| 273 | + // A directory is the end-result version: so, 2.0.5 contains | ||
| 274 | + // every script that differentiates it from a previous version, | ||
| 275 | + // say, 2.0.5rc1 or 2.0.4. | ||
| 276 | + // | ||
| 277 | + if (in_array($file, array('.', '..', 'CVS'))) { | ||
| 278 | + continue; | ||
| 279 | + } | ||
| 280 | + $fullpath = $sqlupgradedir . $file; | ||
| 281 | + if (is_file($fullpath)) { | ||
| 282 | + // Legacy file support, will be in form of | ||
| 283 | + // 1.2.4-to-2.0.0.sql. | ||
| 284 | + $details = SQLUpgradeItem::_getDetailsFromFileName($file); | ||
| 285 | + if ($details) { | ||
| 286 | + if (!gte_version($details[0], $origVersion)) { | ||
| 287 | + continue; | ||
| 288 | + } | ||
| 289 | + if (!lte_version($details[1], $currVersion)) { | ||
| 290 | + continue; | ||
| 291 | + } | ||
| 292 | + //print "Will run $file\n"; | ||
| 293 | +// print_r($this->util->dbUtilities); | ||
| 294 | +// die; | ||
| 295 | + $ret[] = new SQLUpgradeItem($file); | ||
| 296 | + } | ||
| 297 | + } | ||
| 298 | + if (is_dir($fullpath)) { | ||
| 299 | + $subdir = $file; | ||
| 300 | + if (!($subdh = opendir($fullpath))) { | ||
| 301 | + continue; | ||
| 302 | + } | ||
| 303 | + while (($file = readdir($subdh)) !== false) { | ||
| 304 | + $relpath = $subdir . '/' . $file; | ||
| 305 | + $details = SQLUpgradeItem::_getDetailsFromFileName($relpath); | ||
| 306 | + if ($details) { | ||
| 307 | + if (!gte_version($details[0], $origVersion)) { | ||
| 308 | + continue; | ||
| 309 | + } | ||
| 310 | + if (!lte_version($details[1], $currVersion)) { | ||
| 311 | + continue; | ||
| 312 | + } | ||
| 313 | + //print "Will run $file\n"; | ||
| 314 | +// print_r(SQLUpgradeItem::); | ||
| 315 | +// die; | ||
| 316 | +// new InstallUtil(); | ||
| 317 | + $ret[] = new SQLUpgradeItem($relpath); | ||
| 318 | + } | ||
| 319 | + } | ||
| 320 | + } | ||
| 321 | + } | ||
| 322 | + closedir($dh); | ||
| 323 | + return $ret; | ||
| 324 | + } | ||
| 325 | + | ||
| 326 | + function _getDetailsFromFileName($path) { | ||
| 327 | + // Old format (pre 2.0.6) | ||
| 328 | + $matched = preg_match('#^([\d.]*)-to-([\d.]*).sql$#', $path, $matches); | ||
| 329 | + if ($matched != 0) { | ||
| 330 | + $fromVersion = $matches[1]; | ||
| 331 | + $toVersion = $matches[2]; | ||
| 332 | + $description = "Database upgrade from version $fromVersion to $toVersion"; | ||
| 333 | + $phase = 0; | ||
| 334 | + return array($fromVersion, $toVersion, $description, $phase); | ||
| 335 | + } | ||
| 336 | + $matched = preg_match('#^([\d.]*)/(?:(\d*)-)?(.*)\.sql$#', $path, $matches); | ||
| 337 | + //$matched = preg_match('#^([\d.]*)/(?:(\d*)-)?(.*):(?:(\d*))\.sql$#', $path, $matches); | ||
| 338 | + if ($matched != 0) { | ||
| 339 | + $fromVersion = $matches[1]; | ||
| 340 | + $toVersion = $matches[1]; | ||
| 341 | + $in = array('_'); | ||
| 342 | + $out = array(' '); | ||
| 343 | + $phase = (int)$matches[2]; | ||
| 344 | + | ||
| 345 | + //$priority = (int)$matches[4]; | ||
| 346 | + $priority = 0; | ||
| 347 | + $iPriority = preg_match('#^(.*)-(\d*)$#', $matches[3], $priorities); | ||
| 348 | + if($iPriority != 0){ | ||
| 349 | + $priority = $priorities[2]; | ||
| 350 | + $matches[3] = $priorities[1]; | ||
| 351 | + } | ||
| 352 | + | ||
| 353 | + $description = "Database upgrade to version $toVersion: " . ucfirst(str_replace($in, $out, $matches[3])); | ||
| 354 | + return array($fromVersion, $toVersion, $description, $phase, $priority); | ||
| 355 | + } | ||
| 356 | + // XXX: handle new format | ||
| 357 | + return null; | ||
| 358 | + } | ||
| 359 | + | ||
| 360 | + function _performUpgrade() { | ||
| 361 | +// global $default; | ||
| 362 | + $dbType = 'mysql'; | ||
| 363 | + $sqlupgradedir = KT_DIR . 'sql/' . $dbType . '/upgrade/'; | ||
| 364 | + $queries = SQLFile::sqlFromFile($sqlupgradedir . $this->name); | ||
| 365 | + exit('add code'); | ||
| 366 | +// return DBUtil::runQueries($queries, $default->_admindb); | ||
| 367 | + } | ||
| 368 | + | ||
| 369 | + | ||
| 370 | +} | ||
| 371 | + | ||
| 372 | +class KTRebuildPermissionObserver { | ||
| 373 | + function start() { | ||
| 374 | + $this->lastBeat = time(); | ||
| 375 | + } | ||
| 376 | + function receiveMessage() { | ||
| 377 | + $now = time(); | ||
| 378 | + if ($this->lastBeat + 15 < $now) { | ||
| 379 | + print "<!-- -->"; | ||
| 380 | + ob_flush(); | ||
| 381 | + flush(); | ||
| 382 | + } | ||
| 383 | + } | ||
| 384 | + function end() { | ||
| 385 | + } | ||
| 386 | +} | ||
| 387 | + | ||
| 388 | +class RecordUpgradeItem extends UpgradeItem { | ||
| 389 | + function RecordUpgradeItem ($version, $oldversion = null) { | ||
| 390 | + $this->type = "upgrade"; | ||
| 391 | + if (is_null($oldversion)) { | ||
| 392 | + $this->description = "Upgrade to version $version"; | ||
| 393 | + } else { | ||
| 394 | + $this->description = "Upgrade from version $oldversion to $version"; | ||
| 395 | + } | ||
| 396 | + $this->phase = 99; | ||
| 397 | + $this->version = $version; | ||
| 398 | + $this->name = 'upgrade' . $version; | ||
| 399 | + } | ||
| 400 | + | ||
| 401 | + function _performUpgrade() { | ||
| 402 | +// $this->_deleteSmartyFiles(); | ||
| 403 | +// $this->_deleteProxyFiles(); | ||
| 404 | +// require_once(KT_LIB_DIR . '/cache/cache.inc.php'); | ||
| 405 | +// $oCache =& KTCache::getSingleton(); | ||
| 406 | +// $oCache->deleteAllCaches(); | ||
| 407 | + // TODO : clear cache folder | ||
| 408 | +// require_once(KT_LIB_DIR . '/permissions/permissionutil.inc.php'); | ||
| 409 | + // TODO : What does this do | ||
| 410 | +// $po =& new KTRebuildPermissionObserver($this); | ||
| 411 | +// $po->start(); | ||
| 412 | +// $oChannel =& KTPermissionChannel::getSingleton(); | ||
| 413 | +// $oChannel->addObserver($po); | ||
| 414 | + | ||
| 415 | + set_time_limit(0); | ||
| 416 | + ignore_user_abort(true); | ||
| 417 | + | ||
| 418 | +// KTPermissionUtil::rebuildPermissionLookups(true); | ||
| 419 | +// $po->end(); | ||
| 420 | + | ||
| 421 | + $versionFile=KT_DIR . '/docs/VERSION-NAME.txt'; | ||
| 422 | + $fp = fopen($versionFile,'rt'); | ||
| 423 | + $systemVersion = fread($fp, filesize($versionFile)); | ||
| 424 | + fclose($fp); | ||
| 425 | + | ||
| 426 | + $query = "UPDATE system_settings SET value = '$systemVersion' WHERE name = 'knowledgetreeVersion'"; | ||
| 427 | + $this->runDBQuery($query); | ||
| 428 | + $query = "UPDATE system_settings SET value = '{$this->version}' WHERE name = 'databaseVersion'"; | ||
| 429 | + $assArray = $this->runDBQuery($query); | ||
| 430 | + return !is_null($assArray); | ||
| 431 | + } | ||
| 432 | + | ||
| 433 | + function _deleteSmartyFiles() { | ||
| 434 | + $oConfig =& KTConfig::getSingleton(); | ||
| 435 | + $dir = sprintf('%s/%s', $oConfig->get('urls/varDirectory'), 'tmp'); | ||
| 436 | + | ||
| 437 | + $dh = @opendir($dir); | ||
| 438 | + if (empty($dh)) { | ||
| 439 | + return; | ||
| 440 | + } | ||
| 441 | + $aFiles = array(); | ||
| 442 | + while (false !== ($sFilename = readdir($dh))) { | ||
| 443 | + if (substr($sFilename, -10) == "smarty.inc") { | ||
| 444 | + $aFiles[] = sprintf('%s/%s', $dir, $sFilename); | ||
| 445 | + } | ||
| 446 | + if (substr($sFilename, -10) == "smarty.php") { | ||
| 447 | + $aFiles[] = sprintf('%s/%s', $dir, $sFilename); | ||
| 448 | + } | ||
| 449 | + } | ||
| 450 | + foreach ($aFiles as $sFile) { | ||
| 451 | + @unlink($sFile); | ||
| 452 | + } | ||
| 453 | + } | ||
| 454 | + | ||
| 455 | + | ||
| 456 | + function _deleteProxyFiles() { | ||
| 457 | + $oKTConfig =& KTConfig::getSingleton(); | ||
| 458 | + | ||
| 459 | + | ||
| 460 | + // from ktentityutil::_proxyCreate | ||
| 461 | + $sDirectory = $oKTConfig->get('cache/proxyCacheDirectory'); | ||
| 462 | + | ||
| 463 | + if (!file_exists($sDirectory)) { | ||
| 464 | + return; | ||
| 465 | + } | ||
| 466 | + $sRunningUser = KTUtil::running_user(); | ||
| 467 | + if ($sRunningUser) { | ||
| 468 | + $sDirectory = sprintf("%s/%s", $sDirectory, $sRunningUser); | ||
| 469 | + } | ||
| 470 | + if (!file_exists($sDirectory)) { | ||
| 471 | + return ; | ||
| 472 | + } | ||
| 473 | + | ||
| 474 | + $dh = @opendir($sDirectory); | ||
| 475 | + if (empty($dh)) { | ||
| 476 | + return; | ||
| 477 | + } | ||
| 478 | + $aFiles = array(); | ||
| 479 | + while (false !== ($sFilename = readdir($dh))) { | ||
| 480 | + | ||
| 481 | + if (substr($sFilename, -8) == ".inc.php") { | ||
| 482 | + $aFiles[] = sprintf('%s/%s', $sDirectory, $sFilename); | ||
| 483 | + } | ||
| 484 | + } | ||
| 485 | + | ||
| 486 | + foreach ($aFiles as $sFile) { | ||
| 487 | + @unlink($sFile); | ||
| 488 | + } | ||
| 489 | + } | ||
| 490 | +} | ||
| 491 | + | ||
| 492 | +?> |
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. Get all Function upgrades >= origVersion and <= currVersion | ||
| 96 | + // 3. Categorise each into version they upgrade to | ||
| 97 | + // 4. Sort each version subgroup into correct order | ||
| 98 | + // 5. Add "recordSubUpgrade" for each version there. | ||
| 99 | + // 6. Add back into one big list again | ||
| 100 | + // 7. Add "recordUpgrade" for whole thing | ||
| 101 | + | ||
| 102 | + // $recordUpgrade = array('upgrade*' . $currVersion, 'Upgrade to ' . $currVersion, null); | ||
| 103 | + | ||
| 104 | + $steps = array(); | ||
| 105 | + foreach (array('SQLUpgradeItem') as $itemgen) { | ||
| 106 | + $f = array($itemgen, 'getUpgrades'); | ||
| 107 | + $ssteps =& call_user_func($f, $origVersion, $currVersion); | ||
| 108 | + $scount = count($ssteps); | ||
| 109 | + for ($i = 0; $i < $scount; $i++) { | ||
| 110 | + $steps[] =& $ssteps[$i]; | ||
| 111 | + } | ||
| 112 | + } | ||
| 113 | + $upgradestep =& new RecordUpgradeItem($currVersion, $origVersion); | ||
| 114 | + $steps[] =& $upgradestep; | ||
| 115 | + $stepcount = count($steps); | ||
| 116 | + for ($i = 0; $i < $stepcount; $i++) { | ||
| 117 | + $step =& $steps[$i]; | ||
| 118 | + $step->setParent($upgradestep); | ||
| 119 | + } | ||
| 120 | + usort($steps, 'step_sort_func'); | ||
| 121 | + | ||
| 122 | + return $steps; | ||
| 123 | +} | ||
| 124 | +// }}} | ||
| 125 | + | ||
| 126 | +// {{{ step_sort_func | ||
| 127 | +function step_sort_func ($obj1, $obj2) { | ||
| 128 | + // Ugly hack to ensure that upgrade table is made first... | ||
| 129 | + if ($obj1->name === "2.0.6/create_upgrade_table.sql") { | ||
| 130 | + return -1; | ||
| 131 | + } | ||
| 132 | + if ($obj2->name === "2.0.6/create_upgrade_table.sql") { | ||
| 133 | + return 1; | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + // Priority upgrades run first | ||
| 137 | + if ($obj1->getPriority() < $obj2->getPriority()) { | ||
| 138 | + return 1; | ||
| 139 | + } | ||
| 140 | + if ($obj1->getPriority() > $obj2->getPriority()) { | ||
| 141 | + return -1; | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + // early version run first | ||
| 145 | + $res = compare_version($obj1->getVersion(), $obj2->getVersion()); | ||
| 146 | + if ($res !== 0) { | ||
| 147 | + return $res; | ||
| 148 | + } | ||
| 149 | + // Order by phase | ||
| 150 | + if ($obj1->getPhase() > $obj2->getPhase()) { | ||
| 151 | + return 1; | ||
| 152 | + } | ||
| 153 | + if ($obj1->getPhase() < $obj2->getPhase()) { | ||
| 154 | + return -1; | ||
| 155 | + } | ||
| 156 | + // Order by name | ||
| 157 | + if ($obj1->name < $obj2->name) { | ||
| 158 | + return -1; | ||
| 159 | + } | ||
| 160 | + if ($obj1->name > $obj2->name) { | ||
| 161 | + return 1; | ||
| 162 | + } | ||
| 163 | + return 0; | ||
| 164 | +} | ||
| 165 | +// }}} | ||
| 166 | + | ||
| 167 | +// {{{ compare_version | ||
| 168 | +/** | ||
| 169 | + * Compares two version numbers and returns a value based on this comparison | ||
| 170 | + * | ||
| 171 | + * Using standard software version rules, such as 2.0.5rc1 comes before | ||
| 172 | + * 2.0.5, and 2.0.5rc1 comes after 2.0.5alpha1, compare two version | ||
| 173 | + * numbers, and determine which is the higher. | ||
| 174 | + * | ||
| 175 | + * XXX: Actually, just does $version1 < $version2 | ||
| 176 | + * | ||
| 177 | + * @param string First version number | ||
| 178 | + * @param string Second version number | ||
| 179 | + * | ||
| 180 | + * @return int -1, 0, 1 | ||
| 181 | + */ | ||
| 182 | +function compare_version($version1, $version2) { | ||
| 183 | + // XXX: Version comparisons should be better. | ||
| 184 | + if ($version1 < $version2) { | ||
| 185 | + return -1; | ||
| 186 | + } | ||
| 187 | + if ($version1 > $version2) { | ||
| 188 | + return 1; | ||
| 189 | + } | ||
| 190 | + return 0; | ||
| 191 | +} | ||
| 192 | +// }}} | ||
| 193 | + | ||
| 194 | +// {{{ lte_version | ||
| 195 | +/** | ||
| 196 | + * Quick-hand for checking if a version number is lower-than-or-equal-to | ||
| 197 | + */ | ||
| 198 | +function lte_version($version1, $version2) { | ||
| 199 | + if (in_array(compare_version($version1, $version2), array(-1, 0))) { | ||
| 200 | + return true; | ||
| 201 | + } | ||
| 202 | + return false; | ||
| 203 | +} | ||
| 204 | +// }} | ||
| 205 | + | ||
| 206 | +// {{ gte_version | ||
| 207 | +/** | ||
| 208 | + * Quick-hand for checking if a version number is greater-than-or-equal-to | ||
| 209 | + */ | ||
| 210 | +function gte_version($version1, $version2) { | ||
| 211 | + if (in_array(compare_version($version1, $version2), array(0, 1))) { | ||
| 212 | + return true; | ||
| 213 | + } | ||
| 214 | + return false; | ||
| 215 | +} | ||
| 216 | +// }}} | ||
| 217 | + | ||
| 218 | +?> |
setup/upgrade/steps/upgradeDatabase.php
| @@ -43,7 +43,8 @@ | @@ -43,7 +43,8 @@ | ||
| 43 | //require_once('../../config/dmsDefaults.php'); | 43 | //require_once('../../config/dmsDefaults.php'); |
| 44 | //require_once(KT_LIB_DIR . '/config/config.inc.php'); | 44 | //require_once(KT_LIB_DIR . '/config/config.inc.php'); |
| 45 | //require_once(KT_LIB_DIR . '/plugins/pluginutil.inc.php'); | 45 | //require_once(KT_LIB_DIR . '/plugins/pluginutil.inc.php'); |
| 46 | -//define('KT_LIB_DIR', SYSTEM_DIR.'lib'.DS); | 46 | +define('KT_DIR', SYSTEM_DIR); |
| 47 | +define('KT_LIB_DIR', SYSTEM_DIR.'lib'); | ||
| 47 | //require_once(SYSTEM_DIR . 'lib/upgrades/upgrade.inc.php'); | 48 | //require_once(SYSTEM_DIR . 'lib/upgrades/upgrade.inc.php'); |
| 48 | 49 | ||
| 49 | class upgradeDatabase extends Step | 50 | class upgradeDatabase extends Step |
| @@ -92,10 +93,10 @@ class upgradeDatabase extends Step | @@ -92,10 +93,10 @@ class upgradeDatabase extends Step | ||
| 92 | * @var array | 93 | * @var array |
| 93 | */ | 94 | */ |
| 94 | public $storeInSession = true; | 95 | public $storeInSession = true; |
| 95 | - | 96 | + public $sysVersion = ''; |
| 96 | protected $silent = false; | 97 | protected $silent = false; |
| 97 | protected $temp_variables = array(); | 98 | protected $temp_variables = array(); |
| 98 | - | 99 | + public $paths = ''; |
| 99 | /** | 100 | /** |
| 100 | * Main control of database setup | 101 | * Main control of database setup |
| 101 | * | 102 | * |
| @@ -143,17 +144,14 @@ class upgradeDatabase extends Step | @@ -143,17 +144,14 @@ class upgradeDatabase extends Step | ||
| 143 | 144 | ||
| 144 | private function doRun($action = null) { | 145 | private function doRun($action = null) { |
| 145 | // $this->readConfig(KTConfig::getConfigFilename()); | 146 | // $this->readConfig(KTConfig::getConfigFilename()); |
| 146 | - require_once("../wizard/steps/configuration.php"); // configuration to read the ini path | ||
| 147 | - $wizConfigHandler = new configuration(); | ||
| 148 | - $configPath = $wizConfigHandler->readConfigPathIni(); | ||
| 149 | - $this->readConfig($configPath); | ||
| 150 | - if($this->dbSettings['dbPort'] == '') { | ||
| 151 | - $con = $this->util->dbUtilities->load($this->dbSettings['dbHost'], $this->dbSettings['dbUser'], | ||
| 152 | - $this->dbSettings['dbPass'], $this->dbSettings['dbName']); | ||
| 153 | - } else { | ||
| 154 | - $con = $this->util->dbUtilities->load($this->dbSettings['dbHost'].":".$this->dbSettings['dbPort'], $this->dbSettings['dbUser'], | 147 | + |
| 148 | + $this->readConfig(); | ||
| 149 | +// if($this->dbSettings['dbPort'] == '') { | ||
| 150 | +// $con = $this->util->dbUtilities->load($this->dbSettings['dbHost'], '', $this->dbSettings['dbUser'],$this->dbSettings['dbPass'], $this->dbSettings['dbName']); | ||
| 151 | +// } else { | ||
| 152 | + $con = $this->util->dbUtilities->load($this->dbSettings['dbHost'], $this->dbSettings['dbPort'], $this->dbSettings['dbUser'], | ||
| 155 | $this->dbSettings['dbPass'], $this->dbSettings['dbName']); | 153 | $this->dbSettings['dbPass'], $this->dbSettings['dbName']); |
| 156 | - } | 154 | +// } |
| 157 | 155 | ||
| 158 | $this->temp_variables['action'] = $action; | 156 | $this->temp_variables['action'] = $action; |
| 159 | if (is_null($action) || ($action == 'preview')) { | 157 | if (is_null($action) || ($action == 'preview')) { |
| @@ -177,23 +175,19 @@ class upgradeDatabase extends Step | @@ -177,23 +175,19 @@ class upgradeDatabase extends Step | ||
| 177 | } | 175 | } |
| 178 | 176 | ||
| 179 | private function generateUpgradeTable() { | 177 | private function generateUpgradeTable() { |
| 180 | -// global $default; | ||
| 181 | - $v = $this->readVersion(); | ||
| 182 | -// $this->temp_variables['systemVersion'] = $default->systemVersion; | ||
| 183 | - $this->temp_variables['systemVersion'] = $v; | ||
| 184 | - | ||
| 185 | -// $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', $default->system_settings_table); | ||
| 186 | - $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', 'config_settings'); | ||
| 187 | - | 178 | + $this->sysVersion = $this->readVersion(); |
| 179 | + $this->temp_variables['systemVersion'] = $this->sysVersion; | ||
| 180 | + $dconf = $this->util->iniUtilities->getSection('db'); | ||
| 181 | + $query = sprintf('SELECT value FROM %s WHERE name = "databaseVersion"', 'system_settings'); | ||
| 182 | + $this->util->dbUtilities->load($dconf['dbHost'], '', $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']); | ||
| 188 | $result = $this->util->dbUtilities->query($query); | 183 | $result = $this->util->dbUtilities->query($query); |
| 184 | + $assArr = $this->util->dbUtilities->fetchAssoc($result); | ||
| 189 | if ($result) { | 185 | if ($result) { |
| 190 | - $lastVersionObj = $this->util->dbUtilities->fetchNextObject($result); | ||
| 191 | - $lastVersion = $lastVersionObj->value; | 186 | + $lastVersion = $assArr[0]['value']; |
| 192 | } | 187 | } |
| 193 | - $currentVersion = $v; | ||
| 194 | - | 188 | + $currentVersion = $this->sysVersion; |
| 189 | + require_once("lib/upgrade.inc.php"); | ||
| 195 | $upgrades = describeUpgrade($lastVersion, $currentVersion); | 190 | $upgrades = describeUpgrade($lastVersion, $currentVersion); |
| 196 | - | ||
| 197 | $ret = "<table border=1 cellpadding=1 cellspacing=1 width='100%'>\n"; | 191 | $ret = "<table border=1 cellpadding=1 cellspacing=1 width='100%'>\n"; |
| 198 | $ret .= "<tr bgcolor='darkgrey'><th width='10'>Code</th><th width='100%'>Description</th><th width='30'>Applied</th></tr>\n"; | 192 | $ret .= "<tr bgcolor='darkgrey'><th width='10'>Code</th><th width='100%'>Description</th><th width='30'>Applied</th></tr>\n"; |
| 199 | $i=0; | 193 | $i=0; |
| @@ -259,8 +253,10 @@ class upgradeDatabase extends Step | @@ -259,8 +253,10 @@ class upgradeDatabase extends Step | ||
| 259 | } | 253 | } |
| 260 | } | 254 | } |
| 261 | 255 | ||
| 262 | - private function readConfig($path) { | ||
| 263 | - //$ini = $this->util->loadInstallIni($path); | 256 | + private function readConfig() { |
| 257 | + require_once("../wizard/steps/configuration.php"); // configuration to read the ini path | ||
| 258 | + $wizConfigHandler = new configuration(); | ||
| 259 | + $path = $wizConfigHandler->readConfigPathIni(); | ||
| 264 | $this->util->iniUtilities->load($path); | 260 | $this->util->iniUtilities->load($path); |
| 265 | $dbSettings = $this->util->iniUtilities->getSection('db'); | 261 | $dbSettings = $this->util->iniUtilities->getSection('db'); |
| 266 | $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'], | 262 | $this->dbSettings = array('dbHost'=> $dbSettings['dbHost'], |
| @@ -271,7 +267,11 @@ class upgradeDatabase extends Step | @@ -271,7 +267,11 @@ class upgradeDatabase extends Step | ||
| 271 | 'dbAdminUser'=> $dbSettings['dbAdminUser'], | 267 | 'dbAdminUser'=> $dbSettings['dbAdminUser'], |
| 272 | 'dbAdminPass'=> $dbSettings['dbAdminPass'], | 268 | 'dbAdminPass'=> $dbSettings['dbAdminPass'], |
| 273 | ); | 269 | ); |
| 270 | + $this->paths = $this->util->iniUtilities->getSection('urls'); | ||
| 271 | + $this->paths = array_merge($this->paths, $this->util->iniUtilities->getSection('cache')); | ||
| 274 | $this->temp_variables['dbSettings'] = $this->dbSettings; | 272 | $this->temp_variables['dbSettings'] = $this->dbSettings; |
| 273 | + $this->sysVersion = $this->readVersion(); | ||
| 274 | + $this->cachePath = $wizConfigHandler->readCachePath(); | ||
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | private function upgradeConfirm() | 277 | private function upgradeConfirm() |
| @@ -291,9 +291,10 @@ class upgradeDatabase extends Step | @@ -291,9 +291,10 @@ class upgradeDatabase extends Step | ||
| 291 | $errors = false; | 291 | $errors = false; |
| 292 | 292 | ||
| 293 | $this->temp_variables['detail'] = '<p>The table below describes the upgrades that have occurred to | 293 | $this->temp_variables['detail'] = '<p>The table below describes the upgrades that have occurred to |
| 294 | - upgrade your KnowledgeTree installation to <strong>' . $default->systemVersion . '</strong>'; | 294 | + upgrade your KnowledgeTree installation to <strong>' . $this->sysVersion . '</strong>'; |
| 295 | 295 | ||
| 296 | $pre_res = $this->performPreUpgradeActions(); | 296 | $pre_res = $this->performPreUpgradeActions(); |
| 297 | + | ||
| 297 | if (PEAR::isError($pre_res)) { | 298 | if (PEAR::isError($pre_res)) { |
| 298 | $errors = true; | 299 | $errors = true; |
| 299 | $this->temp_variables['preUpgrade'] = '<font color="red">Pre-Upgrade actions failed.</font>'; | 300 | $this->temp_variables['preUpgrade'] = '<font color="red">Pre-Upgrade actions failed.</font>'; |
| @@ -336,7 +337,7 @@ class upgradeDatabase extends Step | @@ -336,7 +337,7 @@ class upgradeDatabase extends Step | ||
| 336 | // It should idealy work the same as the upgrades. | 337 | // It should idealy work the same as the upgrades. |
| 337 | 338 | ||
| 338 | // global $default; | 339 | // global $default; |
| 339 | - | 340 | +// print_r($this->paths);die; |
| 340 | // Lock the scheduler | 341 | // Lock the scheduler |
| 341 | $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock'; | 342 | $lockFile = $default->cacheDirectory . DIRECTORY_SEPARATOR . 'scheduler.lock'; |
| 342 | touch($lockFile); | 343 | touch($lockFile); |
setup/upgrade/steps/upgradeWelcome.php
| @@ -40,12 +40,9 @@ | @@ -40,12 +40,9 @@ | ||
| 40 | * @version Version 0.1 | 40 | * @version Version 0.1 |
| 41 | */ | 41 | */ |
| 42 | 42 | ||
| 43 | -//require_once('../../config/dmsDefaults.php'); | ||
| 44 | -//require_once KT_LIB_DIR . '/authentication/authenticationutil.inc.php'; | ||
| 45 | - | ||
| 46 | class upgradeWelcome extends step { | 43 | class upgradeWelcome extends step { |
| 47 | 44 | ||
| 48 | - protected $silent = false; | 45 | + protected $silent = true; |
| 49 | protected $temp_variables = array(); | 46 | protected $temp_variables = array(); |
| 50 | protected $error = array() ; | 47 | protected $error = array() ; |
| 51 | 48 | ||
| @@ -84,7 +81,7 @@ class upgradeWelcome extends step { | @@ -84,7 +81,7 @@ class upgradeWelcome extends step { | ||
| 84 | private function checkPassword($username, $password) { | 81 | private function checkPassword($username, $password) { |
| 85 | $dconf = $this->getDataFromPackage('installers', 'database'); // Use info from install | 82 | $dconf = $this->getDataFromPackage('installers', 'database'); // Use info from install |
| 86 | if($dconf) { | 83 | if($dconf) { |
| 87 | - $this->util->dbUtilities->load($dconf['dhost'], $dconf['duname'], $dconf['dpassword'], $dconf['dname']); | 84 | + $this->util->dbUtilities->load($dconf['dhost'], $dbconf['dport'], $dconf['duname'], $dconf['dpassword'], $dconf['dname']); |
| 88 | } else { | 85 | } else { |
| 89 | require_once("../wizard/steps/configuration.php"); // configuration to read the ini path | 86 | require_once("../wizard/steps/configuration.php"); // configuration to read the ini path |
| 90 | $wizConfigHandler = new configuration(); | 87 | $wizConfigHandler = new configuration(); |
| @@ -93,7 +90,7 @@ class upgradeWelcome extends step { | @@ -93,7 +90,7 @@ class upgradeWelcome extends step { | ||
| 93 | $dconf = $this->util->iniUtilities->getSection('db'); | 90 | $dconf = $this->util->iniUtilities->getSection('db'); |
| 94 | if($dconf['dbPort'] == 'default') | 91 | if($dconf['dbPort'] == 'default') |
| 95 | $dconf['dbPort'] = 3306; | 92 | $dconf['dbPort'] = 3306; |
| 96 | - $this->util->dbUtilities->load($dconf['dbHost'].":".$dconf['dbPort'], $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']); | 93 | + $this->util->dbUtilities->load($dconf['dbHost'],$dconf['dbPort'], $dconf['dbUser'], $dconf['dbPass'], $dconf['dbName']); |
| 97 | $sQuery = "SELECT count(*) AS match_count FROM users WHERE username = '$username' AND password = '".md5($password)."'"; | 94 | $sQuery = "SELECT count(*) AS match_count FROM users WHERE username = '$username' AND password = '".md5($password)."'"; |
| 98 | $res = $this->util->dbUtilities->query($sQuery); | 95 | $res = $this->util->dbUtilities->query($sQuery); |
| 99 | $ass = $this->util->dbUtilities->fetchAssoc($res); | 96 | $ass = $this->util->dbUtilities->fetchAssoc($res); |
| @@ -110,7 +107,22 @@ class upgradeWelcome extends step { | @@ -110,7 +107,22 @@ class upgradeWelcome extends step { | ||
| 110 | return $this->error; | 107 | return $this->error; |
| 111 | } | 108 | } |
| 112 | 109 | ||
| 110 | + /** | ||
| 111 | + * Returns step variables | ||
| 112 | + * | ||
| 113 | + * @author KnowledgeTree Team | ||
| 114 | + * @param none | ||
| 115 | + * @access public | ||
| 116 | + * @return array | ||
| 117 | + */ | ||
| 118 | + public function getStepVars() | ||
| 119 | + { | ||
| 120 | + return $this->temp_variables; | ||
| 121 | + } | ||
| 113 | 122 | ||
| 123 | + public function storeSilent() { | ||
| 124 | + | ||
| 125 | + } | ||
| 114 | } | 126 | } |
| 115 | 127 | ||
| 116 | ?> | 128 | ?> |
| 117 | \ No newline at end of file | 129 | \ No newline at end of file |
setup/wizard/dbUtilities.php
| @@ -101,12 +101,14 @@ class dbUtilities { | @@ -101,12 +101,14 @@ class dbUtilities { | ||
| 101 | * @access public | 101 | * @access public |
| 102 | */ | 102 | */ |
| 103 | public function __construct() { | 103 | public function __construct() { |
| 104 | - | 104 | + |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | - public function load($dhost = 'localhost', $duname, $dpassword, $dbname) { | 107 | + public function load($dhost = 'localhost', $dport = 'default', $duname, $dpassword, $dbname) { |
| 108 | if(!$this->isConnected($dhost, $duname, $dpassword, $dbname)) { | 108 | if(!$this->isConnected($dhost, $duname, $dpassword, $dbname)) { |
| 109 | - $this->dbhost = $dhost; | 109 | + if($dport == 'default' || $dport == '') |
| 110 | + $dport = '3306'; | ||
| 111 | + $this->dbhost = $dhost.":".$dport; | ||
| 110 | $this->dbuname = $duname; | 112 | $this->dbuname = $duname; |
| 111 | $this->dbpassword = $dpassword; | 113 | $this->dbpassword = $dpassword; |
| 112 | $this->dbconnection = @mysql_connect($dhost, $duname, $dpassword); | 114 | $this->dbconnection = @mysql_connect($dhost, $duname, $dpassword); |
setup/wizard/iniUtilities.php
| @@ -55,8 +55,8 @@ class iniUtilities { | @@ -55,8 +55,8 @@ class iniUtilities { | ||
| 55 | $this->read($iniFile); | 55 | $this->read($iniFile); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | - function __construct() { | ||
| 59 | - } | 58 | +// function __construct() { |
| 59 | +// } | ||
| 60 | 60 | ||
| 61 | /** | 61 | /** |
| 62 | * Create a backup with the date as an extension in the same location as the original config.ini | 62 | * Create a backup with the date as an extension in the same location as the original config.ini |
setup/wizard/resources/js/wizard.js
| @@ -4,14 +4,29 @@ function wizard() { | @@ -4,14 +4,29 @@ function wizard() { | ||
| 4 | 4 | ||
| 5 | // Toggle Advance Database options | 5 | // Toggle Advance Database options |
| 6 | wizard.prototype.toggleClass = function(ele, option) { //adv_options|php_details|php_ext_details|php_con_details | 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/steps/complete.php
| @@ -142,7 +142,7 @@ class complete extends Step { | @@ -142,7 +142,7 @@ class complete extends Step { | ||
| 142 | // retrieve database information from session | 142 | // retrieve database information from session |
| 143 | $dbconf = $this->getDataFromSession("database"); | 143 | $dbconf = $this->getDataFromSession("database"); |
| 144 | // make db connection - admin | 144 | // make db connection - admin |
| 145 | - $this->util->dbUtilities->load($dbconf['dhost'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']); | 145 | + $this->util->dbUtilities->load($dbconf['dhost'], $dbconf['dport'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']); |
| 146 | $loaded = $this->util->dbUtilities->getDatabaseLink(); | 146 | $loaded = $this->util->dbUtilities->getDatabaseLink(); |
| 147 | if (!$loaded) { | 147 | if (!$loaded) { |
| 148 | $this->temp_variables['dbConnectAdmin'] .= '<td><div class="cross"></div></td>' | 148 | $this->temp_variables['dbConnectAdmin'] .= '<td><div class="cross"></div></td>' |
| @@ -157,7 +157,7 @@ class complete extends Step { | @@ -157,7 +157,7 @@ class complete extends Step { | ||
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | // make db connection - user | 159 | // make db connection - user |
| 160 | - $this->util->dbUtilities->load($dbconf['dhost'], $dbconf['dmsusername'], $dbconf['dmsuserpassword'], $dbconf['dname']); | 160 | + $this->util->dbUtilities->load($dbconf['dhost'], $dbconf['dport'], $dbconf['dmsusername'], $dbconf['dmsuserpassword'], $dbconf['dname']); |
| 161 | $loaded = $this->util->dbUtilities->getDatabaseLink(); | 161 | $loaded = $this->util->dbUtilities->getDatabaseLink(); |
| 162 | // if we can log in to the database, check access | 162 | // if we can log in to the database, check access |
| 163 | // TODO check write access? | 163 | // TODO check write access? |
setup/wizard/steps/configuration.php
| @@ -307,7 +307,7 @@ class configuration extends Step | @@ -307,7 +307,7 @@ class configuration extends Step | ||
| 307 | { | 307 | { |
| 308 | $conf = $this->getDataFromSession("configuration"); // get data from the server | 308 | $conf = $this->getDataFromSession("configuration"); // get data from the server |
| 309 | $dbconf = $this->getDataFromSession("database"); | 309 | $dbconf = $this->getDataFromSession("database"); |
| 310 | - $this->util->dbUtilities->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 | $server = $conf['server']; | 311 | $server = $conf['server']; |
| 312 | $paths = $conf['paths']; | 312 | $paths = $conf['paths']; |
| 313 | if ($this->util->isMigration()) { // Check if its an upgrade | 313 | if ($this->util->isMigration()) { // Check if its an upgrade |
| @@ -355,7 +355,7 @@ class configuration extends Step | @@ -355,7 +355,7 @@ class configuration extends Step | ||
| 355 | 355 | ||
| 356 | private function writeDBSection($server) { | 356 | private function writeDBSection($server) { |
| 357 | $dbconf = $this->getDataFromSession("database"); // retrieve database information from session | 357 | $dbconf = $this->getDataFromSession("database"); // retrieve database information from session |
| 358 | - $this->util->dbUtilities->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 |
| 359 | $server = $this->registerDBConfig($server, $dbconf); // add db config to server variables | 359 | $server = $this->registerDBConfig($server, $dbconf); // add db config to server variables |
| 360 | $table = 'config_settings'; | 360 | $table = 'config_settings'; |
| 361 | foreach($server as $item) { // write server settings to config_settings table and config.ini | 361 | foreach($server as $item) { // write server settings to config_settings table and config.ini |
| @@ -577,12 +577,41 @@ class configuration extends Step | @@ -577,12 +577,41 @@ class configuration extends Step | ||
| 577 | return $this->temp_variables['paths']['configFile']['path']; | 577 | return $this->temp_variables['paths']['configFile']['path']; |
| 578 | } | 578 | } |
| 579 | $configPath = $this->getContentPath(); | 579 | $configPath = $this->getContentPath(); |
| 580 | - if(!$configPath) return false; | 580 | + if(!$configPath) { |
| 581 | + return false; | ||
| 582 | + } | ||
| 581 | $this->util->iniUtilities->load($configPath); | 583 | $this->util->iniUtilities->load($configPath); |
| 582 | $data = $this->util->iniUtilities->getFileByLine(); | 584 | $data = $this->util->iniUtilities->getFileByLine(); |
| 583 | $firstline = true; | 585 | $firstline = true; |
| 584 | foreach ($data as $k=>$v) { | 586 | foreach ($data as $k=>$v) { |
| 585 | if(preg_match('/config.ini/', $k)) { // Find config.ini | 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 | + } | ||
| 586 | return $k; | 615 | return $k; |
| 587 | } | 616 | } |
| 588 | } | 617 | } |
setup/wizard/steps/database.php
| @@ -319,11 +319,11 @@ class database extends Step | @@ -319,11 +319,11 @@ class database extends Step | ||
| 319 | $this->error['dmsuserpassword'] = "Passwords do not match: " . $this->dmsuserpassword." ". $this->getPassword2(); | 319 | $this->error['dmsuserpassword'] = "Passwords do not match: " . $this->dmsuserpassword." ". $this->getPassword2(); |
| 320 | return false; | 320 | return false; |
| 321 | } | 321 | } |
| 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 | - } | 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()) { | 327 | if (!$this->util->dbUtilities->getDatabaseLink()) { |
| 328 | $this->error['con'] = "Could not connect to the database, please check username and password"; | 328 | $this->error['con'] = "Could not connect to the database, please check username and password"; |
| 329 | return false; | 329 | return false; |
| @@ -582,7 +582,7 @@ class database extends Step | @@ -582,7 +582,7 @@ class database extends Step | ||
| 582 | * @return object mysql connection | 582 | * @return object mysql connection |
| 583 | */ | 583 | */ |
| 584 | private function connectMysql() { | 584 | private function connectMysql() { |
| 585 | - $this->util->dbUtilities->load($this->dhost, $this->duname, $this->dpassword, $this->dname); | 585 | + $this->util->dbUtilities->load($this->dhost, $this->dport, $this->duname, $this->dpassword, $this->dname); |
| 586 | } | 586 | } |
| 587 | 587 | ||
| 588 | /** | 588 | /** |
| @@ -842,7 +842,7 @@ class database extends Step | @@ -842,7 +842,7 @@ class database extends Step | ||
| 842 | $this->dpassword = 'root'; | 842 | $this->dpassword = 'root'; |
| 843 | $this->dname = 'dms_install'; | 843 | $this->dname = 'dms_install'; |
| 844 | $this->dbbinary = 'mysql'; | 844 | $this->dbbinary = 'mysql'; |
| 845 | - $this->util->dbUtilities->load($this->dhost, $this->duname, $this->dpassword, $this->dname); | 845 | + $this->util->dbUtilities->load($this->dhost, '', $this->duname, $this->dpassword, $this->dname); |
| 846 | $this->createSchema(); | 846 | $this->createSchema(); |
| 847 | echo 'Schema loaded<br>'; | 847 | echo 'Schema loaded<br>'; |
| 848 | } | 848 | } |
setup/wizard/steps/install.php
| @@ -107,7 +107,7 @@ class install extends step | @@ -107,7 +107,7 @@ class install extends step | ||
| 107 | public function callHome() { | 107 | public function callHome() { |
| 108 | $conf = $this->getDataFromSession("install"); // retrieve database information from session | 108 | $conf = $this->getDataFromSession("install"); // retrieve database information from session |
| 109 | $dbconf = $this->getDataFromSession("database"); | 109 | $dbconf = $this->getDataFromSession("database"); |
| 110 | - $this->util->dbUtilities->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 | $complete = 1; | 111 | $complete = 1; |
| 112 | if($conf['call_home'] == 'enable'){ | 112 | if($conf['call_home'] == 'enable'){ |
| 113 | $complete = 0; | 113 | $complete = 0; |
setup/wizard/templates/complete.tpl
| @@ -136,7 +136,7 @@ | @@ -136,7 +136,7 @@ | ||
| 136 | <?php if($migrate_check) { ?> | 136 | <?php if($migrate_check) { ?> |
| 137 | <a href="../upgrade/index.php" class="back button_next" style="width:190px;" onclick="javascript:{w.clearSessions();}">Goto Database Upgrade</a> | 137 | <a href="../upgrade/index.php" class="back button_next" style="width:190px;" onclick="javascript:{w.clearSessions();}">Goto Database Upgrade</a> |
| 138 | <?php } else { ?> | 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 | <?php } ?> | 140 | <?php } ?> |
| 141 | <?php | 141 | <?php |
| 142 | if ($install_environment == 'Zend') { | 142 | if ($install_environment == 'Zend') { |
setup/wizard/templates/install.tpl
| @@ -10,7 +10,8 @@ | @@ -10,7 +10,8 @@ | ||
| 10 | </p> | 10 | </p> |
| 11 | <div class="demo"><?php echo $html->image('img_fatlogo.jpg'); ?></div> | 11 | <div class="demo"><?php echo $html->image('img_fatlogo.jpg'); ?></div> |
| 12 | <br/><br/> | 12 | <br/><br/> |
| 13 | - <p><input type='checkbox' name='call_home' value='enable' checked /> Help to improve KnowledgeTree by providing anonymous usage statistics</p> | 13 | +<p> <input class="" type='checkbox' name='call_home' value='enable' checked style="float:left;"/> |
| 14 | + Help to improve KnowledgeTree by providing anonymous usage statistics</p> | ||
| 14 | </div> | 15 | </div> |
| 15 | <input type="submit" name="Previous" value="Previous" class="button_previous"/> | 16 | <input type="submit" name="Previous" value="Previous" class="button_previous"/> |
| 16 | <input type="submit" name="Install" value="Install" class="button_next"/> | 17 | <input type="submit" name="Install" value="Install" class="button_next"/> |
setup/wizard/templates/welcome.tpl
| @@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
| 4 | <p class="empty_space"> This wizard will lead you through all the steps required to install and configure KnowledgeTree on your server.</p> | 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 | <p class="empty_space"> | 5 | <p class="empty_space"> |
| 6 | Press <b>Next</b> to continue.</p> | 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 | </div> | 8 | </div> |
| 9 | <input type="submit" name="Next" value="Next" class="button_next"/> | 9 | <input type="submit" name="Next" value="Next" class="button_next"/> |
| 10 | <!-- <input type="submit" name="Migrate" value="Migrate" class="button_next"/>--> | 10 | <!-- <input type="submit" name="Migrate" value="Migrate" class="button_next"/>--> |
templates/ktcore/forms/widgets/date.smarty
| 1 | <!-------------------------------------- | 1 | <!-------------------------------------- |
| 2 | ---- Changes for Custom Fields ----- | 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 | {literal} | 6 | {literal} |
| 7 | <script type="text/javascript"> | 7 | <script type="text/javascript"> |
webservice/clienttools/services/0.2/kt.php
| @@ -361,12 +361,8 @@ class kt extends client_service { | @@ -361,12 +361,8 @@ class kt extends client_service { | ||
| 361 | $items[]=array("name"=>"__document_extension", "index"=>0, "value"=>strtolower($fileParts['extension']), "control_type"=>"lookup", "selection"=>explode(',', str_replace('.', '', $params['extensions']))); | 361 | $items[]=array("name"=>"__document_extension", "index"=>0, "value"=>strtolower($fileParts['extension']), "control_type"=>"lookup", "selection"=>explode(',', str_replace('.', '', $params['extensions']))); |
| 362 | } | 362 | } |
| 363 | 363 | ||
| 364 | - $document_types=$this->get_documenttypes($params); | ||
| 365 | - $json_document_types=array(); | ||
| 366 | - foreach($document_types['items'] as $val) { | ||
| 367 | - $json_document_types[]=$val['name']; | ||
| 368 | - } | ||
| 369 | - $items[]=array("name"=>"__document_type", "index"=>0, "value"=>$document_type, "control_type"=>"lookup", "selection"=>$json_document_types); | 364 | + $document_types=$kt->get_documenttypes($params); |
| 365 | + $items[]=array("name"=>"__document_type", "index"=>0, "value"=>$document_type, "control_type"=>"lookup", "selection"=>$document_types); | ||
| 370 | 366 | ||
| 371 | foreach ($detail as $fieldset) { | 367 | foreach ($detail as $fieldset) { |
| 372 | foreach ($fieldset['fields'] as $field) { | 368 | foreach ($fieldset['fields'] as $field) { |