Merge branch 'seeddms-5.1.x' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2017-03-03 09:43:45 +01:00
commit 012d4d9f8d
15 changed files with 159 additions and 135 deletions

View File

@ -25,6 +25,7 @@
--------------------------------------------------------------------------------
Changes in version 5.1.1
--------------------------------------------------------------------------------
- fix initial creation of postgres database
--------------------------------------------------------------------------------
Changes in version 5.1.0
@ -111,6 +112,8 @@
--------------------------------------------------------------------------------
Changes in version 4.3.34
--------------------------------------------------------------------------------
- add multibyte save basename() replacement, which fixes uploading files whose
name starts with a multibyte char
--------------------------------------------------------------------------------
Changes in version 4.3.33

View File

@ -31,24 +31,25 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
2 => array("pipe", "w")
);
$pipes = array();
$timeout += time();
$timeout += time();
$process = proc_open($cmd, $descriptorspec, $pipes);
if (!is_resource($process)) {
throw new Exception("proc_open failed on: " . $cmd);
}
$output = '';
$timeleft = $timeout - time();
$read = array($pipes[1]);
$write = NULL;
$exeptions = NULL;
do {
$timeleft = $timeout - time();
$read = array($pipes[1]);
$write = NULL;
$exeptions = NULL;
stream_select($read, $write, $exeptions, $timeleft, 200000);
if (!empty($read)) {
$output .= fread($pipes[1], 8192);
}
}
$timeleft = $timeout - time();
} while (!feof($pipes[1]) && $timeleft > 0);
if ($timeleft <= 0) {
@ -127,19 +128,12 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
$mimetype = $version->getMimeType();
if(isset($_convcmd[$mimetype])) {
$cmd = sprintf($_convcmd[$mimetype], $path);
$content = self::execWithTimeout($cmd, $timeout);
/*
$fp = popen($cmd, 'r');
if($fp) {
$content = '';
while(!feof($fp)) {
$content .= fread($fp, 2048);
try {
$content = self::execWithTimeout($cmd, $timeout);
if($content) {
$this->addField(Zend_Search_Lucene_Field::UnStored('content', $content, 'utf-8'));
}
pclose($fp);
}
*/
if($content) {
$this->addField(Zend_Search_Lucene_Field::UnStored('content', $content, 'utf-8'));
} catch (Exception $e) {
}
}
}

View File

@ -11,11 +11,11 @@
<email>uwe@steinmann.cx</email>
<active>yes</active>
</lead>
<date>2016-04-28</date>
<time>08:11:19</time>
<date>2017-03-01</date>
<time>15:55:32</time>
<version>
<release>1.1.9</release>
<api>1.1.7</api>
<release>1.1.10</release>
<api>1.1.10</api>
</version>
<stability>
<release>stable</release>
@ -23,8 +23,7 @@
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
pass variables to stream_select() to fullfill strict standards.
make all functions in Indexer.php static
catch exception in execWithTimeout()
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">
@ -235,5 +234,22 @@ add command for indexing postѕcript files
set last parameter of stream_select() to 200000 micro sec. in case the timeout in sec. is set to 0
</notes>
</release>
<release>
<date>2016-04-28</date>
<time>08:11:19</time>
<version>
<release>1.1.9</release>
<api>1.1.7</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
pass variables to stream_select() to fullfill strict standards.
make all functions in Indexer.php static
</notes>
</release>
</changelog>
</package>

View File

