Commit 51231bd7cad23ebff42c2cbc00d8c4aa15981ddf

Authored by kevin_fourie
1 parent 73c5b1ca

Merged in from STABLE trunk...

KTS-3674
"Uno module required for pdf generation"
Fixed.

Committed By: Conrad Vermeulen
Reviewed By: Megan Watson


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/branches/3.5.3a-Release-Branch@9237 c91229c3-7414-0410-bfa2-8a42b809f60b
bin/openoffice/pdfgen.py
... ... @@ -6,37 +6,56 @@
6 6 # Document Management Made Simple
7 7 # Copyright (C) 2008 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 #
37 37  
38   -import uno
39   -import sys
  38 +import os, sys, glob
  39 +
  40 +extrapaths = glob.glob('/usr/lib*/openoffice*/program/') + glob.glob('/usr/lib*/ooo*/program') + [ '/Applications/NeoOffice.app/Contents/program', 'c:/program files/ktdms/openoffice/program' ]
  41 +
  42 +ooProgramPath = os.environ.get('ooProgramPath')
  43 +if not ooProgramPath is None:
  44 + extrapaths = [ ooProgramPath ] + extrapaths
  45 +
  46 +for path in extrapaths:
  47 + try:
  48 + sys.path.append(path)
  49 + import uno
  50 + os.environ['PATH'] = '%s:' % path + os.environ['PATH']
  51 + break
  52 + except ImportError:
  53 + sys.path.remove(path)
  54 + continue
  55 +else:
  56 + print >>sys.stderr, "PyODConverter: Cannot find the pyuno.so library in sys.path and known paths."
  57 + sys.exit(1)
  58 +
40 59 from com.sun.star.beans import PropertyValue
41 60  
42 61 NoConnectException = uno.getClass("com.sun.star.connection.NoConnectException")
... ... @@ -87,7 +106,7 @@ except RuntimeException, e:
87 106 if doc == None:
88 107 sys.stderr.write("The document could not be opened for conversion. This could indicate an unsupported mimetype.\n")
89 108 sys.exit(1)
90   -
  109 +
