Commit 593039b93f48974bcd6c686176218fbdc5994b80

Authored by Paul Barrett
2 parents 374e34bd 8cca3a4f

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

lib/dashboard/Notification.inc.php
... ... @@ -6,31 +6,31 @@
6 6 * Document Management Made Simple
7 7 * Copyright (C) 2008, 2009 KnowledgeTree Inc.
8 8 * Portions copyright The Jam Warehouse Software (Pty) Limited
9   - *
  9 + *
10 10 * This program is free software; you can redistribute it and/or modify it under
11 11 * the terms of the GNU General Public License version 3 as published by the
12 12 * Free Software Foundation.
13   - *
  13 + *
14 14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 17 * details.
18   - *
  18 + *
19 19 * You should have received a copy of the GNU General Public License
20 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,
  21 + *
  22 + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco,
23 23 * California 94120-7775, or email info@knowledgetree.com.
24   - *
  24 + *
25 25 * The interactive user interfaces in modified source and object code versions
26 26 * of this program must display Appropriate Legal Notices, as required under
27 27 * Section 5 of the GNU General Public License version 3.
28   - *
  28 + *
29 29 * In accordance with Section 7(b) of the GNU General Public License version 3,
30 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
  31 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
32 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
  33 + * must display the words "Powered by KnowledgeTree" and retain the original
