Commit ab1e744c11a9fedcfaf95383f9c47c7aa1279da4

Authored by Megan Watson
2 parents b6cd6507 c7b70a08

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

.gitignore
... ... @@ -14,3 +14,4 @@ clienttools/Office
14 14 *.out
15 15 baobab/
16 16 ktoffice*/
  17 +setup/wizard/install.lock
... ...
setup/upgrade/config/databases.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +
  3 +<!--
  4 + Document : database.xml
  5 + Created on : 01 July 2009, 1:13 PM
  6 + Author : KnowledgeTree Team
  7 + Description: Installer Default MySql Database Configuration
  8 +-->
  9 +
  10 +<database>
  11 + <dtypes>
  12 + <dtype>mysql</dtype>
  13 + </dtypes>
  14 + <dhost>localhost</dhost>
  15 + <dport>3306</dport>
  16 + <dname>dms</dname>
  17 + <duname>root</duname>
  18 + <dmsadminuser>dmsadmin</dmsadminuser>
  19 + <dmsaupass>js9281djw</dmsaupass>
  20 + <dmsuser>dms</dmsuser>
  21 + <dmsupass>djw9281js</dmsupass>
  22 +</database>
... ...
setup/upgrade/session.php 0 → 100644
  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 session
  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 +?>
0 225 \ No newline at end of file
... ...
setup/upgrade/steps/upgradeBackup.php
... ... @@ -40,7 +40,7 @@
40 40 * @version Version 0.1
41 41 */
42 42  
43   -require_once('../../config/dmsDefaults.php');
  43 +//require_once('../../config/dmsDefaults.php');