91 110  
92 111 ### Save File
93 112 properties = []
... ...
ktwebservice/KTDownloadManager.inc.php
... ... @@ -134,8 +134,8 @@ class KTDownloadManager
134 134 */
135 135 function download($document_id, $hash, $version = null)
136 136 {
137   - $sql = "SELECT 1 FROM download_files WHERE hash='$hash' AND session='$this->session' AND document_id=$document_id";
138   - $rows = DBUtil::getResultArray($sql);
  137 + $sql = "SELECT 1 FROM download_files WHERE hash=? AND session=? AND document_id=?";
  138 + $rows = DBUtil::getResultArray(array($sql, array($hash, $this->session, $document_id)));
139 139 if (PEAR::isError($rows))
140 140 {
141 141 return $rows;
... ...
plugins/ktstandard/KTEmail.php
... ... @@ -143,11 +143,11 @@ function sendExternalEmails($aEmailAddresses, $iDocumentID, $sDocumentName, $sCo
143 143 $sMessage = '<font face="arial" size="2">';
144 144 $sMessage .= sprintf(_kt("Your colleague, %s, wishes you to view the document entitled '%s'."), $oSendingUser->getName(), $sDocumentName);
145 145 $sMessage .= " \n";
146   - $sMessage .= _kt('Click on the hyperlink below to view it');
  146 + $sMessage .= _kt('Click on the hyperlink below to view it.') . '<br><br>';
147 147 $sMsgEnd = '<br><br>' . _kt('Comments') . ':<br>' . $sComment;
148 148 $sMsgEnd .= '</font>';
149 149  
150   - $sTitle = sprintf(_kt("Link: %s from %s"), $sDocumentName, $oSendingUser->getName());
  150 + $sTitle = sprintf(_kt("Link (ID %s): %s from %s"), $iDocumentID, $sDocumentName, $oSendingUser->getName());
151 151  
152 152 $sEmail = null;
153 153 $sEmailFrom = null;
... ... @@ -171,6 +171,8 @@ function sendExternalEmails($aEmailAddresses, $iDocumentID, $sDocumentName, $sCo
171 171 $oDownloadManager->set_session($session);
172 172 $link = $oDownloadManager->allow_download($iDocumentID);
173 173  
  174 + $link = "<a href=\"{$link}\">{$link}</a>";
  175 +
174 176 $sMsg = $sMessage.$link.$sMsgEnd;
175 177 $res = $oEmail->send(array($sAddress), $sTitle, $sMsg);
176 178  
... ... @@ -220,7 +222,7 @@ function sendEmailDocument($aDestEmailAddress, $iDocumentID, $sDocumentName, $sC
220 222 if (strlen($sComment) > 0) {
221 223 $sMessage .= '<br><br>' . _kt('Comments') . ':<br>' . $sComment;
222 224 }
223   - $sTitle = sprintf(_kt("Document: %s from %s"), $sDocumentName, $oSendingUser->getName());
  225 + $sTitle = sprintf(_kt("Document (ID %s): %s from %s"), $iDocumentID, $sDocumentName, $oSendingUser->getName());
224 226  
225 227 $sEmail = null;
226 228 $sEmailFrom = null;
... ... @@ -278,7 +280,7 @@ function sendEmailHyperlink($aDestEmailAddress, $iDocumentID, $sDocumentName, $s
278 280 */
279 281 $sMessage .= sprintf(_kt("Your colleague, %s, wishes you to view the document entitled '%s'."), $oSendingUser->getName(), $sDocumentName);
280 282 $sMessage .= " \n";
281   - $sMessage .= _kt('Click on the hyperlink below to view it.');
  283 + $sMessage .= _kt('Click on the hyperlink below to view it.') . '<br>';
282 284 // add the link to the document to the mail
283 285 $sMessage .= '<br>' . generateControllerLink('viewDocument', "fDocumentID=$iDocumentID", $sDocumentName, true);
284 286 // add optional comment
... ... @@ -286,7 +288,7 @@ function sendEmailHyperlink($aDestEmailAddress, $iDocumentID, $sDocumentName, $s
286 288 $sMessage .= '<br><br>' . _kt('Comments') . ':<br>' . $sComment;
287 289 }
288 290 $sMessage .= '</font>';
289   - $sTitle = sprintf(_kt("Link: %s from %s"), $sDocumentName, $oSendingUser->getName());
  291 + $sTitle = sprintf(_kt("Link (ID %s): %s from %s"), $iDocumentID, $sDocumentName, $oSendingUser->getName());
290 292 //email the hyperlink
291 293 //
292 294 $sEmail = null;
... ...
plugins/ktstandard/PDFGeneratorAction.php
... ... @@ -66,6 +66,7 @@ class PDFGeneratorAction extends KTDocumentAction {
66 66 function getDisplayName() {
67 67 $cmdpath = KTUtil::findCommand('externalBinary/python');
68 68 // Check if openoffice and python are available
  69 +
69 70 if($cmdpath != false && file_exists($cmdpath) && !empty($cmdpath)) {
70 71 $sDocType = $this->getMimeExtension();
71 72 // make sure that the selected document is of an acceptable extension
... ... @@ -178,6 +179,8 @@ class PDFGeneratorAction extends KTDocumentAction {
178 179 $oDocument = $this->oDocument;
179 180 $oStorage =& KTStorageManagerUtil::getSingleton();
180 181 $oConfig =& KTConfig::getSingleton();
  182 + $default = realpath(str_replace('\\','/',KT_DIR . '/../openoffice/program'));
  183 + putenv('ooProgramPath=' . $oConfig->get('openoffice/programPath', $default));
181 184 $cmdpath = KTUtil::findCommand('externalBinary/python');
182 185 // Check if openoffice and python are available
183 186 if($cmdpath == false || !file_exists($cmdpath) || empty($cmdpath)) {
... ...
search2/indexing/extractorCore.inc.php
... ... @@ -353,7 +353,7 @@ abstract class ExternalDocumentExtractor extends DocumentExtractor
353 353  
354 354 $config = KTConfig::getSingleton();
355 355  
356   - $default = realpath(str_replace('\\','/',KT_ROOT_DIR . '/../openoffice/program'));
  356 + $default = realpath(str_replace('\\','/',KT_DIR . '/../openoffice/program'));
357 357  
358 358 putenv('ooProgramPath=' . $config->get('openoffice/programPath', $default));
359 359 }
... ...