34 34 * copyright notice.
35 35 * Contributor( s): ______________________________________
36 36 *
... ... @@ -200,7 +200,10 @@ class KTSubscriptionNotification extends KTNotificationHandler {
200 200 "ModifyDocument" => 'document',
201 201 "CheckInDocument" => 'document',
202 202 "CheckOutDocument" => 'document',
203   - "MovedDocument" => 'document',
  203 + "MovedDocument" => 'folder',
  204 + "MovedDocument2" => 'document',
  205 + "CopiedDocument" => 'folder',
  206 + "CopiedDocument2" => 'document',
204 207 "ArchivedDocument" => 'document', // can go through and request un-archival (?)
205 208 "RestoredArchivedDocument" => 'document',
206 209 "DiscussDocument" => 'document',
... ...
lib/subscriptions/subscriptions.inc.php
... ... @@ -64,7 +64,9 @@ class SubscriptionEvent {
64 64 "CheckInDocument",
65 65 "CheckOutDocument",
66 66 "MovedDocument",
  67 + "MovedDocument2",
67 68 "CopiedDocument",
  69 + "CopiedDocument2",
68 70 "ArchivedDocument",
69 71 "RestoredArchivedDocument",
70 72 "DownloadDocument",
... ... @@ -364,15 +366,16 @@ class SubscriptionEvent {
364 366 }
365 367  
366 368 function MoveDocument($oMovedDocument, $oToFolder, $oFromFolder, $moveOrCopy = "MovedDocument") {
367   - $content = new SubscriptionContent(); // needed for i18n
368   - // OK: two actions: document registrants, folder registrants.
  369 + $parentId = $oToFolder->getId();
  370 +
  371 + // Document registrants
369 372 $aDocUsers = $this->_getSubscribers($oMovedDocument->getId(), $this->subscriptionTypes["Document"]);
  373 + $this->sendNotification($aDocUsers, $moveOrCopy.'2', $oMovedDocument->getName(), $oMovedDocument->getId(), $parentId);
  374 +
  375 + // Folder registrants
370 376 $aFromUsers = $this->_getSubscribers($oFromFolder->getId(), $this->subscriptionTypes["Folder"]);
371 377 $aFolderUsers = $this->_getSubscribers($oToFolder->getId(), $this->subscriptionTypes["Folder"]);
372   - $aUsers = array_merge($aDocUsers, $aFromUsers);
373   - $aUsers = array_merge($aUsers, $aFolderUsers);
374   -
375   - $parentId = $oToFolder->getId();
  378 + $aUsers = array_merge($aFromUsers, $aFolderUsers);
376 379 $this->sendNotification($aUsers, $moveOrCopy, $oMovedDocument->getName(), $oToFolder->getId(), $parentId);
377 380 }
378 381  
... ... @@ -542,7 +545,9 @@ class SubscriptionContent {
542 545 "CheckInDocument" => _kt('Document checked in'),
543 546 "CheckOutDocument" => _kt('Document checked out'),
544 547 "MovedDocument" => _kt('Document moved'),
  548 + "MovedDocument2" => _kt('Document moved'),
545 549 "CopiedDocument" => _kt('Document copied'),
  550 + "CopiedDocument2" => _kt('Document copied'),
546 551 "ArchivedDocument" => _kt('Document archived'), // can go through and request un-archival (?)
547 552 "DownloadDocument" => _kt('Document downloaded'),
548 553 "RestoredArchivedDocument" => _kt('Document restored'),
... ... @@ -660,6 +665,7 @@ class SubscriptionContent {
660 665 $links .= '&#160;|&#160;<a href="'.$url.'">'._kt('Clear Alert').'</a>';
661 666 break;
662 667 case 'MovedDocument':
  668 + case 'MovedDocument2':
663 669 $text = $modifyDocumentText;
664 670 $url = $rootUrl.'/notify.php?id='.$info['notify_id'];
665 671 if(!$bulk_action) $links = '<a href="'.$url.'">'._kt('View New Location').'</a>';
... ... @@ -667,6 +673,7 @@ class SubscriptionContent {
667 673 $links .= '&#160;|&#160;<a href="'.$url.'">'._kt('Clear Alert').'</a>';
668 674 break;
669 675 case 'CopiedDocument':
  676 + case 'CopiedDocument2':
670 677 $text = $copiedDocumentText;
671 678 $url = $rootUrl.'/notify.php?id='.$info['notify_id'];
672 679 if(!$bulk_action) $links = '<a href="'.$url.'">'._kt('View Document').'</a>';
... ... @@ -770,8 +777,10 @@ class SubscriptionContent {
770 777 "ModifyDocument" => 'document',
771 778 "CheckInDocument" => 'document',
772 779 "CheckOutDocument" => 'document',
773   - "MovedDocument" => 'document',
774   - "CopiedDocument" => 'document',
  780 + "MovedDocument" => 'folder',
  781 + "MovedDocument2" => 'document',
  782 + "CopiedDocument" => 'folder',
  783 + "CopiedDocument2" => 'document',
775 784 "ArchivedDocument" => 'document', // can go through and request un-archival (?)
776 785 "DownloadDocument" => 'document',
777 786 "RestoredArchivedDocument" => 'document',
... ...
setup/wizard/installUtil.php
... ... @@ -312,6 +312,59 @@ class InstallUtil {
312 312 return true;
313 313 }
314 314  
  315 + public function javaBridge() {
  316 + try {
  317 + $javaSystem = new Java('java.lang.System');
  318 + } catch (JavaException $e) {
  319 + return false;
  320 + }
  321 + return true;
  322 + }
  323 +
  324 + function tryJava1() {
  325 + $response = $this->pexec("java -version"); // Java Runtime Check
  326 + if(empty($response['out'])) {
  327 + return false;
  328 + }
  329 +
  330 + return array('response'=>$response, 'java'=>'java');
  331 + }
  332 +
  333 + function tryJava2() {
  334 + $response = $this->pexec("java"); // Java Runtime Check
  335 + if(empty($response['out'])) {
  336 + return false;
  337 + }
  338 +
  339 + return array('response'=>$response, 'java'=>'java');
  340 + }
  341 +
  342 + function tryJava3() {
  343 + $response = $this->pexec("whereis java"); // Java Runtime Check
  344 + if(empty($response['out'])) {
  345 + return false;
  346 + }
  347 + $broke = explode(' ', $response['out'][0]);
  348 + foreach ($broke as $r) {
  349 + $match = preg_match('/bin/', $r);
  350 + if($match) {
  351 + return array('response'=>$response, 'java'=>preg_replace('/java:/', '', $r));
  352 + }
  353 + }
  354 + }
  355 +
  356 + function getJava() {
  357 + $response = $this->tryJava1();
  358 + if(!is_array($response)) {
  359 + $response = $this->tryJava2();
  360 + if(!is_array($response)) {
  361 + $response = $this->tryJava3();
  362 + }
  363 + }
  364 +
  365 + return $response;
  366 + }
  367 +
315 368 /**
316 369 * Portably execute a command on any of the supported platforms.
317 370 *
... ...
setup/wizard/lib/services/unixLucene.php
... ... @@ -40,7 +40,8 @@
40 40 * @version Version 0.1
41 41 */
42 42  
43   -class unixLucene extends Service {
  43 +class unixLucene extends unixService {
  44 + public $util;
44 45 private $phpDir;
45 46 private $shutdownScript;
46 47 private $indexerDir;
... ... @@ -53,6 +54,7 @@ class unixLucene extends Service {
53 54  
54 55 public function __construct() {
55 56 $this->name = "KTLuceneTest";
  57 + $this->util = new InstallUtil();
56 58 }
57 59  
58 60 function load() {
... ... @@ -63,7 +65,7 @@ class unixLucene extends Service {
63 65 $this->setJavaXmx(512);
64 66 $this->setLuceneSource("ktlucene.jar");
65 67 $this->setLuceneSourceLoc("ktlucene.jar");
66   - $this->setPhpDir();
  68 +// $this->setPhpDir();
67 69 $this->setShutdownScript("shutdown.php");
68 70 }
69 71  
... ... @@ -170,7 +172,7 @@ class unixLucene extends Service {
170 172 }
171 173  
172 174 public function install() {
173   -
  175 + $this->start();
174 176 }
175 177  
176 178 public function status() {
... ... @@ -200,7 +202,7 @@ class unixLucene extends Service {
200 202 $state = $this->status();
201 203 if($state != 'STARTED') {
202 204 $cmd = "cd ".$this->getLuceneDir()."; ";
203   - $cmd .= "nohup java -jar ".$this->getLuceneSource()." &> ".SYS_LOG_DIR."lucene.log &";
  205 + $cmd .= "nohup java -jar ".$this->getLuceneSource()." > ".SYS_LOG_DIR."lucene.log 2>&1 & echo $!";
204 206 $response = $this->util->pexec($cmd);
205 207  
206 208 return $response;
... ...
setup/wizard/lib/services/unixScheduler.php
... ... @@ -40,9 +40,8 @@
40 40 * @version Version 0.1
41 41 */
42 42  
43   -class unixScheduler extends Service {
  43 +class unixScheduler extends unixService {
44 44 private $phpDir;
45   - private $schedulerPidFile;
46 45 private $schedulerDir;
47 46 private $schedulerSource;
48 47 private $schedulerSourceLoc;
... ... @@ -50,6 +49,7 @@ class unixScheduler extends Service {
50 49  
51 50 public function __construct() {
52 51 $this->name = "KTSchedulerTest";
  52 + $this->util = new InstallUtil();
53 53 }
54 54  
55 55 function load() {
... ... @@ -57,15 +57,6 @@ class unixScheduler extends Service {
57 57 $this->setSchedulerDir(SYSTEM_DIR."bin".DS);
58 58 $this->setSchedulerSource('schedulerTask.sh');
59 59 $this->setSchedulerSourceLoc('schedulerTask.sh');
60   - $this->setSchedulerPidFile("scheduler_test.pid");
61   - }
62   -
63   - private function setSchedulerPidFile($schedulerPidFile) {
64   - $this->schedulerPidFile = $schedulerPidFile;
65   - }
66   -
67   - private function getSchedulerPidFile() {
68   - return $this->schedulerPidFile;
69 60 }
70 61  
71 62 function setSystemDir($systemDir) {
... ... @@ -109,7 +100,8 @@ class unixScheduler extends Service {
109 100 $content = "#!/bin/sh\n";
110 101 $content .= "cd ".$this->getSchedulerDir()."\n";
111 102 $content .= "while true; do\n";
112   - $content .= "php "."\"{$this->getSchedulerDir()}{$this->getSchedulerSource()}\"";
  103 + // TODO : This will not work without CLI
  104 + $content .= "php -Cq scheduler.php\n";
113 105 $content .= "sleep 30\n";
114 106 $content .= "done";
115 107 fwrite($fp, $content);
... ... @@ -117,7 +109,7 @@ class unixScheduler extends Service {
117 109 }
118 110  
119 111 function install() {
120   -
  112 + $this->start();
121 113 }
122 114  
123 115 function uninstall() {
... ... @@ -151,18 +143,22 @@ class unixScheduler extends Service {
151 143  
152 144 function start() {
153 145 $source = $this->getSchedulerSourceLoc();
154   - if($source) {
155   - $cmd = "nohup ".$source." &> ".SYS_LOG_DIR."dmsctl.log";
  146 + if($source) { // Source
  147 + $cmd = "nohup ".$source." > ".SYS_LOG_DIR."scheduler.log 2>&1 & echo $!";
156 148 $response = $this->util->pexec($cmd);
157 149 return $response;
158 150 } else { // Could be Stack
159   - $source = $this->getSystemDir().$this->schedulerSource;
  151 + $source = SYS_BIN_DIR.$this->schedulerSource;
160 152 if(file_exists($source)) {
161   - $cmd = "nohup ".$source." &> ".SYS_LOG_DIR."dmsctl.log";
  153 + $cmd = "nohup ".$source." > ".SYS_LOG_DIR."scheduler.log 2>&1 & echo $!";
162 154 $response = $this->util->pexec($cmd);
163 155 return $response;
  156 + } else {
  157 + // Write it
  158 + $this->writeSchedulerTask();
164 159 }
165 160 }
  161 +
166 162 return false;
167 163 }
168 164  
... ...
setup/wizard/lib/services/unixService.php
... ... @@ -40,7 +40,7 @@
40 40 * @version Version 0.1
41 41 */
42 42  
43   -class windowsService extends Service {
  43 +class unixService extends Service {
44 44 /**
45 45 * Retrieve Service name
46 46 *
... ...
setup/wizard/step.php
... ... @@ -349,6 +349,18 @@ class Step
349 349 return '';
350 350 }
351 351  
  352 + /**
  353 + * Return whether or not to a step has to be in silent mode
  354 + *
  355 + * @author KnowledgeTree Team
  356 + * @param none
  357 + * @access public
  358 + * @return boolean
  359 + */
  360 + public function silentMode() {
  361 + return $this->silent;
  362 + }
  363 +
352 364 /**
353 365 * Set step errors
354 366 *
... ...
setup/wizard/steps/services.php
... ... @@ -49,7 +49,7 @@ class services extends Step
49 49 * @access public
50 50 * @var array
51 51 */
52   - public $error = array();
  52 + protected $error = array();
53 53  
54 54 /**
55 55 * Flag if step needs to be installed
... ... @@ -60,13 +60,13 @@ class services extends Step
60 60 */
61 61 protected $runInstall = true;
62 62  
63   - protected $services = array('Lucene', 'Scheduler');
  63 + private $services = array('Lucene', 'Scheduler');
64 64  
65 65 protected $java;
66 66  
67 67 protected $util;
68 68  
69   - protected $response;
  69 + private $response;
70 70  
71 71 private $javaVersion = '1.5';
72 72  
... ... @@ -79,7 +79,7 @@ class services extends Step
79 79 */
80 80 protected $storeInSession = false;
81 81  
82   - public $temp_variables;
  82 + protected $temp_variables;
83 83  
84 84 /**
85 85 * Constructs services object
... ... @@ -91,54 +91,9 @@ class services extends Step
91 91 public function __construct() {
92 92 $this->temp_variables = array("step_name"=>"services");
93 93 $this->util = new InstallUtil();
94   - $this->setJava();
95 94 }
96 95  
97   - function tryJava1() {
98   - $response = $this->util->pexec("java -version"); // Java Runtime Check
99   - if(empty($response['out'])) {
100   - return false;
101   - }
102   - $this->java = 'java';
103   - $this->response = $response;
104   - return true;
105   - }
106   -
107   - function tryJava2() {
108   - $response = $this->util->pexec("java"); // Java Runtime Check
109   - if(empty($response['out'])) {
110   - return false;
111   - }
112   - $this->java = 'java';
113   - $this->response = $response;
114   - return true;
115   - }
116   -
117   - function tryJava3() {
118   - $response = $this->util->pexec("whereis java"); // Java Runtime Check
119   - if(empty($response['out'])) {
120   - return false;
121   - }
122   - $broke = explode(' ', $response['out'][0]);
123   - foreach ($broke as $r) {
124   - $match = preg_match('/bin/', $r);
125   - if($match) {
126   - $this->java = preg_replace('/java:/', '', $r);
127   - $this->response = $response;
128   - return true;
129   - }
130   - }
131   - }
132   -
133   - function setJava() {
134   - $response = $this->tryJava1();
135   - if(!$response) {
136   - $response = $this->tryJava2();
137   - if(!$response) {
138   - $response = $this->tryJava3();
139   - }
140   - }
141   - }
  96 +
142 97  
143 98 function getJavaResponse() {
144 99 return $this->response;
... ... @@ -180,8 +135,15 @@ class services extends Step
180 135 * @return boolean
181 136 */
182 137 private function doRun() {
  138 + $javaSettings = $this->util->getJava();
  139 + $this->response = $javaSettings['response'];
  140 + $this->java = $javaSettings['java'];
183 141 if($this->javaChecks()) {
184 142 $this->installService();
  143 + } else { // Services not installed
  144 + foreach ($this->services as $serviceName) {
  145 + $this->temp_variables['services'][] = array('class'=>'cross', 'msg'=>$serviceName." Could not be added as a Service");
  146 + }
185 147 }
186 148 $errors = $this->getErrors();
187 149 if(!empty($errors))
... ... @@ -192,10 +154,12 @@ class services extends Step
192 154 public function javaChecks() {
193 155 $java = false;
194 156 $mods = get_loaded_extensions();
  157 + $mods = array_reverse($mods);
195 158 foreach ($mods as $k=>$v) {
196 159 if($v == 'Zend Java Bridge') {
197 160 $java = true;
198 161 }
  162 + if($java) break;
199 163 }
200 164 if($java) {
201 165 $this->temp_variables['extensions']['class'] = 'tick';
... ... @@ -203,31 +167,35 @@ class services extends Step
203 167 } else {
204 168 $this->temp_variables['extensions']['class'] = 'cross';
205 169 $this->temp_variables['extensions']['found'] = "Zend Java Bridge Required";
  170 + $this->error[] = "Zend Java Bridge Required";
206 171 }
207 172 if($this->java == '') {
208 173 $this->temp_variables['version']['class'] = 'cross';
209 174 $this->temp_variables['version']['found'] = "Java runtime environment required";
  175 + $this->error[] = "Java runtime environment required";
210 176 } else {
211 177 $this->temp_variables['java']['class'] = 'tick';
212 178 $this->temp_variables['java']['found'] = "Java Runtime Installed";
213 179 }
214   - if($java) {
215   - $javaSystem = new Java('java.lang.System');
  180 + if($this->util->javaBridge()) { // Check if java bridge is functional
  181 + $javaSystem = new Java('java.lang.System');
216 182 $version = $javaSystem->getProperty('java.version');
217 183 $ver = substr($version, 0, 3);
218 184 if($ver < $this->javaVersion) {
219 185 $this->temp_variables['version']['class'] = 'cross';
220 186 $this->temp_variables['version']['found'] = "Requires Java 1.5+ to be installed";
  187 + $this->error[] = "Requires Java 1.5+ to be installed";
221 188 } else {
222 189 $this->temp_variables['version']['class'] = 'tick';
223 190 $this->temp_variables['version']['found'] = "Java Version 1.5+ Installed";
224 191 }
225 192 } else {
226   - $this->temp_variables['version']['class'] = 'cross';
  193 + $this->temp_variables['version']['class'] = 'cross';
227 194 $this->temp_variables['version']['found'] = "Cannot detect Java system settings";
  195 + $this->error[] = "Cannot detect Java system settings";
228 196 return false;
229 197 }
230   -
  198 +
231 199 return true;
232 200 }
233 201 /**
... ...
setup/wizard/templates/services.tpl
... ... @@ -4,15 +4,6 @@
4 4 This checkup ensures that your environment is ready to support KnowledgeTree's background services.
5 5 </p>
6 6  
7   -<?php
8   -if($errors){
9   - echo '<div class="error">';
10   - foreach ($errors as $msg){
11   - echo $msg . "<br />\n";
12   - }
13   - echo '</div>';
14   -}
15   -?>
16 7 <h3>Java Version Check</h3>
17 8 <p class="description">
18 9 The Java version must be higher than 1.5.
... ...