44 44  
45 45 class upgradeBackup extends Step {
46 46 protected $silent = false;
... ...
setup/upgrade/steps/upgradeComplete.php
... ... @@ -40,7 +40,7 @@
40 40 * @version Version 0.1
41 41 */
42 42  
43   -require_once('../../config/dmsDefaults.php');
  43 +//require_once('../../config/dmsDefaults.php');
44 44  
45 45 class upgradeComplete extends Step {
46 46  
... ...
setup/upgrade/steps/upgradeDatabase.php
... ... @@ -40,10 +40,10 @@
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 +//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');
47 47  
48 48 class upgradeDatabase extends Step
49 49 {
... ...
setup/upgrade/steps/upgradeRestore.php
... ... @@ -40,7 +40,7 @@
40 40 * @version Version 0.1
41 41 */
42 42  
43   -require_once('../../config/dmsDefaults.php');
  43 +//require_once('../../config/dmsDefaults.php');
44 44  
45 45 class upgradeRestore extends Step {
46 46  
... ...
setup/upgrade/steps/upgradeWelcome.php
... ... @@ -40,14 +40,12 @@
40 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 43 class upgradeWelcome extends step {
47 44  
48 45 protected $silent = false;
49 46 protected $temp_variables = array();
50   -
  47 + protected $error = array() ;
  48 +
51 49 public function doStep() {
52 50 $this->temp_variables = array("step_name"=>"welcome");
53 51 if($this->next()) {
... ... @@ -81,9 +79,18 @@ class upgradeWelcome extends step {
81 79 }
82 80  
83 81 private function checkPassword($username, $password) {
84   -/*
85   - $dconf = $this->getDataFromPackage('installers', 'database');
86   - $this->dbhandler->load($dconf['dhost'], $dconf['duname'], $dconf['dpassword'], $dconf['dname']);
  82 + $dconf = $this->getDataFromPackage('installers', 'database'); // Use info from install
  83 + if($dconf) {
  84 + $this->dbhandler->load($dconf['dhost'], $dconf['duname'], $dconf['dpassword'], $dconf['dname']);
  85 + } else {
  86 + require_once("../wizard/iniUtilities.php"); // ini to read the ini content
  87 + require_once("../wizard/steps/configuration.php"); // configuration to read the ini path
  88 + $wizConfigHandler = new configuration();
  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']);
  93 + }
87 94 $sQuery = "SELECT count(*) AS match_count FROM users WHERE username = '$username' AND password = '".md5($password)."'";
88 95 $res = $this->dbhandler->query($sQuery);
89 96 $ass = $this->dbhandler->fetchAssoc($res);
... ... @@ -91,28 +98,15 @@ class upgradeWelcome extends step {
91 98 if($ass[0]['match_count'])
92 99 return true;
93 100 }
  101 + $this->error[] = 'Could Not Authenticate User';
94 102 return false;
95   - */
96   -
97   - global $default;
98   -
99   - $sTable = KTUtil::getTableName('users');
100   - $sQuery = "SELECT count(*) AS match_count FROM $sTable WHERE username = ? AND password = ?";
101   - $aParams = array($username, md5($password));
102   - $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'match_count');
103   - if (PEAR::isError($res)) { return false; }
104   - else {
105   - $sTable = KTUtil::getTableName('users_groups_link');
106   - $sQuery = "SELECT count(*) AS match_count FROM $sTable WHERE user_id = ? AND group_id = 1";
107   - $aParams = array($res);
108   - $res = DBUtil::getOneResultKey(array($sQuery, $aParams), 'match_count');
109   - if (PEAR::isError($res)) { return false; }
110   - else {
111   - return ($res == 1);
112   - }
113   - }
114 103 }
115 104  
  105 + public function getErrors() {
  106 + return $this->error;
  107 + }
  108 +
  109 +
116 110 }
117 111  
118 112 ?>
119 113 \ No newline at end of file
... ...
setup/upgrade/templates/welcome.tpl
... ... @@ -9,9 +9,14 @@
9 9 <p class="empty_space"> Only administrator users may access the upgrade wizard. </p>
10 10 <div class="demo">
11 11 <table>
12   - <tr><td>Username<td><input name=username>
13   - <tr><td>Password<td><input name=password type="password">
  12 + <tr><td>Username</td><td><input name=username></td></tr>
  13 + <tr><td>Password</td><td><input name=password type="password"></td></tr>
  14 + <?php if (!empty($errors)) { ?><tr><td></td><td><span class="error">Could Not Authenticate User</span></td></tr> <?php } ?>
  15 + <?php
  16 +// print_r($errors);
  17 + ?>
14 18 </table>
  19 +
15 20 </div>
16 21 </div>
17 22 <?php
... ...
setup/upgrade/upgradeUtil.php
... ... @@ -40,7 +40,7 @@
40 40 * @version Version 0.1
41 41 */
42 42  
43   -require_once('../../config/dmsDefaults.php');
  43 +//require_once('../../config/dmsDefaults.php');
44 44 require_once("../wizard/installUtil.php");
45 45  
46 46 class UpgradeUtil extends InstallUtil {
... ...
setup/upgrade/upgradeWizard.php
... ... @@ -117,7 +117,7 @@ class UpgradeWizard {
117 117 $ins = new Upgrader(); // Instantiate the upgrader
118 118 $ins->resolveErrors($response); // Run step
119 119 } else {
120   - $ins = new Upgrader(new UpgradeSession()); // Instantiate the upgrader and pass the session class
  120 + $ins = new Upgrader(new session()); // Instantiate the upgrader and pass the session class
121 121 $ins->step(); // Run step
122 122 }
123 123 }
... ...
setup/wizard/installUtil.php
... ... @@ -748,17 +748,17 @@ class InstallUtil {
748 748 */
749 749 public function useZendPhp() {
750 750 if($this->installEnvironment() == 'Zend') {
751   - if(WINDOWS_OS) {
  751 + if(WINDOWS_OS) { // For Zend Installation only
752 752 $sysdir = explode(DS, SYSTEM_DIR);
753 753 array_pop($sysdir);
754 754 array_pop($sysdir);
755   - array_pop($sysdir);
756   - array_pop($sysdir);
757 755 $zendsys = '';
758 756 foreach ($sysdir as $k=>$v) {
759 757 $zendsys .= $v.DS;
760 758 }
761   - return $zendsys."ZendServer".DS."bin".DS;
  759 + $bin = $zendsys."ZendServer".DS."bin".DS;
  760 + if(file_exists($bin))
  761 + return $bin;
762 762 } else {
763 763 return DS."usr".DS."local".DS."zend".DS."bin".DS;
764 764 }
... ...
setup/wizard/lib/services/windowsLucene.php
... ... @@ -377,10 +377,32 @@ class windowsLucene extends windowsService {
377 377 } elseif (file_exists($this->getJavaBin().DS."bin".DS."server".DS."jvm.dll")) {
378 378 $this->javaJVM = $this->getJavaBin().DS."bin".DS."server".DS."jvm.dll";
379 379 } else {
380   - return false;
  380 + $javaJVM = $this->useZendJVM();
  381 + if(file_exists($javaJVM)) {
  382 + $this->javaJVM = $javaJVM;
  383 + }
381 384 }
382 385 }
383 386  
  387 + public function useZendJVM() {
  388 + if($this->util->installEnvironment() == 'Zend') {
  389 + if(WINDOWS_OS) { // For Zend Installation only
  390 + $sysdir = explode(DS, SYSTEM_DIR);
  391 + array_pop($sysdir);
  392 + array_pop($sysdir);
  393 + $zendsys = '';
  394 + foreach ($sysdir as $k=>$v) {
  395 + $zendsys .= $v.DS;
  396 + }
  397 + $jvm = $zendsys."jre".DS."bin".DS."client".DS."jvm.dll";
  398 + if(file_exists($jvm))
  399 + return $jvm;
  400 + }
  401 + }
  402 +
  403 + return false;
  404 + }
  405 +
384 406 /**
385 407 * Get Java JVM path
386 408 *
... ...
setup/wizard/lib/services/windowsOpenOffice.php
... ... @@ -203,7 +203,7 @@ class windowsOpenOffice extends windowsService {
203 203 //$binary = $this->util->openOfficeSpecified();
204 204 $binary = $this->getBin();
205 205 if($binary != '') {
206   - $cmd = "\"{$this->winservice}\" install $this->name "."-displayname {$this->name} -start auto \"".$binary."\" -headless -invisible -\"accept=socket,host={$this->host},port={$this->port};urp;\"";;
  206 + $cmd = "\"{$this->winservice}\" install $this->name "."-displayname {$this->name} -start auto \"".$binary."\" -headless -invisible -nofirststartwizard -\"accept=socket,host={$this->host},port={$this->port};urp;\"";;
207 207 if(DEBUG) {
208 208 echo "Command : $cmd<br/>";
209 209 return ;
... ...
setup/wizard/lib/services/windowsScheduler.php
... ... @@ -209,6 +209,9 @@ class windowsScheduler extends windowsService {
209 209 echo '<pre>';
210 210 print_r(array('service' => $this->name, 'display' => $this->name, 'path' => $this->getSchedulerScriptPath()));
211 211 echo '</pre>';
  212 + echo '<pre>';
  213 + print_r(file_get_contents($this->getSchedulerScriptPath()));
  214 + echo '</pre>';
212 215 return ;
213 216 }
214 217 $response = win32_create_service(array(
... ...
setup/wizard/lib/validation/luceneValidation.php
... ... @@ -355,6 +355,25 @@ class luceneValidation extends serviceValidation {
355 355 }
356 356 }
357 357  
  358 + public function useZendJava() {
  359 + if($this->util->installEnvironment() == 'Zend') {
  360 + if(WINDOWS_OS) { // For Zend Installation only
  361 + $sysdir = explode(DS, SYSTEM_DIR);
  362 + array_pop($sysdir);
  363 + array_pop($sysdir);
  364 + $zendsys = '';
  365 + foreach ($sysdir as $k=>$v) {
  366 + $zendsys .= $v.DS;
  367 + }
  368 + $java = $zendsys."jre".DS."bin".DS."java.exe";
  369 + if(file_exists($java))
  370 + return $java;
  371 + }
  372 + }
  373 +
  374 + return false;
  375 + }
  376 +
358 377 /**
359 378 * Attempts to use user input and configure java settings
360 379 *
... ... @@ -374,11 +393,24 @@ class luceneValidation extends serviceValidation {
374 393 if(WINDOWS_OS) {
375 394 $cmd = "\"$javaExecutable\" -cp \"".SYS_DIR.";\" javaVersion \"".$this->outputDir."outJV\""." \"".$this->outputDir."outJVHome\"";
376 395 $func = OS."ReadJVFromFile";
377   - if($this->$func($cmd)) return true;
  396 + if($this->$func($cmd)) {
  397 + return true;
  398 + } else {
  399 + $this->java = $this->useZendJava(); // Java not installed
  400 + $javaExecutable = $this->java;
  401 + $cmd = "\"$javaExecutable\" -cp \"".SYS_DIR.";\" javaVersion \"".$this->outputDir."outJV\""." \"".$this->outputDir."outJVHome\"";
  402 + if($this->$func($cmd)) {
  403 + return true;
  404 + }
  405 + }
378 406 } else {
379 407 $cmd = "\"$javaExecutable\" -version > ".$this->outputDir."outJV 2>&1 echo $!";
380 408 $func = OS."ReadJVFromFile";
381   - if($this->$func($cmd)) return true;
  409 + if($this->$func($cmd)) {
  410 + return true;
  411 + } else {
  412 + // TODO: Not sure
  413 + }
382 414 }
383 415  
384 416 $this->javaVersionInCorrect();
... ...
setup/wizard/lib/validation/openofficeValidation.php
... ... @@ -159,9 +159,33 @@ class openofficeValidation extends serviceValidation {
159 159 return $pathToBinary;
160 160 }
161 161 }
162   -
  162 + $pathToBinary = $this->useZendOffice(); // Check for openoffice in zend
  163 + if(file_exists($pathToBinary)) {
  164 + return $pathToBinary;
  165 + }
  166 +
163 167 return false;
164 168 }
  169 +
  170 + public function useZendOffice() {
  171 + if($this->util->installEnvironment() == 'Zend') {
  172 + if(WINDOWS_OS) { // For Zend Installation only
  173 + $sysdir = explode(DS, SYSTEM_DIR);
  174 + array_pop($sysdir);
  175 + array_pop($sysdir);
  176 + $zendsys = '';
  177 + foreach ($sysdir as $k=>$v) {
  178 + $zendsys .= $v.DS;
  179 + }
  180 + $soffice = $zendsys."openoffice".DS."program".DS."soffice.exe";
  181 + if(file_exists($soffice))
  182 + return $soffice;
  183 + }
  184 + }
  185 +
  186 + return false;
  187 + }
  188 +
165 189 /**
166 190 * Set all silent mode varibles
167 191 *
... ...
setup/wizard/steps/configuration.php
... ... @@ -576,7 +576,7 @@ class configuration extends Step
576 576 return true;
577 577 }
578 578  
579   - private function readConfigPathIni() {
  579 + public function readConfigPathIni() {
580 580 if(isset($this->temp_variables['paths']['configFile']['path'])) {
581 581 return $this->temp_variables['paths']['configFile']['path'];
582 582 }
... ...
setup/wizard/steps/database.php
... ... @@ -441,6 +441,8 @@ class database extends Step
441 441 $this->temp_variables['tprefix'] = '';
442 442 $this->temp_variables['ddrop'] = false;
443 443 }
  444 +
  445 + return $this->temp_variables;
444 446 }
445 447  
446 448 /**
... ... @@ -493,11 +495,12 @@ class database extends Step
493 495 * Read xml config file
494 496 *
495 497 * @author KnowledgeTree Team
496   - * @access private
  498 + * @access public
497 499 * @params none
498 500 * @return object SimpleXmlObject
499 501 */
500   - private function readXml() {
  502 + public function readXml() {
  503 +// echo CONF_DIR."databases.xml";
501 504 $simplexml = simplexml_load_file(CONF_DIR."databases.xml");
502 505  
503 506 return $simplexml;
... ...