@ -89,8 +89,13 @@ class SeedDMS_Preview_PdfPreviewer extends SeedDMS_Preview_Base {
$target = $this->previewDir.$dir.md5($infile);
if($target != '' && (!file_exists($target.'.pdf') || filectime($target.'.pdf') < filectime($infile))) {
$cmd = '';
$mimeparts = explode('/', $mimetype, 2);
if(isset($this->converters[$mimetype])) {
$cmd = str_replace(array('%f', '%o'), array($infile, $target.'.pdf'), $this->converters[$mimetype]);
$cmd = str_replace(array('%f', '%o', '%m'), array($infile, $target.'.pdf', $mimetype), $this->converters[$mimetype]);
} elseif(isset($this->converters[$mimeparts[0].'/*'])) {
$cmd = str_replace(array('%f', '%o', '%m'), array($infile, $target.'.pdf', $mimetype), $this->converters[$mimeparts[0].'/*']);
} elseif(isset($this->converters['*'])) {
$cmd = str_replace(array('%f', '%o', '%m'), array($infile, $target.'.pdf', $mimetype), $this->converters['*']);
}
if($cmd) {
try {

View File

@ -106,9 +106,15 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base {
$target = $this->previewDir.$dir.md5($infile).'-'.$width;
if($target != '' && (!file_exists($target.'.png') || filectime($target.'.png') < filectime($infile))) {
$cmd = '';
$mimeparts = explode('/', $mimetype, 2);
if(isset($this->converters[$mimetype])) {
$cmd = str_replace(array('%w', '%f', '%o'), array($width, $infile, $target.'.png'), $this->converters[$mimetype]);
$cmd = str_replace(array('%w', '%f', '%o', '%m'), array($width, $infile, $target.'.png', $mimetype), $this->converters[$mimetype]);
} elseif(isset($this->converters[$mimeparts[0].'/*'])) {
$cmd = str_replace(array('%w', '%f', '%o', '%m'), array($width, $infile, $target.'.png', $mimetype), $this->converters[$mimeparts[0].'/*']);
} elseif(isset($this->converters['*'])) {
$cmd = str_replace(array('%w', '%f', '%o', '%m'), array($width, $infile, $target.'.png', $mimetype), $this->converters['*']);
}
/*
switch($mimetype) {
case "image/png":
@ -131,7 +137,6 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base {
}
*/
if($cmd) {
//exec($cmd);
try {
self::execWithTimeout($cmd, $this->timeout);
} catch(Exception $e) {

View File

@ -11,10 +11,10 @@
<email>uwe@steinmann.cx</email>
<active>yes</active>
</lead>
<date>2016-11-15</date>
<time>21:00:26</time>
<date>2017-03-02</date>
<time>07:14:59</time>
<version>
<release>1.2.1</release>
<release>1.2.2</release>
<api>1.2.0</api>
</version>
<stability>
@ -23,7 +23,8 @@
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
setConverters() overrides exiting converters
commands can be set for mimetypes 'xxxx/*' and '*'
pass mimetype as parameter '%m' to converter
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">
@ -254,5 +255,21 @@ check if cache dir exists before deleting it in deleteDocumentPreviews()
add new previewer which converts document to pdf instead of png
</notes>
</release>
<release>
<date>2016-11-15</date>
<time>21:00:26</time>
<version>
<release>1.2.1</release>
<api>1.2.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
setConverters() overrides exiting converters
</notes>
</release>
</changelog>
</package>

View File

@ -37,7 +37,7 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
);
$pipes = array();
$timeout += time();
$timeout += time();
$process = proc_open($cmd, $descriptorspec, $pipes);
if (!is_resource($process)) {
throw new Exception("proc_open failed on: " . $cmd);
@ -53,7 +53,7 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
if (!empty($read)) {
$output .= fread($pipes[1], 8192);
}
}
$timeleft = $timeout - time();
} while (!feof($pipes[1]) && $timeleft > 0);
@ -133,9 +133,12 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
$mimetype = $version->getMimeType();
if(isset($_convcmd[$mimetype])) {
$cmd = sprintf($_convcmd[$mimetype], $path);
$content = self::execWithTimeout($cmd, $timeout);
if($content) {
$this->addField('content', $content, 'unstored');
try {
$content = self::execWithTimeout($cmd, $timeout);
if($content) {
$this->addField('content', $content, 'unstored');
}
} catch (Exception $e) {
}
}
}

View File

@ -11,11 +11,11 @@
<email>uwe@steinmann.cx</email>
<active>yes</active>
</lead>
<date>2016-03-29</date>
<time>08:09:48</time>
<date>2017-03-01</date>
<time>15:53:24</time>
<version>
<release>1.0.6</release>
<api>1.0.1</api>
<release>1.0.7</release>
<api>1.0.7</api>
</version>
<stability>
<release>stable</release>
@ -23,7 +23,7 @@
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
fix calculation of timeout (see bug #269)
catch exception in execWithTimeout()
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">
@ -162,5 +162,21 @@ make it work with sqlite3 &lt; 3.8.0
set last parameter of stream_select() to 200000 micro sec. in case the timeout in sec. is set to 0
</notes>
</release>
<release>
<date>2016-03-29</date>
<time>08:09:48</time>
<version>
<release>1.0.6</release>
<api>1.0.1</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
fix calculation of timeout (see bug #269)
</notes>
</release>
</changelog>
</package>

View File

@ -66,7 +66,7 @@ class SeedDMS_Controller_AddDocument extends SeedDMS_Controller_Common {
if($result === null) {
$filesize = SeedDMS_Core_File::fileSize($userfiletmp);
$res = $folder->addDocument($name, $comment, $expires, $owner, $keywords,
$cats, $userfiletmp, basename($userfilename),
$cats, $userfiletmp, utf8_basename($userfilename),
$filetype, $userfiletype, $sequence,
$reviewers, $approvers, $reqversion,
$version_comment, $attributes, $attributes_version, $workflow, $initialdocumentstatus);

View File

@ -339,6 +339,27 @@ function dskspace($dir) { /* {{{ */
return $space;
} /* }}} */
/**
* Replacement of PHP's basename function
*
* Because basename is locale dependent and strips off non ascii chars
* from the beginning of filename, it cannot be used in a environment
* where locale is set to e.g. 'C'
*/
function utf8_basename($path, $suffix='') { /* {{{ */
$rpos = strrpos($path, DIRECTORY_SEPARATOR);
if($rpos === false)
return $path;
$file = substr($path, $rpos+1);
$suflen = strlen($suffix);
if($suflen && (substr($file, -$suflen) == $suffix)){
$file = substr($file, 0, -$suflen);
}
return $file;
} /* }}} */
/**
* Log a message
*

View File

@ -279,7 +279,7 @@ if(isset($_POST['fineuploaderuuids']) && $_POST['fineuploaderuuids']) {
$uuids = explode(';', $_POST['fineuploaderuuids']);
$names = explode(';', $_POST['fineuploadernames']);
foreach($uuids as $i=>$uuid) {
$fullfile = $settings->_stagingDir.'/'.basename($uuid);
$fullfile = $settings->_stagingDir.'/'.utf8_basename($uuid);
if(file_exists($fullfile)) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mimetype = finfo_file($finfo, $fullfile);
@ -366,7 +366,7 @@ for ($file_num=0;$file_num<count($_FILES["userfile"]["tmp_name"]);$file_num++){
if ((count($_FILES["userfile"]["tmp_name"])==1)&&($_POST["name"]!=""))
$name = trim($_POST["name"]);
else $name = basename($userfilename);
else $name = utf8_basename($userfilename);
/* Check if name already exists in the folder */
if(!$settings->_enableDuplicateDocNames) {
@ -406,66 +406,6 @@ for ($file_num=0;$file_num<count($_FILES["userfile"]["tmp_name"]);$file_num++){
if(!$document = $controller->run()) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText($controller->getErrorMsg()));
} else {
<<<<<<< HEAD
=======
$document = $res[0];
/* Set access as specified in settings. */
if($settings->_defaultAccessDocs) {
if($settings->_defaultAccessDocs > 0 && $settings->_defaultAccessDocs < 4) {
$document->setInheritAccess(0, true);
$document->setDefaultAccess($settings->_defaultAccessDocs, true);
}
}
if(isset($GLOBALS['SEEDDMS_HOOKS']['addDocument'])) {
foreach($GLOBALS['SEEDDMS_HOOKS']['addDocument'] as $hookObj) {
if (method_exists($hookObj, 'postAddDocument')) {
$hookObj->postAddDocument($document);
}
}
}
if($settings->_enableFullSearch) {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
if($index) {
$indexconf['Indexer']::init($settings->_stopWordsFile);
$idoc = new $indexconf['IndexedDocument']($dms, $document, isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null, !($filesize < $settings->_maxSizeForFullText));
if(isset($GLOBALS['SEEDDMS_HOOKS']['addDocument'])) {
foreach($GLOBALS['SEEDDMS_HOOKS']['addDocument'] as $hookObj) {
if (method_exists($hookObj, 'preIndexDocument')) {
$hookObj->preIndexDocument(null, $document, $idoc);
}
}
}
$index->addDocument($idoc);
}
}
/* Add a default notification for the owner of the document */
if($settings->_enableOwnerNotification) {
$res = $document->addNotify($user->getID(), true);
}
/* Check if additional notification shall be added */
if(!empty($_POST['notification_users'])) {
foreach($_POST['notification_users'] as $notuserid) {
$notuser = $dms->getUser($notuserid);
if($notuser) {
if($document->getAccessMode($user) >= M_READ)
$res = $document->addNotify($notuserid, true);
}
}
}
if(!empty($_POST['notification_groups'])) {
foreach($_POST['notification_groups'] as $notgroupid) {
$notgroup = $dms->getGroup($notgroupid);
if($notgroup) {
if($document->getGroupAccessMode($notgroup) >= M_READ)
$res = $document->addNotify($notgroupid, false);
}
}
}
>>>>>>> seeddms-5.1.x
// Send notification to subscribers of folder.
if($notifier) {
$fnl = $folder->getNotifyList();

View File

@ -204,7 +204,7 @@ if ($action == "saveSettings")
$settings->_converters['fulltext'] = $_POST["converters"]["fulltext"];
else
$settings->_converters['fulltext'] = $_POST["converters"];
$newmimetype = preg_replace('#[^A-Za-z0-9_/+.-]+#', '', $settings->_converters["fulltext"]["newmimetype"]);
$newmimetype = preg_replace('#[^A-Za-z0-9_/+.-*]+#', '', $settings->_converters["fulltext"]["newmimetype"]);
if($newmimetype && trim($settings->_converters['fulltext']['newcmd']))
$settings->_converters['fulltext'][$newmimetype] = trim($settings->_converters['fulltext']['newcmd']);
unset($settings->_converters['fulltext']['newmimetype']);
@ -212,7 +212,7 @@ if ($action == "saveSettings")
if(isset($_POST["converters"]["preview"]))
$settings->_converters['preview'] = $_POST["converters"]["preview"];
$newmimetype = preg_replace('#[^A-Za-z0-9_/+.-]+#', '', $settings->_converters["preview"]["newmimetype"]);
$newmimetype = preg_replace('#[^A-Za-z0-9_/+.-*]+#', '', $settings->_converters["preview"]["newmimetype"]);
if($newmimetype && trim($settings->_converters['preview']['newcmd']))
$settings->_converters['preview'][$newmimetype] = trim($settings->_converters['preview']['newcmd']);
unset($settings->_converters['preview']['newmimetype']);

View File

@ -62,6 +62,7 @@ function check_queue() {
data: {command: 'indexdocument', id: docid},
beforeSend: function() {
queue_count++; // Add request to the counter
$('.queue-bar').css('width', (queue_count*100/MAX_REQUESTS)+'%');
},
error: function(xhr, textstatus) {
noty({

View File

@ -552,20 +552,25 @@ $(document).ready( function() {
$this->pageList($pageNumber, $totalpages, "../out/out.Search.php", $urlparams);
// $this->contentContainerStart();
print "<table class=\"table table-hover\">";
print "<thead>\n<tr>\n";
print "<th></th>\n";
print "<th>".getMLText("name")."</th>\n";
print "<th>".getMLText("attributes")."</th>\n";
print "<th>".getMLText("status")."</th>\n";
print "<th>".getMLText("action")."</th>\n";
print "</tr>\n</thead>\n<tbody>\n";
$txt = $this->callHook('searchListHeader', $folder, $orderby);
if(is_string($txt))
echo $txt;
else {
print "<table class=\"table table-hover\">";
print "<thead>\n<tr>\n";
print "<th></th>\n";
print "<th>".getMLText("name")."</th>\n";
print "<th>".getMLText("attributes")."</th>\n";
print "<th>".getMLText("status")."</th>\n";
print "<th>".getMLText("action")."</th>\n";
print "</tr>\n</thead>\n<tbody>\n";
}
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout);
$previewer->setConverters($previewconverters);
foreach ($entries as $entry) {
if(get_class($entry) == $dms->getClassname('document')) {
$txt = $this->callHook('documentListItem', $entry, $previewer);
$txt = $this->callHook('documentListItem', $entry, $previewer, 'search');
if(is_string($txt))
echo $txt;
else {

View File

@ -302,36 +302,34 @@ function folderSelected(id, name) {
print "<th>".getMLText("action")."</th>\n";
print "</tr>\n</thead>\n<tbody>\n";
}
}
else printMLText("empty_folder_list");
foreach($subFolders as $subFolder) {
$txt = $this->callHook('folderListItem', $subFolder);
if(is_string($txt))
echo $txt;
else {
echo $this->folderListRow($subFolder);
foreach($subFolders as $subFolder) {
$txt = $this->callHook('folderListItem', $subFolder, 'viewfolder');
if(is_string($txt))
echo $txt;
else {
echo $this->folderListRow($subFolder);
}
}
}
foreach($documents as $document) {
$document->verifyLastestContentExpriry();
$txt = $this->callHook('documentListItem', $document, $previewer);
if(is_string($txt))
echo $txt;
else {
echo $this->documentListRow($document, $previewer);
foreach($documents as $document) {
$document->verifyLastestContentExpriry();
$txt = $this->callHook('documentListItem', $document, $previewer, 'viewfolder');
if(is_string($txt))
echo $txt;
else {
echo $this->documentListRow($document, $previewer);
}
}
}
if ((count($subFolders) > 0)||(count($documents) > 0)) {
$txt = $this->callHook('folderListFooter', $folder);
if(is_string($txt))
echo $txt;
else
echo "</tbody>\n</table>\n";
}
else printMLText("empty_folder_list");
echo "</div>\n"; // End of right column div
echo "</div>\n"; // End of div around left and right column