Commit 3a97c8ad5d9b24ddc2e6180a7aed569db32b1b96

Authored by Charl Joseph Mert
2 parents 2fcd85ac 65b87499

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

plugins/ktstandard/PDFGeneratorAction.php
... ... @@ -255,9 +255,10 @@ class PDFGeneratorAction extends KTDocumentAction {
255 255 $converter->setDocument($this->oDocument);
256 256 $res = $converter->processDocument();
257 257  
258   - if(!$res){
  258 + if($res !== true){
  259 + // please contact your System Administrator
259 260 $default->log->error('PDF Generator: PDF file could not be generated');
260   - $this->errorRedirectToMain(_kt('PDF file could not be generated, the file may be of an unsupported mime type or the PDF Generator could not connect.'));
  261 + $this->errorRedirectToMain($res . ' ' . _kt('Please contact your System Administrator for assistance.'));
261 262 exit();
262 263 }
263 264  
... ... @@ -268,7 +269,22 @@ class PDFGeneratorAction extends KTDocumentAction {
268 269 }
269 270 exit();
270 271 }
271   - $this->errorRedirectToMain(_kt('PDF file could not be generated'));
  272 +
  273 + // Check if this is a office 2007 doc
  274 + $mime = $this->getMimeExtension();
  275 +
  276 + $o2007_types[] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
  277 + $o2007_types[] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
  278 + $o2007_types[] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
  279 +
  280 + if(in_array($mime, $o2007_types)){
  281 + $error = _kt('The document is an MS Office 2007 format. This may not be supported by your version of OpenOffice. Please contact your System Administrator for assistance');
  282 + $default->log->error('PDF Generator: Document is an MS Office 2007 format. OpenOffice must be version 3.0 or higher to support this format. Please upgrade to the latest version.');
  283 + }else{
  284 + $error = _kt('PDF file could not be generated. The format may not be supported by your version of OpenOffice. Please contact your System Administrator for assistance');
  285 + $default->log->error('PDF Generator: PDF file could not be generated. The format may not be supported by your version of OpenOffice. Please check that you have the latest version installed.');
  286 + }
  287 + $this->errorRedirectToMain($error);
272 288 exit();
273 289 }
274 290  
... ...
plugins/pdfConverter/pdfConverter.php
... ... @@ -48,6 +48,25 @@ class pdfConverter extends BaseProcessor
48 48 $this->ooPort = $config->get('openoffice/port','8100');
49 49  
50 50 $this->xmlrpc = XmlRpcLucene::get($javaServerUrl);
  51 +
  52 +
  53 +
  54 + }
  55 +
  56 + /**
  57 + * Check that open office is running
  58 + *
  59 + * @return boolean
  60 + */
  61 + private function checkOO()
  62 + {
  63 + $available = SearchHelper::checkOpenOfficeAvailablity();
  64 +
  65 + if(is_null($available)){
  66 + return true;
  67 + }
  68 +
  69 + return false;
51 70 }
52 71  
53 72 /**
... ... @@ -63,17 +82,26 @@ class pdfConverter extends BaseProcessor
63 82  
64 83 if(!file_exists($path)){
65 84 global $default;
66   - $default->log->debug('Document, id: '.$this->document->iId.', does not exist at given storage path: '.$path);
67   - return false;
  85 + $default->log->debug('PDF Converter: Document, id: '.$this->document->iId.', does not exist at given storage path: '.$path);
  86 + return _kt("The document, id: {$this->document->iId}, does not exist at the given storage path: {$path}");
68 87 }
69 88  
  89 + // check for OO
  90 + $available = $this->checkOO();
  91 +
70 92 // do pdf conversion
  93 + if(!$available){
  94 + global $default;
  95 + $default->log->error("PDF Converter: Cannot connect to Open Office Server on host {$this->ooHost} : {$this->ooPort}");
  96 + return _kt('Cannot connect to Open Office Server.');
  97 + }
  98 +
71 99 $res = $this->convertFile($path, $ext);
72 100  
73   - if($res === false){
  101 + if($res !== true){
74 102 global $default;
75   - $default->log->debug('Document, id: '.$this->document->iId.', could not be converted to pdf.');
76   - return false;
  103 + $default->log->debug('PDF Converter: Document, id: '.$this->document->iId.', could not be converted to pdf.');
  104 + return _kt("The document, id: {$this->document->iId}, could not be converted to pdf format. The following error occurred: \"{$res}\".");
77 105 }
78 106  
79 107 return true;
... ... @@ -169,11 +197,11 @@ class pdfConverter extends BaseProcessor
169 197 // Get contents and send to converter
170 198 $result = $this->xmlrpc->convertDocument($sourceFile, $targetFile, $this->ooHost, $this->ooPort);
171 199  
172   - if($result === false){
  200 + if(is_string($result)){
173 201 $default->log->error('PDF Converter Plugin: Conversion to PDF Failed');
174 202 @unlink($sourceFile);
175 203 @unlink($targetFile);
176   - return false;
  204 + return $result;
177 205 }
178 206  
179 207 $pdfDir = $default->pdfDirectory;
... ... @@ -196,7 +224,7 @@ class pdfConverter extends BaseProcessor
196 224 $res = @copy($targetFile, $pdfFile);
197 225 @unlink($sourceFile);
198 226 @unlink($targetFile);
199   - return $pdfFile;
  227 + return true;
200 228  
201 229 }
202 230 }
... ...
search2/indexing/lib/XmlRpcLucene.inc.php
... ... @@ -416,7 +416,7 @@ class XmlRpcLucene
416 416  
417 417 if($result->faultCode()) {
418 418 $this->error($result, 'convertDocument');
419   - return false;
  419 + return $result->faultString();
420 420 }
421 421 return php_xmlrpc_decode($result->value()) == 0;
422 422 }
... ...
setup/migrate/config/config.xml
... ... @@ -7,7 +7,7 @@
7 7 Description: Migrateer steps
8 8 -->
9 9  
10   -<migrate version="3.7" type="Commercial Edition">
  10 +<migrate version="3.7" type="Community Edition">
11 11 <steps>
12 12 <step name="Current Installation">installation</step>
13 13 <step name="Deactivate Services">services</step>
... ...
setup/migrate/migrateWizard.php
... ... @@ -261,7 +261,7 @@ class MigrateWizard {
261 261 }
262 262 } else {
263 263 // TODO: Die gracefully
264   - $this->util->error("System has been migrated <a href='../../login.php' class='back' style='width:80px;float:none'>Goto Login</a>");
  264 + $this->util->error("System has been migrated <a href='../../login.php' class='back' style='width:80px;float:none' back button_next>Goto Login</a>");
265 265 }
266 266 }
267 267 }
... ...
setup/migrate/steps/migrateDatabase.php
... ... @@ -134,7 +134,7 @@ class migrateDatabase extends Step
134 134 $exe = "'$location/mysql/bin/mysqldump'"; // Location of dump
135 135 }
136 136 $date = date('Y-m-d-H-i-s');
137   - if(isset($database)) {
  137 + if(isset($database['manual_export'])) {
138 138 $sqlFile = $database['manual_export'];
139 139 if(file_exists($sqlFile)) {
140 140 $manual = true;
... ... @@ -147,7 +147,7 @@ class migrateDatabase extends Step
147 147 if(!$manual) { // Try to export database
148 148 $sqlFile = $tmpFolder."/kt-backup-$date.sql";
149 149 $cmd = $exe.' -u"'.$dbAdminUser.'" -p"'.$dbAdminPass.'" --port="'.$port.'" '.$dbName.' > '.$sqlFile;
150   -// $response = $this->util->pexec($cmd);
  150 + $response = $this->util->pexec($cmd);
151 151 }
152 152 if(file_exists($sqlFile)) {
153 153 $fileContents = file_get_contents($sqlFile);
... ...
setup/upgrade/config/config.xml
... ... @@ -7,7 +7,7 @@
7 7 Description: Upgrader steps
8 8 -->
9 9  
10   -<upgrade version="3.7" type="Commercial Edition">
  10 +<upgrade version="3.7" type="Community Edition">
11 11 <steps>
12 12 <step name="Welcome">welcome</step>
13 13 <step name="Current Installation">installation</step>
... ...
setup/upgrade/templates/complete.tpl
... ... @@ -9,5 +9,5 @@
9 9 Your database has been upgraded to <?php echo $default->systemVersion; ?>
10 10 </div>
11 11 </div>
12   - <a href="../../" class="buttons back" style="width:100px;">Goto Login</a>
  12 + <a href="../../" class="back button_next" style="width:80px;" onclick="javascript:{w.clearSessions();}">Goto Login</a>
13 13 </form>
14 14 \ No newline at end of file
... ...
setup/wizard/installWizard.php
... ... @@ -296,7 +296,7 @@ class InstallWizard {
296 296 }
297 297 } else {
298 298 // TODO: Die gracefully
299   - $this->util->error("System has been installed <a href='../../login.php' class='back' style='width:80px;float:none'>Goto Login</a>");
  299 + $this->util->error("System has been installed <a href='../../login.php' class='back' style='width:80px;float:none' class='back button_next'>Goto Login</a>");
300 300 }
301 301 }
302 302 }
... ...
setup/wizard/lib/services/unixOpenOffice.php
... ... @@ -137,7 +137,7 @@ class unixOpenOffice extends unixService {
137 137 public function start() {
138 138 $state = $this->status();
139 139 if($state != 'STARTED') {
140   - $cmd = "nohup ".$this->getBin().' -nofirststartwizard -nologo -headless -accept="socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" '." > /dev/null 2>&1 & echo $!";
  140 + $cmd = "nohup ".$this->getBin().' -nofirststartwizard -nologo -headless -"accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" '." > /dev/null 2>&1 & echo $!";
141 141 if(DEBUG) {
142 142 echo "Command : $cmd<br/>";
143 143 return ;
... ...
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 -\"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/system/config-path-mock
1   -/var/lib/knowledgetree
2   -/var/lib/knowledgetree/Documents
3   -/var/lib/knowledgetree/indexes
4   -/etc/knowledgetree/config.ini
5   -/var/log/knowledgetree
6   -/var/tmp/knowledgetree
7   -/var/tmp/knowledgetree/proxies
8   -/var/tmp/knowledgetree/uploads
9   -/var/tmp/knowledgetree/cache
10 1 \ No newline at end of file
  2 +/var/lib/knowledgetree-ce
  3 +/var/lib/knowledgetree-ce/Documents
  4 +/var/lib/knowledgetree-ce/indexes
  5 +/etc/knowledgetree-ce/config.ini
  6 +/var/log/knowledgetree-ce
  7 +/var/tmp/knowledgetree-ce
  8 +/var/tmp/knowledgetree-ce/proxies
  9 +/var/tmp/knowledgetree-ce/uploads
  10 +/var/tmp/knowledgetree-ce/cache
11 11 \ No newline at end of file
... ...
setup/wizard/lib/validation/luceneValidation.php
... ... @@ -274,7 +274,7 @@ class luceneValidation extends serviceValidation {
274 274 if($auto) {
275 275 return $auto;
276 276 } else {
277   - $auto = $this->useDetected(); // Check if auto detected java works
  277 + $auto = $this->detSettings(); // Check if auto detected java works
278 278 if($auto) {
279 279 $this->disableExtension = true; // Disable the use of the php bridge extension
280 280 return $auto;
... ... @@ -372,7 +372,7 @@ class luceneValidation extends serviceValidation {
372 372 $javaExecutable = $this->java;
373 373 }
374 374 if(WINDOWS_OS) {
375   - $cmd .= "\"$javaExecutable\" -cp \"".SYS_DIR.";\" javaVersion \"".$this->outputDir."outJV\""." \"".$this->outputDir."outJVHome\"";
  375 + $cmd = "\"$javaExecutable\" -cp \"".SYS_DIR.";\" javaVersion \"".$this->outputDir."outJV\""." \"".$this->outputDir."outJVHome\"";
376 376 $func = OS."ReadJVFromFile";
377 377 if($this->$func($cmd)) return true;
378 378 } else {
... ... @@ -454,18 +454,6 @@ class luceneValidation extends serviceValidation {
454 454 }
455 455 }
456 456  
457   - /**
458   - * Attempt detection without logging errors
459   - *
460   - * @author KnowledgeTree Team
461   - * @param none
462   - * @access private
463   - * @return boolean
464   - */
465   - private function useDetected() {
466   - return $this->detSettings();
467   - }
468   -
469 457 /**
470 458 * Set all silent mode varibles
471 459 *
... ...
setup/wizard/steps/configuration.php
... ... @@ -53,6 +53,7 @@ if(isset($_GET[&#39;action&#39;])) {
53 53  
54 54 class configuration extends Step
55 55 {
  56 + private $allConfs;
56 57 /**
57 58 * Database host
58 59 *
... ... @@ -282,16 +283,19 @@ class configuration extends Step
282 283 }
283 284  
284 285 private function registerDirs() { // Adjust directories variables
285   - $this->readConfigPath();
286   - $dirs = $this->getFromConfigPath();
287   - $directories['varDirectory'] = array('section'=>'urls', 'value'=>addslashes($dirs['varDirectory']['path']), 'setting'=>'varDirectory');
288   - $directories['logDirectory'] = array('section'=>'urls', 'value'=>addslashes($dirs['logDirectory']['path']), 'setting'=>'logDirectory');
289   - $directories['documentRoot'] = array('section'=>'urls', 'value'=>addslashes($dirs['documentRoot']['path']), 'setting'=>'documentRoot');
  286 +// $this->readConfigPath();
  287 +// $dirs = $this->getFromConfigPath();
  288 +// print_r($dirs);
  289 + $directories['varDirectory'] = array('section'=>'urls', 'value'=>addslashes($this->allConfs['varDirectory']['path']), 'setting'=>'varDirectory');
  290 + $directories['logDirectory'] = array('section'=>'urls', 'value'=>addslashes($this->allConfs['logDirectory']['path']), 'setting'=>'logDirectory');
  291 + $directories['documentRoot'] = array('section'=>'urls', 'value'=>addslashes($this->allConfs['documentRoot']['path']), 'setting'=>'documentRoot');
290 292 $directories['uiDirectory'] = array('section'=>'urls', 'value'=>'${fileSystemRoot}/presentation/lookAndFeel/knowledgeTree', 'setting'=>'uiDirectory');
291   - $directories['tmpDirectory'] = array('section'=>'urls', 'value'=>addslashes($dirs['tmpDirectory']['path']), 'setting'=>'tmpDirectory');
  293 + $directories['tmpDirectory'] = array('section'=>'urls', 'value'=>addslashes($this->allConfs['tmpDirectory']['path']), 'setting'=>'tmpDirectory');
  294 + $directories['cacheDirectory'] = array('section'=>'cache', 'value'=>addslashes($this->allConfs['cacheDirectory']['path']), 'setting'=>'cacheDirectory');
292 295  
293 296 return $directories;
294 297 }
  298 +
295 299 /**
296 300 * Perform the installation associated with the step.
297 301 * Variables required by the installation are stored within the session.
... ... @@ -306,22 +310,24 @@ class configuration extends Step
306 310 $this->dbhandler->load($dbconf['dhost'], $dbconf['dmsname'], $dbconf['dmspassword'], $dbconf['dname']);
307 311 $server = $conf['server'];
308 312 $paths = $conf['paths'];
309   - // TODO
310 313 if ($this->util->isMigration()) { // Check if its an upgrade
  314 + $this->confpaths['configIni'] = $this->readConfigPathIni();
311 315 $this->readInstallation();
  316 + $configPath = $this->confpaths['configIni'];
312 317 } else {
313 318 $this->readConfigPath(); // initialise writing to config.ini
  319 + if(isset($this->confpaths['configIni'])) { // Check if theres a config path
  320 + $configPath = realpath("../../{$this->confpaths['configIni']}"); // Relative to Config Path File
  321 + if($configPath == '') { // Absolute path probably entered
  322 + $configPath = realpath("{$this->confpaths['configIni']}"); // Get relative path
  323 + }
  324 + } else {
  325 + $configPath = realpath('../../config/config.ini'); // Normal
  326 + }
314 327 }
315   - $dirs = $this->getFromConfigPath();
316   - if(isset($this->confpaths['configIni'])) { // Check if theres a config path
317   - $configPath = realpath("../../{$this->confpaths['configIni']}"); // Relative to Config Path File
318   - if($configPath == '') { // Absolute path probably entered
319   - $configPath = realpath("{$this->confpaths['configIni']}"); // Get relative path
320   - }
321   - } else {
322   - $configPath = realpath('../../config/config.ini');
323   - }
  328 + $this->getFromConfigPath();
324 329 $ini = false;
  330 +// print_r($configPath);
325 331 if(file_exists($configPath)) {
326 332 $ini = new iniUtilities($configPath);
327 333 }
... ... @@ -333,7 +339,7 @@ class configuration extends Step
333 339 }
334 340 $this->dbhandler->close(); // close the database connection
335 341 $this->writeCachePath(); // Write cache path file
336   - $this->writeConfigPath(); // Write config file
  342 + $this->writeConfigPath($configPath); // Write config file
337 343 }
338 344  
339 345 private function writeUrlSection($ini) {
... ... @@ -446,6 +452,7 @@ class configuration extends Step
446 452 {
447 453 if(isset($this->temp_variables['paths'])) {
448 454 if ($this->util->isMigration()) { // Check if its an upgrade
  455 + $this->confpaths['configIni'] = $this->readConfigPathIni();
449 456 $this->readInstallation(); // Read values from config.ini of other installation
450 457 $dirs = $this->getFromConfigPath(); // Store contents
451 458 } else {
... ... @@ -453,6 +460,7 @@ class configuration extends Step
453 460 }
454 461 } else {
455 462 if ($this->util->isMigration()) { // Check if its an upgrade
  463 + $this->confpaths['configIni'] = $this->readConfigPathIni();
456 464 $this->readInstallation(); // Read values from config.ini of other installation
457 465 } else {
458 466 $this->readConfigPath(); // Read contents of config-path file
... ... @@ -583,6 +591,7 @@ class configuration extends Step
583 591 }
584 592 $configs['varDirectory'] = array('name' => 'Var Directory', 'setting' => 'varDirectory', 'path' => $varPath, 'create' => false);
585 593  
  594 + $this->allConfs = $configs;
586 595 return $configs;
587 596 }
588 597  
... ... @@ -632,6 +641,21 @@ class configuration extends Step
632 641 return true;
633 642 }
634 643  
  644 + private function readConfigPathIni() {
  645 + $configPath = $this->getContentPath();
  646 + if(!$configPath) return false;
  647 + $ini = new iniUtilities($configPath);
  648 + $data = $ini->getFileByLine();
  649 + $firstline = true;
  650 + foreach ($data as $k=>$v) {
  651 + if(preg_match('/config.ini/', $k)) { // Find config.ini
  652 + return $k;
  653 + }
  654 + }
  655 +
  656 + return false;
  657 + }
  658 +
635 659 /**
636 660 * Read contents of config path file
637 661 *
... ... @@ -676,14 +700,14 @@ class configuration extends Step
676 700 }
677 701  
678 702 /**
679   - * Read contents of config path file
  703 + * Write location of config path file
680 704 *
681 705 * @author KnowledgeTree Team
682 706 * @access private
683 707 * @param none
684 708 * @return boolean
685 709 */
686   - private function writeConfigPath() {
  710 + private function writeConfigPath($configPath = '') {
687 711 $configPath = $this->getContentPath();
688 712 if(!$configPath) return false;
689 713 $ini = new iniUtilities($configPath);
... ... @@ -746,10 +770,6 @@ class configuration extends Step
746 770 if(!$cachePath) return false;
747 771 return $cachePath;
748 772 }
749   -
750   - public function doReadConfig() {
751   -
752   - }
753 773 }
754 774  
755 775 if(isset($_GET['action'])) {
... ...
setup/wizard/steps/database.php
... ... @@ -719,7 +719,14 @@ class database extends Step
719 719 * @return boolean
720 720 */
721 721 private function createDmsUser() {
722   - return $this->parse_mysql_dump($this->util->sqlInstallDir()."user.sql");
  722 + $user1 = "GRANT SELECT, INSERT, UPDATE, DELETE ON {$this->dname}.* TO {$this->dmsusername}@{$this->dhost} IDENTIFIED BY \"{$this->dmsuserpassword}\";";
  723 + $user2 = "GRANT ALL PRIVILEGES ON {$this->dname}.* TO {$this->dmsname}@{$this->dhost} IDENTIFIED BY \"{$this->dmspassword}\";";
  724 + if ($this->dbhandler->query($user1) && $this->dbhandler->query($user2)) {
  725 + return true;
  726 + } else {
  727 + $this->error['con'] = "Could not create users for database: {$this->dname}";
  728 + return false;
  729 + }
723 730 }
724 731  
725 732 /**
... ...
setup/wizard/templates/complete.tpl
... ... @@ -128,10 +128,13 @@
128 128  
129 129 $pos = strpos($script, '/setup/wizard/');
130 130 $root_url = substr($script, 0, $pos);
131   - $redirect = "http://".$_SERVER['SERVER_NAME'].$root_url."/admin.php";
  131 + if($port == '')
  132 + $redirect = "http://".$_SERVER['SERVER_NAME'].$root_url."/admin.php";
  133 + else
  134 + $redirect = "http://".$_SERVER['SERVER_NAME'].":$port".$root_url."/admin.php";
132 135 ?>
133 136 <?php if($migrate_check) { ?>
134   - <a href="../../login.php?redirect=<?php echo $redirect; ?>" class="back button_next" style="width:80px;" onclick="javascript:{w.clearSessions();}">Goto Login</a>
  137 + <a href="../upgrade" class="back button_next" style="width:190px;" onclick="javascript:{w.clearSessions();}">Goto Database Upgrade</a>
135 138 <?php } else { ?>
136 139 <a href="../../login.php?redirect=<?php echo $redirect; ?>" class="back button_next" style="width:80px;" onclick="javascript:{w.clearSessions();}">Goto Login</a>
137 140 <?php } ?>
... ...
setup/wizard/templates/welcome.tpl
... ... @@ -4,6 +4,7 @@
4 4 <p class="empty_space"> This wizard will lead you through all the steps required to install and configure KnowledgeTree on your server.</p>
5 5 <p class="empty_space">
6 6 Press <b>Next</b> to continue.</p>
  7 + <div class="demo"><?php echo $html->image('kt_browse.png'); ?> </div>
7 8 </div>
8 9 <input type="submit" name="Next" value="Next" class="button_next"/>
9 10 <!-- <input type="submit" name="Migrate" value="Migrate" class="button_next"/>-->
... ...