mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-13 13:11:31 +00:00
Merge branch 'seeddms-5.1.x' into seeddms-6.0.x
This commit is contained in:
commit
a830b18fc3
|
@ -6,7 +6,7 @@ Header set X-Content-Type-Options: "nosniff"
|
||||||
</IfModule>
|
</IfModule>
|
||||||
|
|
||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
RewriteRule ^favicon.ico$ styles/bootstrap/favicon.ico [L]
|
RewriteRule ^favicon.ico$ views/bootstrap/images/favicon.svg [L]
|
||||||
|
|
||||||
# Store the current location in an environment variable CWD to use
|
# Store the current location in an environment variable CWD to use
|
||||||
# mod_rewrite in .htaccess files without knowing the RewriteBase
|
# mod_rewrite in .htaccess files without knowing the RewriteBase
|
||||||
|
|
|
@ -218,6 +218,7 @@
|
||||||
a folder
|
a folder
|
||||||
- get zendframework from pkgist
|
- get zendframework from pkgist
|
||||||
- auto generate path if not set in settings.xml
|
- auto generate path if not set in settings.xml
|
||||||
|
- add document conversion service
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
Changes in version 5.1.23
|
Changes in version 5.1.23
|
||||||
|
|
|
@ -38,6 +38,12 @@ define("M_READWRITE", 3);
|
||||||
*/
|
*/
|
||||||
define("M_ALL", 4);
|
define("M_ALL", 4);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Lowest and highest access right
|
||||||
|
*/
|
||||||
|
define("M_LOWEST_RIGHT", 1);
|
||||||
|
define("M_HIGHEST_RIGHT", 4);
|
||||||
|
|
||||||
define ("O_GTEQ", ">=");
|
define ("O_GTEQ", ">=");
|
||||||
define ("O_LTEQ", "<=");
|
define ("O_LTEQ", "<=");
|
||||||
define ("O_EQ", "=");
|
define ("O_EQ", "=");
|
||||||
|
@ -85,4 +91,4 @@ define("N_DELETE_VERSION", 5);
|
||||||
/**
|
/**
|
||||||
* Notify when version of document was deleted
|
* Notify when version of document was deleted
|
||||||
*/
|
*/
|
||||||
define("N_ADD_DOCUMENT", 6);
|
define("N_ADD_DOCUMENT", 6);
|
||||||
|
|
|
@ -248,27 +248,27 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$this->_notifyList = array();
|
$this->_notifyList = array();
|
||||||
$this->_latestContent = null;
|
$this->_latestContent = null;
|
||||||
$this->_content = null;
|
$this->_content = null;
|
||||||
/* Cache */
|
/* Cache */
|
||||||
$this->clearCache();
|
$this->clearCache();
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear cache of this instance.
|
* Clear cache of this instance.
|
||||||
*
|
*
|
||||||
* The result of some expensive database actions (e.g. get all subfolders
|
* The result of some expensive database actions (e.g. get all subfolders
|
||||||
* or documents) will be saved in a class variable to speed up consecutive
|
* or documents) will be saved in a class variable to speed up consecutive
|
||||||
* calls of the same method. If a second call of the same method shall not
|
* calls of the same method. If a second call of the same method shall not
|
||||||
* use the cache, then it must be cleared.
|
* use the cache, then it must be cleared.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function clearCache() { /* {{{ */
|
public function clearCache() { /* {{{ */
|
||||||
$this->_parent = null;
|
$this->_parent = null;
|
||||||
$this->_owner = null;
|
$this->_owner = null;
|
||||||
$this->_documentLinks = null;
|
$this->_documentLinks = null;
|
||||||
$this->_documentFiles = null;
|
$this->_documentFiles = null;
|
||||||
$this->_content = null;
|
$this->_content = null;
|
||||||
$this->_accessList = null;
|
$this->_accessList = null;
|
||||||
$this->_notifyList = null;
|
$this->_notifyList = null;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -486,11 +486,12 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
if(!$this->_categories) {
|
if(!$this->_categories) {
|
||||||
$queryStr = "SELECT * FROM `tblCategory` where `id` in (select `categoryID` from `tblDocumentCategory` where `documentID` = ".$this->_id.")";
|
$queryStr = "SELECT * FROM `tblCategory` WHERE `id` IN (SELECT `categoryID` FROM `tblDocumentCategory` WHERE `documentID` = ".$this->_id.")";
|
||||||
$resArr = $db->getResultArray($queryStr);
|
$resArr = $db->getResultArray($queryStr);
|
||||||
if (is_bool($resArr) && !$resArr)
|
if (is_bool($resArr) && !$resArr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
$this->_categories = [];
|
||||||
foreach ($resArr as $row) {
|
foreach ($resArr as $row) {
|
||||||
$cat = new SeedDMS_Core_DocumentCategory($row['id'], $row['name']);
|
$cat = new SeedDMS_Core_DocumentCategory($row['id'], $row['name']);
|
||||||
$cat->setDMS($this->_dms);
|
$cat->setDMS($this->_dms);
|
||||||
|
@ -512,7 +513,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
$db->startTransaction();
|
$db->startTransaction();
|
||||||
$queryStr = "DELETE from `tblDocumentCategory` WHERE `documentID` = ". $this->_id;
|
$queryStr = "DELETE FROM `tblDocumentCategory` WHERE `documentID` = ". $this->_id;
|
||||||
if (!$db->getResult($queryStr)) {
|
if (!$db->getResult($queryStr)) {
|
||||||
$db->rollbackTransaction();
|
$db->rollbackTransaction();
|
||||||
return false;
|
return false;
|
||||||
|
@ -577,7 +578,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
foreach($categories as $cat)
|
foreach($categories as $cat)
|
||||||
$catids[] = $cat->getID();
|
$catids[] = $cat->getID();
|
||||||
|
|
||||||
$queryStr = "DELETE from `tblDocumentCategory` WHERE `documentID` = ". $this->_id ." AND `categoryID` IN (".implode(',', $catids).")";
|
$queryStr = "DELETE FROM `tblDocumentCategory` WHERE `documentID` = ". $this->_id ." AND `categoryID` IN (".implode(',', $catids).")";
|
||||||
if (!$db->getResult($queryStr)) {
|
if (!$db->getResult($queryStr)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -677,6 +678,12 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
function setFolder($newFolder) { /* {{{ */
|
function setFolder($newFolder) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
|
if(!$newFolder)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(!$newFolder->isType('folder'))
|
||||||
|
return false;
|
||||||
|
|
||||||
$queryStr = "UPDATE `tblDocuments` SET `folder` = " . $newFolder->getID() . " WHERE `id` = ". $this->_id;
|
$queryStr = "UPDATE `tblDocuments` SET `folder` = " . $newFolder->getID() . " WHERE `id` = ". $this->_id;
|
||||||
if (!$db->getResult($queryStr))
|
if (!$db->getResult($queryStr))
|
||||||
return false;
|
return false;
|
||||||
|
@ -721,6 +728,12 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
function setOwner($newOwner) { /* {{{ */
|
function setOwner($newOwner) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
|
if(!$newOwner)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(!$newOwner->isType('user'))
|
||||||
|
return false;
|
||||||
|
|
||||||
$oldOwner = self::getOwner();
|
$oldOwner = self::getOwner();
|
||||||
|
|
||||||
$db->startTransaction();
|
$db->startTransaction();
|
||||||
|
@ -769,22 +782,33 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* Set default access mode
|
* Set default access mode
|
||||||
*
|
*
|
||||||
* This method sets the default access mode and also removes all notifiers which
|
* This method sets the default access mode and also removes all notifiers which
|
||||||
* will not have read access anymore.
|
* will not have read access anymore. Setting a default access mode will only
|
||||||
|
* have an immediate effect if the access rights are not inherited, otherwise
|
||||||
|
* it just updates the database record of the document and once the
|
||||||
|
* inheritance is turn off the default access mode will take effect.
|
||||||
*
|
*
|
||||||
* @param integer $mode access mode
|
* @param integer $mode access mode
|
||||||
* @param bool|string $noclean set to true if notifier list shall not be clean up
|
* @param bool|string $noclean set to true if notifier list shall not be clean up
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function setDefaultAccess($mode, $noclean="false") { /* {{{ */
|
function setDefaultAccess($mode, $noclean="false") { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
|
if($mode < M_LOWEST_RIGHT || $mode > M_HIGHEST_RIGHT)
|
||||||
|
return false;
|
||||||
|
|
||||||
$queryStr = "UPDATE `tblDocuments` set `defaultAccess` = " . (int) $mode . " WHERE `id` = " . $this->_id;
|
$queryStr = "UPDATE `tblDocuments` set `defaultAccess` = " . (int) $mode . " WHERE `id` = " . $this->_id;
|
||||||
if (!$db->getResult($queryStr))
|
if (!$db->getResult($queryStr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$this->_defaultAccess = $mode;
|
$this->_defaultAccess = $mode;
|
||||||
|
|
||||||
if(!$noclean)
|
/* Setting the default access mode does not have any effect if access
|
||||||
|
* is still inherited. In that case there is no need to clean the
|
||||||
|
* notification list.
|
||||||
|
*/
|
||||||
|
if(!$noclean && !$this->_inheritAccess)
|
||||||
$this->cleanNotifyList();
|
$this->cleanNotifyList();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -795,6 +819,13 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
*/
|
*/
|
||||||
function inheritsAccess() { return $this->_inheritAccess; }
|
function inheritsAccess() { return $this->_inheritAccess; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is supposed to be a replacement for inheritsAccess()
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function getInheritAccess() { return $this->_inheritAccess; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set inherited access mode
|
* Set inherited access mode
|
||||||
* Setting inherited access mode will set or unset the internal flag which
|
* Setting inherited access mode will set or unset the internal flag which
|
||||||
|
@ -1300,7 +1331,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$modeStr = " AND mode".$op.(int)$mode;
|
$modeStr = " AND mode".$op.(int)$mode;
|
||||||
}
|
}
|
||||||
$queryStr = "SELECT * FROM `tblACLs` WHERE `targetType` = ".T_DOCUMENT.
|
$queryStr = "SELECT * FROM `tblACLs` WHERE `targetType` = ".T_DOCUMENT.
|
||||||
" AND target = " . $this->_id . $modeStr . " ORDER BY `targetType`";
|
" AND target = " . $this->_id . $modeStr . " ORDER BY `targetType`";
|
||||||
$resArr = $db->getResultArray($queryStr);
|
$resArr = $db->getResultArray($queryStr);
|
||||||
if (is_bool($resArr) && !$resArr)
|
if (is_bool($resArr) && !$resArr)
|
||||||
return false;
|
return false;
|
||||||
|
@ -1332,8 +1363,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
function addAccess($mode, $userOrGroupID, $isUser) { /* {{{ */
|
function addAccess($mode, $userOrGroupID, $isUser) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
if($mode < M_NONE || $mode > M_ALL)
|
if($mode < M_NONE || $mode > M_ALL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$userOrGroup = ($isUser) ? "`userID`" : "`groupID`";
|
$userOrGroup = ($isUser) ? "`userID`" : "`groupID`";
|
||||||
|
|
||||||
|
@ -1838,7 +1869,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* innodb is used. That's why the version is now determined here.
|
* innodb is used. That's why the version is now determined here.
|
||||||
*/
|
*/
|
||||||
if ((int)$version<1) {
|
if ((int)$version<1) {
|
||||||
$queryStr = "SELECT MAX(`version`) as m from `tblDocumentContent` where `document` = ".$this->_id;
|
$queryStr = "SELECT MAX(`version`) AS m FROM `tblDocumentContent` WHERE `document` = ".$this->_id;
|
||||||
$resArr = $db->getResultArray($queryStr);
|
$resArr = $db->getResultArray($queryStr);
|
||||||
if (is_bool($resArr) && !$resArr)
|
if (is_bool($resArr) && !$resArr)
|
||||||
return false;
|
return false;
|
||||||
|
@ -2015,7 +2046,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
/* If $version < 1 than replace the content of the latest version.
|
/* If $version < 1 than replace the content of the latest version.
|
||||||
*/
|
*/
|
||||||
if ((int) $version<1) {
|
if ((int) $version<1) {
|
||||||
$queryStr = "SELECT MAX(`version`) as m from `tblDocumentContent` where `document` = ".$this->_id;
|
$queryStr = "SELECT MAX(`version`) AS m FROM `tblDocumentContent` WHERE `document` = ".$this->_id;
|
||||||
$resArr = $db->getResultArray($queryStr);
|
$resArr = $db->getResultArray($queryStr);
|
||||||
if (is_bool($resArr) && !$resArr)
|
if (is_bool($resArr) && !$resArr)
|
||||||
return false;
|
return false;
|
||||||
|
@ -2116,9 +2147,9 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* currently logged in user.
|
* currently logged in user.
|
||||||
*
|
*
|
||||||
* @param integer $version version number of content element
|
* @param integer $version version number of content element
|
||||||
* @return SeedDMS_Core_DocumentContent|null|boolean object of class
|
* @return SeedDMS_Core_DocumentContent|null|boolean object of class
|
||||||
* {@link SeedDMS_Core_DocumentContent}, null if not content was found,
|
* {@link SeedDMS_Core_DocumentContent}, null if not content was found,
|
||||||
* false in case of an error
|
* false in case of an error
|
||||||
*/
|
*/
|
||||||
function getContentByVersion($version) { /* {{{ */
|
function getContentByVersion($version) { /* {{{ */
|
||||||
if (!is_numeric($version)) return false;
|
if (!is_numeric($version)) return false;
|
||||||
|
@ -2238,16 +2269,12 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
private function _removeContent($version) { /* {{{ */
|
private function _removeContent($version) { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
if (file_exists( $this->_dms->contentDir.$version->getPath() ))
|
|
||||||
if (!SeedDMS_Core_File::removeFile( $this->_dms->contentDir.$version->getPath() ))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
$db->startTransaction();
|
$db->startTransaction();
|
||||||
|
|
||||||
$status = $version->getStatus();
|
$status = $version->getStatus();
|
||||||
$stID = $status["statusID"];
|
$stID = $status["statusID"];
|
||||||
|
|
||||||
$queryStr = "DELETE FROM `tblDocumentContent` WHERE `document` = " . $this->getID() . " AND `version` = " . $version->getVersion();
|
$queryStr = "DELETE FROM `tblDocumentContent` WHERE `document` = " . $this->getID() . " AND `version` = " . $version->getVersion();
|
||||||
if (!$db->getResult($queryStr)) {
|
if (!$db->getResult($queryStr)) {
|
||||||
$db->rollbackTransaction();
|
$db->rollbackTransaction();
|
||||||
return false;
|
return false;
|
||||||
|
@ -2422,6 +2449,12 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file_exists( $this->_dms->contentDir.$version->getPath() ))
|
||||||
|
if (!SeedDMS_Core_File::removeFile( $this->_dms->contentDir.$version->getPath() )) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$db->commitTransaction();
|
$db->commitTransaction();
|
||||||
return true;
|
return true;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -2434,6 +2467,23 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
*/
|
*/
|
||||||
function removeContent($version) { /* {{{ */
|
function removeContent($version) { /* {{{ */
|
||||||
$this->_dms->lasterror = '';
|
$this->_dms->lasterror = '';
|
||||||
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
|
/* Make sure the version exists */
|
||||||
|
$queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = " . $this->getID() . " AND `version` = " . $version->getVersion();
|
||||||
|
$resArr = $db->getResultArray($queryStr);
|
||||||
|
if (is_bool($resArr) && !$resArr)
|
||||||
|
return false;
|
||||||
|
if (count($resArr)==0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
/* Make sure this is not the last version */
|
||||||
|
$queryStr = "SELECT * FROM `tblDocumentContent` WHERE `document` = " . $this->getID();
|
||||||
|
$resArr = $db->getResultArray($queryStr);
|
||||||
|
if (is_bool($resArr) && !$resArr)
|
||||||
|
return false;
|
||||||
|
if (count($resArr)==1)
|
||||||
|
return false;
|
||||||
|
|
||||||
/* Check if 'onPreRemoveDocument' callback is set */
|
/* Check if 'onPreRemoveDocument' callback is set */
|
||||||
if(isset($this->_dms->callbacks['onPreRemoveContent'])) {
|
if(isset($this->_dms->callbacks['onPreRemoveContent'])) {
|
||||||
|
@ -2480,7 +2530,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
|
|
||||||
$queryStr = "SELECT * FROM `tblDocumentLinks` WHERE `document` = " . $this->_id ." AND `id` = " . (int) $linkID;
|
$queryStr = "SELECT * FROM `tblDocumentLinks` WHERE `document` = " . $this->_id ." AND `id` = " . (int) $linkID;
|
||||||
$resArr = $db->getResultArray($queryStr);
|
$resArr = $db->getResultArray($queryStr);
|
||||||
if (is_bool($resArr) && !$resArr)
|
if (is_bool($resArr) && !$resArr)
|
||||||
return false;
|
return false;
|
||||||
if (count($resArr)==0)
|
if (count($resArr)==0)
|
||||||
return null;
|
return null;
|
||||||
|
@ -2602,13 +2652,13 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$public = ($public) ? 1 : 0;
|
$public = ($public) ? 1 : 0;
|
||||||
|
|
||||||
if (!is_numeric($targetID) || $targetID < 1)
|
if (!is_numeric($targetID) || $targetID < 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ($targetID == $this->_id)
|
if ($targetID == $this->_id)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!is_numeric($userID) || $userID < 1)
|
if (!is_numeric($userID) || $userID < 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(!($target = $this->_dms->getDocument($targetID)))
|
if(!($target = $this->_dms->getDocument($targetID)))
|
||||||
return false;
|
return false;
|
||||||
|
@ -2631,7 +2681,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
if (!is_numeric($linkID) || $linkID < 1)
|
if (!is_numeric($linkID) || $linkID < 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$queryStr = "DELETE FROM `tblDocumentLinks` WHERE `document` = " . $this->_id ." AND `id` = " . (int) $linkID;
|
$queryStr = "DELETE FROM `tblDocumentLinks` WHERE `document` = " . $this->_id ." AND `id` = " . (int) $linkID;
|
||||||
if (!$db->getResult($queryStr)) return false;
|
if (!$db->getResult($queryStr)) return false;
|
||||||
|
@ -2746,7 +2796,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
if (!is_numeric($ID) || $ID < 1)
|
if (!is_numeric($ID) || $ID < 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$file = $this->getDocumentFile($ID);
|
$file = $this->getDocumentFile($ID);
|
||||||
if (is_bool($file) && !$file) return false;
|
if (is_bool($file) && !$file) return false;
|
||||||
|
@ -3054,7 +3104,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
function getFolderList() { /* {{{ */
|
function getFolderList() { /* {{{ */
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
||||||
$queryStr = "SELECT `folderList` FROM `tblDocuments` where id = ".$this->_id;
|
$queryStr = "SELECT `folderList` FROM `tblDocuments` WHERE id = ".$this->_id;
|
||||||
$resArr = $db->getResultArray($queryStr);
|
$resArr = $db->getResultArray($queryStr);
|
||||||
if (is_bool($resArr) && !$resArr)
|
if (is_bool($resArr) && !$resArr)
|
||||||
return false;
|
return false;
|
||||||
|
@ -3455,7 +3505,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$this->_document = $document;
|
$this->_document = $document;
|
||||||
$this->_version = (int) $version;
|
$this->_version = (int) $version;
|
||||||
$this->_comment = $comment;
|
$this->_comment = $comment;
|
||||||
$this->_date = $date;
|
$this->_date = (int) $date;
|
||||||
$this->_userID = (int) $userID;
|
$this->_userID = (int) $userID;
|
||||||
$this->_dir = $dir;
|
$this->_dir = $dir;
|
||||||
$this->_orgFileName = $orgFileName;
|
$this->_orgFileName = $orgFileName;
|
||||||
|
@ -3564,17 +3614,28 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
return true;
|
return true;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set upload date of document content
|
||||||
|
*
|
||||||
|
* @param string $date date must be a timestamp or in the format 'Y-m-d H:i:s'
|
||||||
|
*
|
||||||
|
* @return boolean true on success, otherwise false
|
||||||
|
*/
|
||||||
function setDate($date = false) { /* {{{ */
|
function setDate($date = false) { /* {{{ */
|
||||||
$db = $this->_document->getDMS()->getDB();
|
$db = $this->_document->getDMS()->getDB();
|
||||||
|
|
||||||
if(!$date)
|
if(!$date)
|
||||||
$date = time();
|
$date = time();
|
||||||
else {
|
else {
|
||||||
if(!is_numeric($date))
|
if(is_string($date) && SeedDMS_Core_DMS::checkDate($date, 'Y-m-d H:i:s')) {
|
||||||
|
$date = strtotime($date);
|
||||||
|
} elseif(is_numeric($date))
|
||||||
|
$date = (int) $date;
|
||||||
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$queryStr = "UPDATE `tblDocumentContent` SET `date` = ".(int) $date." WHERE `document` = " . $this->_document->getID() . " AND `version` = " . $this->_version;
|
$queryStr = "UPDATE `tblDocumentContent` SET `date` = ". $date." WHERE `document` = " . $this->_document->getID() . " AND `version` = " . $this->_version;
|
||||||
if (!$db->getResult($queryStr))
|
if (!$db->getResult($queryStr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -3596,7 +3657,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$db = $this->_document->getDMS()->getDB();
|
$db = $this->_document->getDMS()->getDB();
|
||||||
$queryStr = "UPDATE `tblDocumentContent` SET `fileSize` = ".$filesize." where `document` = " . $this->_document->getID() . " AND `version` = " . $this->_version;
|
$queryStr = "UPDATE `tblDocumentContent` SET `fileSize` = ".$filesize." WHERE `document` = " . $this->_document->getID() . " AND `version` = " . $this->_version;
|
||||||
if (!$db->getResult($queryStr))
|
if (!$db->getResult($queryStr))
|
||||||
return false;
|
return false;
|
||||||
$this->_fileSize = $filesize;
|
$this->_fileSize = $filesize;
|
||||||
|
@ -3617,7 +3678,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$db = $this->_document->getDMS()->getDB();
|
$db = $this->_document->getDMS()->getDB();
|
||||||
$queryStr = "UPDATE `tblDocumentContent` SET `checksum` = ".$db->qstr($checksum)." where `document` = " . $this->_document->getID() . " AND `version` = " . $this->_version;
|
$queryStr = "UPDATE `tblDocumentContent` SET `checksum` = ".$db->qstr($checksum)." WHERE `document` = " . $this->_document->getID() . " AND `version` = " . $this->_version;
|
||||||
if (!$db->getResult($queryStr))
|
if (!$db->getResult($queryStr))
|
||||||
return false;
|
return false;
|
||||||
$this->_checksum = $checksum;
|
$this->_checksum = $checksum;
|
||||||
|
@ -3659,10 +3720,27 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
return false;
|
return false;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
function setMimeType($newMimetype) { /* {{{ */
|
||||||
|
$db = $this->_document->getDMS()->getDB();
|
||||||
|
|
||||||
|
$newMimetype = trim($newMimetype);
|
||||||
|
|
||||||
|
if(!$newMimetype)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$queryStr = "UPDATE `tblDocumentContent` SET `mimeType` = ".$db->qstr($newMimetype)." WHERE `document` = " . $this->_document->getID() . " AND `version` = " . $this->_version;
|
||||||
|
if (!$db->getResult($queryStr))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$this->_mimeType = $newMimetype;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
function setComment($newComment) { /* {{{ */
|
function setComment($newComment) { /* {{{ */
|
||||||
$db = $this->_document->getDMS()->getDB();
|
$db = $this->_document->getDMS()->getDB();
|
||||||
|
|
||||||
$queryStr = "UPDATE `tblDocumentContent` SET `comment` = ".$db->qstr($newComment)." WHERE `document` = " . $this->_document->getID() . " AND `version` = " . $this->_version;
|
$queryStr = "UPDATE `tblDocumentContent` SET `comment` = ".$db->qstr($newComment)." WHERE `document` = " . $this->_document->getID() . " AND `version` = " . $this->_version;
|
||||||
if (!$db->getResult($queryStr))
|
if (!$db->getResult($queryStr))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -3717,7 +3795,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
return false;
|
return false;
|
||||||
if (count($res)!=1)
|
if (count($res)!=1)
|
||||||
return false;
|
return false;
|
||||||
$this->_status = $res[0];
|
$this->_status = $res[0];
|
||||||
}
|
}
|
||||||
return $this->_status;
|
return $this->_status;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -3758,9 +3836,11 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* tblDocumentStatusLog. The method returns also false if the status
|
* tblDocumentStatusLog. The method returns also false if the status
|
||||||
* is already set on the value passed to the method.
|
* is already set on the value passed to the method.
|
||||||
*
|
*
|
||||||
* @param integer $status new status of content
|
* @param integer $status new status of content
|
||||||
* @param string $comment comment for this status change
|
* @param string $comment comment for this status change
|
||||||
* @param object $updateUser user initiating the status change
|
* @param object $updateUser user initiating the status change
|
||||||
|
* @param string $date date in the format 'Y-m-d H:i:s'
|
||||||
|
*
|
||||||
* @return boolean true on success, otherwise false
|
* @return boolean true on success, otherwise false
|
||||||
*/
|
*/
|
||||||
function setStatus($status, $comment, $updateUser, $date='') { /* {{{ */
|
function setStatus($status, $comment, $updateUser, $date='') { /* {{{ */
|
||||||
|
@ -3769,7 +3849,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
if (!is_numeric($status)) return false;
|
if (!is_numeric($status)) return false;
|
||||||
|
|
||||||
/* return an error if $updateuser is not set */
|
/* return an error if $updateuser is not set */
|
||||||
if(!$updateUser)
|
if(!$updateUser || !$updateUser->isType('user'))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If the supplied value lies outside of the accepted range, return an
|
// If the supplied value lies outside of the accepted range, return an
|
||||||
|
@ -3786,9 +3866,11 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
if ($this->_status["status"]==$status) {
|
if ($this->_status["status"]==$status) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if($date)
|
if($date) {
|
||||||
|
if(!SeedDMS_Core_DMS::checkDate($date, 'Y-m-d H:i:s'))
|
||||||
|
return false;
|
||||||
$ddate = $db->qstr($date);
|
$ddate = $db->qstr($date);
|
||||||
else
|
} else
|
||||||
$ddate = $db->getCurrentDatetime();
|
$ddate = $db->getCurrentDatetime();
|
||||||
$db->startTransaction();
|
$db->startTransaction();
|
||||||
$queryStr = "INSERT INTO `tblDocumentStatusLog` (`statusID`, `status`, `comment`, `date`, `userID`) ".
|
$queryStr = "INSERT INTO `tblDocumentStatusLog` (`statusID`, `status`, `comment`, `date`, `userID`) ".
|
||||||
|
@ -3815,7 +3897,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->commitTransaction();
|
$db->commitTransaction();
|
||||||
unset($this->_status);
|
unset($this->_status);
|
||||||
return true;
|
return true;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
@ -3842,7 +3924,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$db->startTransaction();
|
$db->startTransaction();
|
||||||
|
|
||||||
/* First, remove the old entries */
|
/* First, remove the old entries */
|
||||||
$queryStr = "DELETE from `tblDocumentStatusLog` where `statusID`=".$statusID;
|
$queryStr = "DELETE FROM `tblDocumentStatusLog` WHERE `statusID`=".$statusID;
|
||||||
if (!$db->getResult($queryStr)) {
|
if (!$db->getResult($queryStr)) {
|
||||||
$db->rollbackTransaction();
|
$db->rollbackTransaction();
|
||||||
return false;
|
return false;
|
||||||
|
@ -4147,13 +4229,13 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$reviewID = $review['reviewID'];
|
$reviewID = $review['reviewID'];
|
||||||
|
|
||||||
/* First, remove the old entries */
|
/* First, remove the old entries */
|
||||||
$queryStr = "DELETE from `tblDocumentReviewLog` where `reviewID`=".$reviewID;
|
$queryStr = "DELETE FROM `tblDocumentReviewLog` WHERE `reviewID`=".$reviewID;
|
||||||
if (!$db->getResult($queryStr)) {
|
if (!$db->getResult($queryStr)) {
|
||||||
$db->rollbackTransaction();
|
$db->rollbackTransaction();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$queryStr = "DELETE from `tblDocumentReviewers` where `reviewID`=".$reviewID;
|
$queryStr = "DELETE FROM `tblDocumentReviewers` WHERE `reviewID`=".$reviewID;
|
||||||
if (!$db->getResult($queryStr)) {
|
if (!$db->getResult($queryStr)) {
|
||||||
$db->rollbackTransaction();
|
$db->rollbackTransaction();
|
||||||
return false;
|
return false;
|
||||||
|
@ -4327,13 +4409,13 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
$reviewID = $review['reviewID'];
|
$reviewID = $review['reviewID'];
|
||||||
|
|
||||||
/* First, remove the old entries */
|
/* First, remove the old entries */
|
||||||
$queryStr = "DELETE from `tblDocumentApproveLog` where `approveID`=".$reviewID;
|
$queryStr = "DELETE FROM `tblDocumentApproveLog` WHERE `approveID`=".$reviewID;
|
||||||
if (!$db->getResult($queryStr)) {
|
if (!$db->getResult($queryStr)) {
|
||||||
$db->rollbackTransaction();
|
$db->rollbackTransaction();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$queryStr = "DELETE from `tblDocumentApprovers` where `approveID`=".$reviewID;
|
$queryStr = "DELETE FROM `tblDocumentApprovers` WHERE `approveID`=".$reviewID;
|
||||||
if (!$db->getResult($queryStr)) {
|
if (!$db->getResult($queryStr)) {
|
||||||
$db->rollbackTransaction();
|
$db->rollbackTransaction();
|
||||||
return false;
|
return false;
|
||||||
|
@ -4797,7 +4879,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
|
|
||||||
// Check to see if the group has already been added to the review list.
|
// Check to see if the group has already been added to the review list.
|
||||||
$reviewStatus = $group->getReviewStatus($this->_document->getID(), $this->_version);
|
$reviewStatus = $group->getReviewStatus($this->_document->getID(), $this->_version);
|
||||||
if (is_bool($reviewStatus) && !$reviewStatus) {
|
if (is_bool($reviewStatus) && !$reviewStatus) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (count($reviewStatus) > 0 && $reviewStatus[0]["status"]!=-2) {
|
if (count($reviewStatus) > 0 && $reviewStatus[0]["status"]!=-2) {
|
||||||
|
@ -4811,7 +4893,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
"VALUES ('". $this->_document->getID() ."', '". $this->_version ."', '1', '". $groupID ."')";
|
"VALUES ('". $this->_document->getID() ."', '". $this->_version ."', '1', '". $groupID ."')";
|
||||||
$res = $db->getResult($queryStr);
|
$res = $db->getResult($queryStr);
|
||||||
if (is_bool($res) && !$res) {
|
if (is_bool($res) && !$res) {
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
$reviewID = $db->getInsertID('tblDocumentReviewers', 'reviewID');
|
$reviewID = $db->getInsertID('tblDocumentReviewers', 'reviewID');
|
||||||
}
|
}
|
||||||
|
@ -4827,7 +4909,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
}
|
}
|
||||||
|
|
||||||
$reviewLogID = $db->getInsertID('tblDocumentReviewLog', 'reviewLogID');
|
$reviewLogID = $db->getInsertID('tblDocumentReviewLog', 'reviewLogID');
|
||||||
$db->dropTemporaryTable('ttreviewid');
|
$db->dropTemporaryTable('ttreviewid');
|
||||||
return $reviewLogID;
|
return $reviewLogID;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
@ -4843,16 +4925,16 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* be set again and 0 will be returned. Іf the review could be succesfully
|
* be set again and 0 will be returned. Іf the review could be succesfully
|
||||||
* added, the review log id will be returned.
|
* added, the review log id will be returned.
|
||||||
*
|
*
|
||||||
* @see SeedDMS_Core_DocumentContent::setApprovalByInd()
|
* @see SeedDMS_Core_DocumentContent::setApprovalByInd()
|
||||||
*
|
*
|
||||||
* @param object $user user doing the review
|
* @param object $user user doing the review
|
||||||
* @param object $requestUser user asking for the review, this is mostly
|
* @param object $requestUser user asking for the review, this is mostly
|
||||||
* the user currently logged in.
|
* the user currently logged in.
|
||||||
* @param integer $status status of review
|
* @param integer $status status of review
|
||||||
* @param string $comment comment for review
|
* @param string $comment comment for review
|
||||||
*
|
*
|
||||||
* @return integer|bool new review log id, error code 0 till -4,
|
* @return integer|bool new review log id, error code 0 till -4,
|
||||||
* false in case of an sql error
|
* false in case of an sql error
|
||||||
*/
|
*/
|
||||||
function setReviewByInd($user, $requestUser, $status, $comment, $file='') { /* {{{ */
|
function setReviewByInd($user, $requestUser, $status, $comment, $file='') { /* {{{ */
|
||||||
if(!$user || !$requestUser)
|
if(!$user || !$requestUser)
|
||||||
|
@ -4860,8 +4942,8 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
|
|
||||||
$db = $this->_document->getDMS()->getDB();
|
$db = $this->_document->getDMS()->getDB();
|
||||||
|
|
||||||
if(!$user->isType('user'))
|
if(!$user->isType('user'))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// Check if the user is on the review list at all.
|
// Check if the user is on the review list at all.
|
||||||
$reviewStatus = $user->getReviewStatus($this->_document->getID(), $this->_version);
|
$reviewStatus = $user->getReviewStatus($this->_document->getID(), $this->_version);
|
||||||
|
@ -4896,7 +4978,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
SeedDMS_Core_File::copyFile($file, $this->_dms->contentDir . $this->_document->getDir() . 'r' . $reviewLogID);
|
SeedDMS_Core_File::copyFile($file, $this->_dms->contentDir . $this->_document->getDir() . 'r' . $reviewLogID);
|
||||||
}
|
}
|
||||||
return $reviewLogID;
|
return $reviewLogID;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add another entry to review log which resets the status
|
* Add another entry to review log which resets the status
|
||||||
|
@ -4908,12 +4990,12 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* After calling this method SeedDMS_Core_DocumentCategory::verifyStatus()
|
* After calling this method SeedDMS_Core_DocumentCategory::verifyStatus()
|
||||||
* should be called to recalculate the document status.
|
* should be called to recalculate the document status.
|
||||||
*
|
*
|
||||||
* @param integer $reviewid id of review
|
* @param integer $reviewid id of review
|
||||||
* @param SeedDMS_Core_User $requestUser user requesting the removal
|
* @param SeedDMS_Core_User $requestUser user requesting the removal
|
||||||
* @param string $comment comment
|
* @param string $comment comment
|
||||||
*
|
*
|
||||||
* @return integer|bool true if successful, error code < 0,
|
* @return integer|bool true if successful, error code < 0,
|
||||||
* false in case of an sql error
|
* false in case of an sql error
|
||||||
*/
|
*/
|
||||||
public function removeReview($reviewid, $requestUser, $comment='') { /* {{{ */
|
public function removeReview($reviewid, $requestUser, $comment='') { /* {{{ */
|
||||||
$db = $this->_document->getDMS()->getDB();
|
$db = $this->_document->getDMS()->getDB();
|
||||||
|
@ -4946,7 +5028,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a review to the document content
|
* Add a review to the document content
|
||||||
|
@ -4961,8 +5043,8 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* @param integer $status status of review
|
* @param integer $status status of review
|
||||||
* @param string $comment comment for review
|
* @param string $comment comment for review
|
||||||
*
|
*
|
||||||
* @return integer|bool new review log id, error code 0 till -4,
|
* @return integer|bool new review log id, error code 0 till -4,
|
||||||
* false in case of an sql error
|
* false in case of an sql error
|
||||||
*/
|
*/
|
||||||
function setReviewByGrp($group, $requestUser, $status, $comment, $file='') { /* {{{ */
|
function setReviewByGrp($group, $requestUser, $status, $comment, $file='') { /* {{{ */
|
||||||
if(!$group || !$requestUser)
|
if(!$group || !$requestUser)
|
||||||
|
@ -5008,24 +5090,24 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
return $reviewLogID;
|
return $reviewLogID;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add user as new approver
|
* Add user as new approver
|
||||||
*
|
*
|
||||||
* @param object $user user in charge for the approval
|
* @param object $user user in charge for the approval
|
||||||
* @param object $requestUser user requesting the operation (usually the
|
* @param object $requestUser user requesting the operation (usually the
|
||||||
* currently logged in user)
|
* currently logged in user)
|
||||||
*
|
*
|
||||||
* @return integer|false if > 0 the id of the approval log, if < 0 the error
|
* @return integer|false if > 0 the id of the approval log, if < 0 the error
|
||||||
* code, false in case of an sql error
|
* code, false in case of an sql error
|
||||||
*/
|
*/
|
||||||
function addIndApprover($user, $requestUser) { /* {{{ */
|
function addIndApprover($user, $requestUser) { /* {{{ */
|
||||||
if(!$user || !$requestUser)
|
if(!$user || !$requestUser)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
$db = $this->_document->getDMS()->getDB();
|
$db = $this->_document->getDMS()->getDB();
|
||||||
|
|
||||||
if(!$user->isType('user'))
|
if(!$user->isType('user'))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
$userID = $user->getID();
|
$userID = $user->getID();
|
||||||
|
|
||||||
|
@ -5070,28 +5152,28 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
}
|
}
|
||||||
|
|
||||||
$approveLogID = $db->getInsertID('tblDocumentApproveLog', 'approveLogID');
|
$approveLogID = $db->getInsertID('tblDocumentApproveLog', 'approveLogID');
|
||||||
$db->dropTemporaryTable('ttapproveid');
|
$db->dropTemporaryTable('ttapproveid');
|
||||||
return $approveLogID;
|
return $approveLogID;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add group as new approver
|
* Add group as new approver
|
||||||
*
|
*
|
||||||
* @param object $group group in charge for the approval
|
* @param object $group group in charge for the approval
|
||||||
* @param object $requestUser user requesting the operation (usually the
|
* @param object $requestUser user requesting the operation (usually the
|
||||||
* currently logged in user)
|
* currently logged in user)
|
||||||
*
|
*
|
||||||
* @return integer|false if > 0 the id of the approval log, if < 0 the error
|
* @return integer|false if > 0 the id of the approval log, if < 0 the error
|
||||||
* code, false in case of an sql error
|
* code, false in case of an sql error
|
||||||
*/
|
*/
|
||||||
function addGrpApprover($group, $requestUser) { /* {{{ */
|
function addGrpApprover($group, $requestUser) { /* {{{ */
|
||||||
if(!$group || !$requestUser)
|
if(!$group || !$requestUser)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
$db = $this->_document->getDMS()->getDB();
|
$db = $this->_document->getDMS()->getDB();
|
||||||
|
|
||||||
if(!$group->isType('group'))
|
if(!$group->isType('group'))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
$groupID = $group->getID();
|
$groupID = $group->getID();
|
||||||
|
|
||||||
|
@ -5142,8 +5224,8 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$approveLogID = $db->getInsertID('tblDocumentApproveLog', 'approveLogID');
|
$approveLogID = $db->getInsertID('tblDocumentApproveLog', 'approveLogID');
|
||||||
$db->dropTemporaryTable('ttapproveid');
|
$db->dropTemporaryTable('ttapproveid');
|
||||||
return $approveLogID;
|
return $approveLogID;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
@ -5158,8 +5240,8 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* Then it is check if the approval status is already -2. In both cases
|
* Then it is check if the approval status is already -2. In both cases
|
||||||
* the function returns with an error.
|
* the function returns with an error.
|
||||||
*
|
*
|
||||||
* @see SeedDMS_Core_DocumentContent::setReviewByInd()
|
* @see SeedDMS_Core_DocumentContent::setReviewByInd()
|
||||||
*
|
*
|
||||||
* @param object $user user in charge for doing the approval
|
* @param object $user user in charge for doing the approval
|
||||||
* @param object $requestUser user actually calling this function
|
* @param object $requestUser user actually calling this function
|
||||||
* @param integer $status the status of the approval, possible values are
|
* @param integer $status the status of the approval, possible values are
|
||||||
|
@ -5168,10 +5250,10 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* -1=rejected,
|
* -1=rejected,
|
||||||
* -2=user is deleted (use {link
|
* -2=user is deleted (use {link
|
||||||
* SeedDMS_Core_DocumentContent::delIndApprover} instead)
|
* SeedDMS_Core_DocumentContent::delIndApprover} instead)
|
||||||
* @param string $comment approval comment
|
* @param string $comment approval comment
|
||||||
*
|
*
|
||||||
* @return integer|bool new review log id, error code 0 till -4,
|
* @return integer|bool new review log id, error code 0 till -4,
|
||||||
* false in case of an sql error
|
* false in case of an sql error
|
||||||
*/
|
*/
|
||||||
function setApprovalByInd($user, $requestUser, $status, $comment, $file='') { /* {{{ */
|
function setApprovalByInd($user, $requestUser, $status, $comment, $file='') { /* {{{ */
|
||||||
if(!$user || !$requestUser)
|
if(!$user || !$requestUser)
|
||||||
|
@ -5179,8 +5261,8 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
|
|
||||||
$db = $this->_document->getDMS()->getDB();
|
$db = $this->_document->getDMS()->getDB();
|
||||||
|
|
||||||
if(!$user->isType('user'))
|
if(!$user->isType('user'))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// Check if the user is on the approval list at all.
|
// Check if the user is on the approval list at all.
|
||||||
$approvalStatus = $user->getApprovalStatus($this->_document->getID(), $this->_version);
|
$approvalStatus = $user->getApprovalStatus($this->_document->getID(), $this->_version);
|
||||||
|
@ -5215,7 +5297,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
SeedDMS_Core_File::copyFile($file, $this->_dms->contentDir . $this->_document->getDir() . 'a' . $approveLogID);
|
SeedDMS_Core_File::copyFile($file, $this->_dms->contentDir . $this->_document->getDir() . 'a' . $approveLogID);
|
||||||
}
|
}
|
||||||
return $approveLogID;
|
return $approveLogID;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add another entry to approval log which resets the status
|
* Add another entry to approval log which resets the status
|
||||||
|
@ -5227,12 +5309,12 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
* After calling this method SeedDMS_Core_DocumentCategory::verifyStatus()
|
* After calling this method SeedDMS_Core_DocumentCategory::verifyStatus()
|
||||||
* should be called to recalculate the document status.
|
* should be called to recalculate the document status.
|
||||||
*
|
*
|
||||||
* @param integer $approveid id of approval
|
* @param integer $approveid id of approval
|
||||||
* @param SeedDMS_Core_User $requestUser user requesting the removal
|
* @param SeedDMS_Core_User $requestUser user requesting the removal
|
||||||
* @param string $comment comment
|
* @param string $comment comment
|
||||||
*
|
*
|
||||||
* @return integer|bool true if successful, error code < 0,
|
* @return integer|bool true if successful, error code < 0,
|
||||||
* false in case of an sql error
|
* false in case of an sql error
|
||||||
*/
|
*/
|
||||||
public function removeApproval($approveid, $requestUser, $comment='') { /* {{{ */
|
public function removeApproval($approveid, $requestUser, $comment='') { /* {{{ */
|
||||||
$db = $this->_document->getDMS()->getDB();
|
$db = $this->_document->getDMS()->getDB();
|
||||||
|
@ -5280,8 +5362,8 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
|
|
||||||
$db = $this->_document->getDMS()->getDB();
|
$db = $this->_document->getDMS()->getDB();
|
||||||
|
|
||||||
if(!$group->isType('group'))
|
if(!$group->isType('group'))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
// Check if the group is on the approval list at all.
|
// Check if the group is on the approval list at all.
|
||||||
$approvalStatus = $group->getApprovalStatus($this->_document->getID(), $this->_version);
|
$approvalStatus = $group->getApprovalStatus($this->_document->getID(), $this->_version);
|
||||||
|
@ -5769,8 +5851,8 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
function delGrpReviewer($group, $requestUser, $msg='') { /* {{{ */
|
function delGrpReviewer($group, $requestUser, $msg='') { /* {{{ */
|
||||||
$db = $this->_document->getDMS()->getDB();
|
$db = $this->_document->getDMS()->getDB();
|
||||||
|
|
||||||
if(!$group->isType('group'))
|
if(!$group->isType('group'))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
$groupID = $group->getID();
|
$groupID = $group->getID();
|
||||||
|
|
||||||
|
@ -5803,8 +5885,8 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
function delIndApprover($user, $requestUser, $msg='') { /* {{{ */
|
function delIndApprover($user, $requestUser, $msg='') { /* {{{ */
|
||||||
$db = $this->_document->getDMS()->getDB();
|
$db = $this->_document->getDMS()->getDB();
|
||||||
|
|
||||||
if(!$user->isType('user'))
|
if(!$user->isType('user'))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
$userID = $user->getID();
|
$userID = $user->getID();
|
||||||
|
|
||||||
|
@ -5838,8 +5920,8 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
function delGrpApprover($group, $requestUser, $msg='') { /* {{{ */
|
function delGrpApprover($group, $requestUser, $msg='') { /* {{{ */
|
||||||
$db = $this->_document->getDMS()->getDB();
|
$db = $this->_document->getDMS()->getDB();
|
||||||
|
|
||||||
if(!$group->isType('group'))
|
if(!$group->isType('group'))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
$groupID = $group->getID();
|
$groupID = $group->getID();
|
||||||
|
|
||||||
|
@ -6190,7 +6272,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assign a workflow to a document
|
* Assign a workflow to a document content
|
||||||
*
|
*
|
||||||
* @param object $workflow
|
* @param object $workflow
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -55,7 +55,7 @@ class SeedDMS_Core_DocumentCategory {
|
||||||
|
|
||||||
function setName($newName) { /* {{{ */
|
function setName($newName) { /* {{{ */
|
||||||
$newName = trim($newName);
|
$newName = trim($newName);
|
||||||
if(!$name)
|
if(!$newName)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$db = $this->_dms->getDB();
|
$db = $this->_dms->getDB();
|
||||||
|
|
|
@ -179,8 +179,13 @@ class SeedDMS_Core_Workflow { /* {{{ */
|
||||||
return $this->_transitions;
|
return $this->_transitions;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* Get all states this workflow at some point may reach
|
||||||
|
*
|
||||||
|
* It basically iterates through all transistions and makes a unique
|
||||||
|
* list of the start and end state.
|
||||||
|
*
|
||||||
|
* @return array list of states
|
||||||
*/
|
*/
|
||||||
function getStates() { /* {{{ */
|
function getStates() { /* {{{ */
|
||||||
/** @noinspection PhpUnusedLocalVariableInspection */
|
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||||
|
@ -190,7 +195,7 @@ class SeedDMS_Core_Workflow { /* {{{ */
|
||||||
$this->getTransitions();
|
$this->getTransitions();
|
||||||
|
|
||||||
$states = array();
|
$states = array();
|
||||||
foreach($this->_transitions as $transition) {
|
foreach($this->_transitions as $transition) {
|
||||||
if(!isset($states[$transition->getState()->getID()]))
|
if(!isset($states[$transition->getState()->getID()]))
|
||||||
$states[$transition->getState()->getID()] = $transition->getState();
|
$states[$transition->getState()->getID()] = $transition->getState();
|
||||||
if(!isset($states[$transition->getNextState()->getID()]))
|
if(!isset($states[$transition->getNextState()->getID()]))
|
||||||
|
|
|
@ -58,10 +58,10 @@ class SeedDMS_Core_File {
|
||||||
*/
|
*/
|
||||||
static function moveFile($source, $target) { /* {{{ */
|
static function moveFile($source, $target) { /* {{{ */
|
||||||
/** @noinspection PhpUndefinedFunctionInspection */
|
/** @noinspection PhpUndefinedFunctionInspection */
|
||||||
if (!@copyFile($source, $target))
|
if (!self::copyFile($source, $target))
|
||||||
return false;
|
return false;
|
||||||
/** @noinspection PhpUndefinedFunctionInspection */
|
/** @noinspection PhpUndefinedFunctionInspection */
|
||||||
return @removeFile($source);
|
return self::removeFile($source);
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,7 +69,7 @@ class SeedDMS_Core_File {
|
||||||
* @return bool|int
|
* @return bool|int
|
||||||
*/
|
*/
|
||||||
static function fileSize($file) { /* {{{ */
|
static function fileSize($file) { /* {{{ */
|
||||||
if(!$a = fopen($file, 'r'))
|
if(!$a = @fopen($file, 'r'))
|
||||||
return false;
|
return false;
|
||||||
fseek($a, 0, SEEK_END);
|
fseek($a, 0, SEEK_END);
|
||||||
$filesize = ftell($a);
|
$filesize = ftell($a);
|
||||||
|
@ -84,8 +84,9 @@ class SeedDMS_Core_File {
|
||||||
*/
|
*/
|
||||||
static function format_filesize($size, $sizes = array('Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB')) { /* {{{ */
|
static function format_filesize($size, $sizes = array('Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB')) { /* {{{ */
|
||||||
if ($size == 0) return('0 Bytes');
|
if ($size == 0) return('0 Bytes');
|
||||||
/** @noinspection PhpIllegalArrayKeyTypeInspection */
|
if ($size == 1) return('1 Byte');
|
||||||
return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]);
|
/** @noinspection PhpIllegalArrayKeyTypeInspection */
|
||||||
|
return (round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $sizes[$i]);
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -204,14 +205,14 @@ class SeedDMS_Core_File {
|
||||||
{
|
{
|
||||||
if ($entry == ".." || $entry == ".")
|
if ($entry == ".." || $entry == ".")
|
||||||
continue;
|
continue;
|
||||||
else if (is_dir($path . $entry))
|
else if (is_dir($path . DIRECTORY_SEPARATOR . $entry))
|
||||||
{
|
{
|
||||||
if (!self::removeDir($path . $entry . "/"))
|
if (!self::removeDir($path . DIRECTORY_SEPARATOR . $entry . "/"))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!@unlink($path . $entry))
|
if (!@unlink($path . DIRECTORY_SEPARATOR . $entry))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,10 +232,10 @@ class SeedDMS_Core_File {
|
||||||
if ($entry == ".." || $entry == ".")
|
if ($entry == ".." || $entry == ".")
|
||||||
continue;
|
continue;
|
||||||
else if (is_dir($sourcePath . $entry)) {
|
else if (is_dir($sourcePath . $entry)) {
|
||||||
if (!self::copyDir($sourcePath . $entry . "/", $targetPath . $entry . "/"))
|
if (!self::copyDir($sourcePath . DIRECTORY_SEPARATOR . $entry, $targetPath . DIRECTORY_SEPARATOR . $entry))
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (!@copy($sourcePath . $entry, $targetPath . $entry))
|
if (!@copy($sourcePath . DIRECTORY_SEPARATOR . $entry, $targetPath . DIRECTORY_SEPARATOR . $entry))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,29 +179,39 @@ class SeedDMS_Lucene_IndexedDocument extends Zend_Search_Lucene_Document {
|
||||||
if($version && !$nocontent) {
|
if($version && !$nocontent) {
|
||||||
$path = $dms->contentDir . $version->getPath();
|
$path = $dms->contentDir . $version->getPath();
|
||||||
if(file_exists($path)) {
|
if(file_exists($path)) {
|
||||||
$content = '';
|
|
||||||
$mimetype = $version->getMimeType();
|
$mimetype = $version->getMimeType();
|
||||||
$this->mimetype = $mimetype;
|
$this->mimetype = $mimetype;
|
||||||
$cmd = '';
|
if(is_object($convcmd) && (get_class($convcmd) == 'SeedDMS_ConversionMgr')) {
|
||||||
$mimeparts = explode('/', $mimetype, 2);
|
if($convcmd->hasService($mimetype, 'text/plain')) {
|
||||||
if(isset($convcmd[$mimetype])) {
|
$content = $convcmd->convert($path, $mimetype, 'text/plain');
|
||||||
$cmd = sprintf($convcmd[$mimetype], $path);
|
if($content) {
|
||||||
} elseif(isset($convcmd[$mimeparts[0].'/*'])) {
|
self::setContent($content);
|
||||||
$cmd = sprintf($convcmd[$mimetype], $path);
|
|
||||||
} elseif(isset($convcmd['*'])) {
|
|
||||||
$cmd = sprintf($convcmd[$mimetype], $path);
|
|
||||||
}
|
|
||||||
if($cmd) {
|
|
||||||
$this->cmd = $cmd;
|
|
||||||
try {
|
|
||||||
$content = self::execWithTimeout($cmd, $timeout);
|
|
||||||
if($content['stdout']) {
|
|
||||||
$this->addField(Zend_Search_Lucene_Field::UnStored('content', $content['stdout'], 'utf-8'));
|
|
||||||
}
|
}
|
||||||
if($content['stderr']) {
|
}
|
||||||
$this->errormsg = $content['stderr'];
|
} else {
|
||||||
|
$content = '';
|
||||||
|
$cmd = '';
|
||||||
|
$mimeparts = explode('/', $mimetype, 2);
|
||||||
|
if(isset($convcmd[$mimetype])) {
|
||||||
|
$cmd = sprintf($convcmd[$mimetype], $path);
|
||||||
|
} elseif(isset($convcmd[$mimeparts[0].'/*'])) {
|
||||||
|
$cmd = sprintf($convcmd[$mimetype], $path);
|
||||||
|
} elseif(isset($convcmd['*'])) {
|
||||||
|
$cmd = sprintf($convcmd[$mimetype], $path);
|
||||||
|
}
|
||||||
|
if($cmd) {
|
||||||
|
$this->cmd = $cmd;
|
||||||
|
try {
|
||||||
|
$content = self::execWithTimeout($cmd, $timeout);
|
||||||
|
if($content['stdout']) {
|
||||||
|
self::setContent($content['stdout']);
|
||||||
|
// $this->addField(Zend_Search_Lucene_Field::UnStored('content', $content['stdout'], 'utf-8'));
|
||||||
|
}
|
||||||
|
if($content['stderr']) {
|
||||||
|
$this->errormsg = $content['stderr'];
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,12 @@ class SeedDMS_Preview_Base {
|
||||||
*/
|
*/
|
||||||
protected $converters;
|
protected $converters;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var object $conversionmgr
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
protected $conversionmgr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var integer $timeout maximum time for execution of external commands
|
* @var integer $timeout maximum time for execution of external commands
|
||||||
* @access protected
|
* @access protected
|
||||||
|
@ -69,6 +75,7 @@ class SeedDMS_Preview_Base {
|
||||||
$this->timeout = intval($timeout);
|
$this->timeout = intval($timeout);
|
||||||
$this->converters = array();
|
$this->converters = array();
|
||||||
$this->xsendfile = $xsendfile;
|
$this->xsendfile = $xsendfile;
|
||||||
|
$this->conversionmgr = null;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -145,6 +152,18 @@ class SeedDMS_Preview_Base {
|
||||||
$this->converters = array();
|
$this->converters = array();
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set conversion service manager
|
||||||
|
*
|
||||||
|
* A conversion manager is a service for converting files from one format
|
||||||
|
* to another format.
|
||||||
|
*
|
||||||
|
* @param object $conversionmgr
|
||||||
|
*/
|
||||||
|
function setConversionMgr($conversionmgr) { /* {{{ */
|
||||||
|
$this->conversionmgr = $conversionmgr;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable/Disable xsendfile extension
|
* Enable/Disable xsendfile extension
|
||||||
*
|
*
|
||||||
|
@ -173,11 +192,16 @@ class SeedDMS_Preview_Base {
|
||||||
/**
|
/**
|
||||||
* Check if converter for a given mimetype is set
|
* Check if converter for a given mimetype is set
|
||||||
*
|
*
|
||||||
* @param string $mimetype
|
* @param string $from from mimetype
|
||||||
|
* @param string $to to mimetype
|
||||||
|
*
|
||||||
* @return boolean true if converter exists, otherwise false
|
* @return boolean true if converter exists, otherwise false
|
||||||
*/
|
*/
|
||||||
function hasConverter($mimetype) { /* {{{ */
|
function hasConverter($from, $to='') { /* {{{ */
|
||||||
return array_key_exists($mimetype, $this->converters) && $this->converters[$mimetype];
|
if($this->conversionmgr)
|
||||||
|
return $this->conversionmgr->hasService($from, $to);
|
||||||
|
else
|
||||||
|
return array_key_exists($from, $this->converters) && $this->converters[$from];
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -68,6 +68,17 @@ class SeedDMS_Preview_PdfPreviewer extends SeedDMS_Preview_Base {
|
||||||
return $target;
|
return $target;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if converter for a given mimetype is set
|
||||||
|
*
|
||||||
|
* @param string $mimetype from mimetype
|
||||||
|
*
|
||||||
|
* @return boolean true if converter exists, otherwise false
|
||||||
|
*/
|
||||||
|
function hasConverter($from, $to='') { /* {{{ */
|
||||||
|
return parent::hasConverter($from, 'application/pdf');
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a pdf preview for a given file
|
* Create a pdf preview for a given file
|
||||||
*
|
*
|
||||||
|
@ -98,21 +109,27 @@ class SeedDMS_Preview_PdfPreviewer extends SeedDMS_Preview_Base {
|
||||||
$target = $this->previewDir.$dir.md5($infile);
|
$target = $this->previewDir.$dir.md5($infile);
|
||||||
$this->lastpreviewfile = $target.'.pdf';
|
$this->lastpreviewfile = $target.'.pdf';
|
||||||
if($target != '' && (!file_exists($target.'.pdf') || filectime($target.'.pdf') < filectime($infile))) {
|
if($target != '' && (!file_exists($target.'.pdf') || filectime($target.'.pdf') < filectime($infile))) {
|
||||||
$cmd = '';
|
if($this->conversionmgr) {
|
||||||
$mimeparts = explode('/', $mimetype, 2);
|
if($this->conversionmgr->hasService($mimetype, 'application/pdf')) {
|
||||||
if(isset($this->converters[$mimetype])) {
|
return $this->conversionmgr->convert($infile, $mimetype, 'application/pdf', $target.'.pdf');
|
||||||
$cmd = str_replace(array('%f', '%o', '%m'), array($infile, $target.'.pdf', $mimetype), $this->converters[$mimetype]);
|
}
|
||||||
} elseif(isset($this->converters[$mimeparts[0].'/*'])) {
|
} else {
|
||||||
$cmd = str_replace(array('%f', '%o', '%m'), array($infile, $target.'.pdf', $mimetype), $this->converters[$mimeparts[0].'/*']);
|
$cmd = '';
|
||||||
} elseif(isset($this->converters['*'])) {
|
$mimeparts = explode('/', $mimetype, 2);
|
||||||
$cmd = str_replace(array('%f', '%o', '%m'), array($infile, $target.'.pdf', $mimetype), $this->converters['*']);
|
if(isset($this->converters[$mimetype])) {
|
||||||
}
|
$cmd = str_replace(array('%f', '%o', '%m'), array($infile, $target.'.pdf', $mimetype), $this->converters[$mimetype]);
|
||||||
if($cmd) {
|
} elseif(isset($this->converters[$mimeparts[0].'/*'])) {
|
||||||
try {
|
$cmd = str_replace(array('%f', '%o', '%m'), array($infile, $target.'.pdf', $mimetype), $this->converters[$mimeparts[0].'/*']);
|
||||||
self::execWithTimeout($cmd, $this->timeout);
|
} elseif(isset($this->converters['*'])) {
|
||||||
} catch(Exception $e) {
|
$cmd = str_replace(array('%f', '%o', '%m'), array($infile, $target.'.pdf', $mimetype), $this->converters['*']);
|
||||||
$this->lastpreviewfile = '';
|
}
|
||||||
return false;
|
if($cmd) {
|
||||||
|
try {
|
||||||
|
self::execWithTimeout($cmd, $this->timeout);
|
||||||
|
} catch(Exception $e) {
|
||||||
|
$this->lastpreviewfile = '';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -72,6 +72,17 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base {
|
||||||
return $target;
|
return $target;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if converter for a given mimetype is set
|
||||||
|
*
|
||||||
|
* @param string $mimetype from mimetype
|
||||||
|
*
|
||||||
|
* @return boolean true if converter exists, otherwise false
|
||||||
|
*/
|
||||||
|
function hasConverter($from, $to='') { /* {{{ */
|
||||||
|
return parent::hasConverter($from, 'image/png');
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a preview image for a given file
|
* Create a preview image for a given file
|
||||||
*
|
*
|
||||||
|
@ -107,23 +118,33 @@ class SeedDMS_Preview_Previewer extends SeedDMS_Preview_Base {
|
||||||
$target = $this->previewDir.$dir.md5($infile).'-'.$width;
|
$target = $this->previewDir.$dir.md5($infile).'-'.$width;
|
||||||
$this->lastpreviewfile = $target.'.png';
|
$this->lastpreviewfile = $target.'.png';
|
||||||
if($target != '' && (!file_exists($target.'.png') || filectime($target.'.png') < filectime($infile))) {
|
if($target != '' && (!file_exists($target.'.png') || filectime($target.'.png') < filectime($infile))) {
|
||||||
$cmd = '';
|
if($this->conversionmgr) {
|
||||||
$mimeparts = explode('/', $mimetype, 2);
|
if($this->conversionmgr->hasService($mimetype, 'image/png')) {
|
||||||
if(isset($this->converters[$mimetype])) {
|
if(!$this->conversionmgr->convert($infile, $mimetype, 'image/png', $target.'.png', array('width'=>$width))) {
|
||||||
$cmd = str_replace(array('%w', '%f', '%o', '%m'), array($width, $infile, $target.'.png', $mimetype), $this->converters[$mimetype]);
|
$this->lastpreviewfile = '';
|
||||||
} elseif(isset($this->converters[$mimeparts[0].'/*'])) {
|
return false;
|
||||||
$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['*']);
|
$new = true;
|
||||||
}
|
} else {
|
||||||
|
$cmd = '';
|
||||||
|
$mimeparts = explode('/', $mimetype, 2);
|
||||||
|
if(isset($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['*']);
|
||||||
|
}
|
||||||
|
|
||||||
if($cmd) {
|
if($cmd) {
|
||||||
try {
|
try {
|
||||||
self::execWithTimeout($cmd, $this->timeout);
|
self::execWithTimeout($cmd, $this->timeout);
|
||||||
$new = true;
|
$new = true;
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$this->lastpreviewfile = '';
|
$this->lastpreviewfile = '';
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -106,6 +106,9 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
|
||||||
/**
|
/**
|
||||||
* Constructor. Creates our indexable document and adds all
|
* Constructor. Creates our indexable document and adds all
|
||||||
* necessary fields to it using the passed in document
|
* necessary fields to it using the passed in document
|
||||||
|
*
|
||||||
|
* $convcmd can either be an array of conversion commands or
|
||||||
|
* an object of class SeedDMS_ConversionMgr
|
||||||
*/
|
*/
|
||||||
public function __construct($dms, $document, $convcmd=null, $nocontent=false, $timeout=5) { /* {{{ */
|
public function __construct($dms, $document, $convcmd=null, $nocontent=false, $timeout=5) { /* {{{ */
|
||||||
$this->errormsg = '';
|
$this->errormsg = '';
|
||||||
|
@ -176,29 +179,42 @@ class SeedDMS_SQLiteFTS_IndexedDocument extends SeedDMS_SQLiteFTS_Document {
|
||||||
if($version && !$nocontent) {
|
if($version && !$nocontent) {
|
||||||
$path = $dms->contentDir . $version->getPath();
|
$path = $dms->contentDir . $version->getPath();
|
||||||
if(file_exists($path)) {
|
if(file_exists($path)) {
|
||||||
$content = '';
|
|
||||||
$mimetype = $version->getMimeType();
|
$mimetype = $version->getMimeType();
|
||||||
$this->mimetype = $mimetype;
|
$this->mimetype = $mimetype;
|
||||||
$cmd = '';
|
if(is_object($convcmd) && (get_class($convcmd) == 'SeedDMS_ConversionMgr')) {
|
||||||
$mimeparts = explode('/', $mimetype, 2);
|
if($convcmd->hasService($mimetype, 'text/plain')) {
|
||||||
if(isset($convcmd[$mimetype])) {
|
$content = $convcmd->convert($path, $mimetype, 'text/plain');
|
||||||
$cmd = sprintf($convcmd[$mimetype], $path);
|
if($content) {
|
||||||
} elseif(isset($convcmd[$mimeparts[0].'/*'])) {
|
self::setContent($content);
|
||||||
$cmd = sprintf($convcmd[$mimetype], $path);
|
|
||||||
} elseif(isset($convcmd['*'])) {
|
|
||||||
$cmd = sprintf($convcmd[$mimetype], $path);
|
|
||||||
}
|
|
||||||
if($cmd) {
|
|
||||||
$this->cmd = $cmd;
|
|
||||||
try {
|
|
||||||
$content = self::execWithTimeout($cmd, $timeout);
|
|
||||||
if($content['stdout']) {
|
|
||||||
$this->addField(SeedDMS_SQLiteFTS_Field::UnStored('content', $content['stdout']));
|
|
||||||
}
|
}
|
||||||
if($content['stderr']) {
|
$this->cmd = get_class($convcmd);
|
||||||
$this->errormsg = $content['stderr'];
|
} else {
|
||||||
|
$this->cmd = 'No service to convert '.$mimetype.' to text/plain';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$content = '';
|
||||||
|
$cmd = '';
|
||||||
|
$mimeparts = explode('/', $mimetype, 2);
|
||||||
|
if(isset($convcmd[$mimetype])) {
|
||||||
|
$cmd = sprintf($convcmd[$mimetype], $path);
|
||||||
|
} elseif(isset($convcmd[$mimeparts[0].'/*'])) {
|
||||||
|
$cmd = sprintf($convcmd[$mimetype], $path);
|
||||||
|
} elseif(isset($convcmd['*'])) {
|
||||||
|
$cmd = sprintf($convcmd[$mimetype], $path);
|
||||||
|
}
|
||||||
|
if($cmd) {
|
||||||
|
$this->cmd = $cmd;
|
||||||
|
try {
|
||||||
|
$content = self::execWithTimeout($cmd, $timeout);
|
||||||
|
if($content['stdout']) {
|
||||||
|
self::setContent($content['stdout']);
|
||||||
|
// $this->addField(SeedDMS_SQLiteFTS_Field::UnStored('content', $content['stdout']));
|
||||||
|
}
|
||||||
|
if($content['stderr']) {
|
||||||
|
$this->errormsg = $content['stderr'];
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,11 @@ class SeedDMS_SQLiteFTS_Indexer {
|
||||||
${$kk} = '';
|
${$kk} = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$sql = "DELETE FROM docs WHERE documentid=".$this->_conn->quote($doc->getFieldValue('document_id'));
|
||||||
|
$res = $this->_conn->exec($sql);
|
||||||
|
if($res === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$sql = "INSERT INTO docs (documentid, title, comment, keywords, category, owner, content, mimetype, origfilename, created, users, status, path) VALUES (".$this->_conn->quote($doc->getFieldValue('document_id')).", ".$this->_conn->quote($doc->getFieldValue('title')).", ".$this->_conn->quote($comment).", ".$this->_conn->quote($keywords).", ".$this->_conn->quote($category).", ".$this->_conn->quote($doc->getFieldValue('owner')).", ".$this->_conn->quote($content).", ".$this->_conn->quote($mimetype).", ".$this->_conn->quote($origfilename).", ".(int)$created.", ".$this->_conn->quote($doc->getFieldValue('users')).", ".$this->_conn->quote($status).", ".$this->_conn->quote($doc->getFieldValue('path'))/*time()*/.")";
|
$sql = "INSERT INTO docs (documentid, title, comment, keywords, category, owner, content, mimetype, origfilename, created, users, status, path) VALUES (".$this->_conn->quote($doc->getFieldValue('document_id')).", ".$this->_conn->quote($doc->getFieldValue('title')).", ".$this->_conn->quote($comment).", ".$this->_conn->quote($keywords).", ".$this->_conn->quote($category).", ".$this->_conn->quote($doc->getFieldValue('owner')).", ".$this->_conn->quote($content).", ".$this->_conn->quote($mimetype).", ".$this->_conn->quote($origfilename).", ".(int)$created.", ".$this->_conn->quote($doc->getFieldValue('users')).", ".$this->_conn->quote($status).", ".$this->_conn->quote($doc->getFieldValue('path'))/*time()*/.")";
|
||||||
$res = $this->_conn->exec($sql);
|
$res = $this->_conn->exec($sql);
|
||||||
if($res === false) {
|
if($res === false) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ class SeedDMS_Controller_PdfPreview extends SeedDMS_Controller_Common {
|
||||||
$dms = $this->params['dms'];
|
$dms = $this->params['dms'];
|
||||||
$type = $this->params['type'];
|
$type = $this->params['type'];
|
||||||
$settings = $this->params['settings'];
|
$settings = $this->params['settings'];
|
||||||
|
$conversionmgr = $this->params['conversionmgr'];
|
||||||
|
|
||||||
switch($type) {
|
switch($type) {
|
||||||
case "version":
|
case "version":
|
||||||
|
@ -51,7 +52,10 @@ class SeedDMS_Controller_PdfPreview extends SeedDMS_Controller_Common {
|
||||||
$this->params['content'] = $content;
|
$this->params['content'] = $content;
|
||||||
if(null === $this->callHook('version')) {
|
if(null === $this->callHook('version')) {
|
||||||
$previewer = new SeedDMS_Preview_PdfPreviewer($settings->_cacheDir, $settings->_cmdTimeout);
|
$previewer = new SeedDMS_Preview_PdfPreviewer($settings->_cacheDir, $settings->_cmdTimeout);
|
||||||
$previewer->setConverters(isset($settings->_converters['pdf']) ? $settings->_converters['pdf'] : array());
|
if($conversionmgr)
|
||||||
|
$previewer->setConversionMgr($conversionmgr);
|
||||||
|
else
|
||||||
|
$previewer->setConverters(isset($settings->_converters['pdf']) ? $settings->_converters['pdf'] : array());
|
||||||
$previewer->setXsendfile($settings->_enableXsendfile);
|
$previewer->setXsendfile($settings->_enableXsendfile);
|
||||||
if(!$previewer->hasPreview($content)) {
|
if(!$previewer->hasPreview($content)) {
|
||||||
add_log_line("");
|
add_log_line("");
|
||||||
|
|
|
@ -27,6 +27,7 @@ class SeedDMS_Controller_Preview extends SeedDMS_Controller_Common {
|
||||||
$dms = $this->params['dms'];
|
$dms = $this->params['dms'];
|
||||||
$type = $this->params['type'];
|
$type = $this->params['type'];
|
||||||
$settings = $this->params['settings'];
|
$settings = $this->params['settings'];
|
||||||
|
$conversionmgr = $this->params['conversionmgr'];
|
||||||
|
|
||||||
switch($type) {
|
switch($type) {
|
||||||
case "version":
|
case "version":
|
||||||
|
@ -55,7 +56,10 @@ class SeedDMS_Controller_Preview extends SeedDMS_Controller_Common {
|
||||||
$previewer = new SeedDMS_Preview_Previewer($settings->_cacheDir, $width, $settings->_cmdTimeout);
|
$previewer = new SeedDMS_Preview_Previewer($settings->_cacheDir, $width, $settings->_cmdTimeout);
|
||||||
else
|
else
|
||||||
$previewer = new SeedDMS_Preview_Previewer($settings->_cacheDir);
|
$previewer = new SeedDMS_Preview_Previewer($settings->_cacheDir);
|
||||||
$previewer->setConverters($settings->_converters['preview']);
|
if($conversionmgr)
|
||||||
|
$previewer->setConversionMgr($conversionmgr);
|
||||||
|
else
|
||||||
|
$previewer->setConverters($settings->_converters['preview']);
|
||||||
$previewer->setXsendfile($settings->_enableXsendfile);
|
$previewer->setXsendfile($settings->_enableXsendfile);
|
||||||
if(!$previewer->hasPreview($content)) {
|
if(!$previewer->hasPreview($content)) {
|
||||||
add_log_line("");
|
add_log_line("");
|
||||||
|
@ -86,7 +90,10 @@ class SeedDMS_Controller_Preview extends SeedDMS_Controller_Common {
|
||||||
$previewer = new SeedDMS_Preview_Previewer($settings->_cacheDir, $width, $settings->_cmdTimeout);
|
$previewer = new SeedDMS_Preview_Previewer($settings->_cacheDir, $width, $settings->_cmdTimeout);
|
||||||
else
|
else
|
||||||
$previewer = new SeedDMS_Preview_Previewer($settings->_cacheDir);
|
$previewer = new SeedDMS_Preview_Previewer($settings->_cacheDir);
|
||||||
$previewer->setConverters($settings->_converters['preview']);
|
if($conversionmgr)
|
||||||
|
$previewer->setConversionMgr($conversionmgr);
|
||||||
|
else
|
||||||
|
$previewer->setConverters($settings->_converters['preview']);
|
||||||
$previewer->setXsendfile($settings->_enableXsendfile);
|
$previewer->setXsendfile($settings->_enableXsendfile);
|
||||||
|
|
||||||
if(!$previewer->hasPreview($object)) {
|
if(!$previewer->hasPreview($object)) {
|
||||||
|
|
65
inc/inc.ClassConversionMgr.php
Normal file
65
inc/inc.ClassConversionMgr.php
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Implementation of conversion manager
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @license GPL 2
|
||||||
|
* @version @version@
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2021 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once("inc/inc.ClassConversionServiceExec.php");
|
||||||
|
require_once("inc/inc.ClassConversionServiceImageToImage.php");
|
||||||
|
require_once("inc/inc.ClassConversionServicePdfToImage.php");
|
||||||
|
require_once("inc/inc.ClassConversionServiceTextToText.php");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of conversion manager
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2021 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
class SeedDMS_ConversionMgr {
|
||||||
|
/**
|
||||||
|
* List of services for searching fulltext
|
||||||
|
*/
|
||||||
|
public $services;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
$this->services = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addService($service) {
|
||||||
|
$this->services[$service->from][$service->to][] = $service;
|
||||||
|
return $service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasService($from, $to) {
|
||||||
|
if(!empty($this->services[$from][$to]))
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a file
|
||||||
|
*
|
||||||
|
* @param string $file name of file to convert
|
||||||
|
* @param string $from mimetype of input file
|
||||||
|
* @param string $to mimetype of output file
|
||||||
|
*
|
||||||
|
* @return boolean true on success, other false
|
||||||
|
*/
|
||||||
|
public function convert($file, $from, $to, $target=null, $params=array()) {
|
||||||
|
if(isset($this->services[$from][$to])) {
|
||||||
|
$service = array_pop($this->services[$from][$to]);
|
||||||
|
return $service->convert($file, $target, $params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
54
inc/inc.ClassConversionServiceBase.php
Normal file
54
inc/inc.ClassConversionServiceBase.php
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Implementation of conversion service base class
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @license GPL 2
|
||||||
|
* @version @version@
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2021 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of conversion service base class
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2021 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
abstract class SeedDMS_ConversionServiceBase {
|
||||||
|
/**
|
||||||
|
* mimetype original file
|
||||||
|
*/
|
||||||
|
public $from;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mimetype converted file
|
||||||
|
*/
|
||||||
|
public $to;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* logger
|
||||||
|
*/
|
||||||
|
protected $logger;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
$this->from = null;
|
||||||
|
$this->to = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setLogger($logger) {
|
||||||
|
$this->logger = $logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getInfo() {
|
||||||
|
return 'Conversion service';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function convert($infile, $target = null, $params = array()) {
|
||||||
|
}
|
||||||
|
}
|
126
inc/inc.ClassConversionServiceExec.php
Normal file
126
inc/inc.ClassConversionServiceExec.php
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Implementation of conversion service exec class
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @license GPL 2
|
||||||
|
* @version @version@
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2021 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once("inc/inc.ClassConversionServiceBase.php");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of conversion service exec class
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2021 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
class SeedDMS_ConversionServiceExec extends SeedDMS_ConversionServiceBase {
|
||||||
|
/**
|
||||||
|
* shell cmd
|
||||||
|
*/
|
||||||
|
public $cmd;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* timeout
|
||||||
|
*/
|
||||||
|
public $timeout;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run a shell command
|
||||||
|
*
|
||||||
|
* @param $cmd
|
||||||
|
* @param int $timeout
|
||||||
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
static function execWithTimeout($cmd, $timeout=5) { /* {{{ */
|
||||||
|
$descriptorspec = array(
|
||||||
|
0 => array("pipe", "r"),
|
||||||
|
1 => array("pipe", "w"),
|
||||||
|
2 => array("pipe", "w")
|
||||||
|
);
|
||||||
|
$pipes = array();
|
||||||
|
|
||||||
|
$timeout += time();
|
||||||
|
// Putting an 'exec' before the command will not fork the command
|
||||||
|
// and therefore not create any child process. proc_terminate will
|
||||||
|
// then reliably terminate the cmd and not just shell. See notes of
|
||||||
|
// https://www.php.net/manual/de/function.proc-terminate.php
|
||||||
|
$process = proc_open('exec '.$cmd, $descriptorspec, $pipes);
|
||||||
|
if (!is_resource($process)) {
|
||||||
|
throw new Exception("proc_open failed on: " . $cmd);
|
||||||
|
}
|
||||||
|
stream_set_blocking($pipes[1], 0);
|
||||||
|
stream_set_blocking($pipes[2], 0);
|
||||||
|
|
||||||
|
$output = $error = '';
|
||||||
|
$timeleft = $timeout - time();
|
||||||
|
$read = array($pipes[1], $pipes[2]);
|
||||||
|
$write = NULL;
|
||||||
|
$exeptions = NULL;
|
||||||
|
do {
|
||||||
|
$num_changed_streams = stream_select($read, $write, $exeptions, $timeleft, 200000);
|
||||||
|
|
||||||
|
if ($num_changed_streams === false) {
|
||||||
|
proc_terminate($process);
|
||||||
|
throw new Exception("stream select failed on: " . $cmd);
|
||||||
|
} elseif ($num_changed_streams > 0) {
|
||||||
|
$output .= fread($pipes[1], 8192);
|
||||||
|
$error .= fread($pipes[2], 8192);
|
||||||
|
}
|
||||||
|
$timeleft = $timeout - time();
|
||||||
|
} while (!feof($pipes[1]) && $timeleft > 0);
|
||||||
|
|
||||||
|
fclose($pipes[0]);
|
||||||
|
fclose($pipes[1]);
|
||||||
|
fclose($pipes[2]);
|
||||||
|
if ($timeleft <= 0) {
|
||||||
|
proc_terminate($process);
|
||||||
|
throw new Exception("command timeout on: " . $cmd);
|
||||||
|
} else {
|
||||||
|
$return_value = proc_close($process);
|
||||||
|
return array('stdout'=>$output, 'stderr'=>$error, 'return'=>$return_value);
|
||||||
|
}
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
public function __construct($from, $to, $cmd) {
|
||||||
|
$this->from = $from;
|
||||||
|
$this->to = $to;
|
||||||
|
$this->cmd = $cmd;
|
||||||
|
$this->timeout = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function convert($infile, $target = null, $params = array()) {
|
||||||
|
$start = microtime(true);
|
||||||
|
if(!$target)
|
||||||
|
$tmpfile = tempnam(sys_get_temp_dir(), 'convert');
|
||||||
|
else
|
||||||
|
$tmpfile = $target;
|
||||||
|
$cmd = str_replace(array('%w', '%f', '%o', '%m'), array(isset($params['width']) ? $params['width'] : '', $infile, $tmpfile, $this->from), $this->cmd);
|
||||||
|
try {
|
||||||
|
self::execWithTimeout($cmd, $this->timeout);
|
||||||
|
} catch(Exception $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$end = microtime(true);
|
||||||
|
if($this->logger) {
|
||||||
|
$this->logger->log('Conversion from '.$this->from.' to '.$this->to.' with cmd "'.$this->cmd.'" took '.($end-$start).' sec.', PEAR_LOG_INFO);
|
||||||
|
}
|
||||||
|
if(!$target) {
|
||||||
|
$content = file_get_contents($tmpfile);
|
||||||
|
unlink($tmpfile);
|
||||||
|
return $content;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
57
inc/inc.ClassConversionServiceImageToImage.php
Normal file
57
inc/inc.ClassConversionServiceImageToImage.php
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Implementation of conversion service image class
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @license GPL 2
|
||||||
|
* @version @version@
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2021 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once("inc/inc.ClassConversionServiceBase.php");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of conversion service image class
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2021 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
class SeedDMS_ConversionServiceImageToImage extends SeedDMS_ConversionServiceBase {
|
||||||
|
/**
|
||||||
|
* timeout
|
||||||
|
*/
|
||||||
|
public $timeout;
|
||||||
|
|
||||||
|
public function __construct($from, $to) {
|
||||||
|
$this->from = $from;
|
||||||
|
$this->to = $to;
|
||||||
|
$this->timeout = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function convert($infile, $target = null, $params = array()) {
|
||||||
|
$start = microtime(true);
|
||||||
|
$imagick = new Imagick();
|
||||||
|
if($imagick->readImage($infile)) {
|
||||||
|
if(!empty($params['width']))
|
||||||
|
$imagick->scaleImage((int) $params['width'], 0);
|
||||||
|
$end = microtime(true);
|
||||||
|
if($this->logger) {
|
||||||
|
$this->logger->log('Conversion from '.$this->from.' to '.$this->to.' with image service took '.($end-$start).' sec.', PEAR_LOG_INFO);
|
||||||
|
}
|
||||||
|
if($target) {
|
||||||
|
return $imagick->writeImage($target);
|
||||||
|
} else {
|
||||||
|
return $imagick->getImageBlob();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
63
inc/inc.ClassConversionServicePdfToImage.php
Normal file
63
inc/inc.ClassConversionServicePdfToImage.php
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Implementation of conversion service pdf class
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @license GPL 2
|
||||||
|
* @version @version@
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2021 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once("inc/inc.ClassConversionServiceBase.php");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of conversion service pdf class
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2021 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
class SeedDMS_ConversionServicePdfToImage extends SeedDMS_ConversionServiceBase {
|
||||||
|
/**
|
||||||
|
* timeout
|
||||||
|
*/
|
||||||
|
public $timeout;
|
||||||
|
|
||||||
|
public function __construct($from, $to) {
|
||||||
|
$this->from = $from;
|
||||||
|
$this->to = $to;
|
||||||
|
$this->timeout = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function convert($infile, $target = null, $params = array()) {
|
||||||
|
$start = microtime(true);
|
||||||
|
$imagick = new Imagick();
|
||||||
|
/* Setting a smaller resolution will speed up the conversion
|
||||||
|
* A resolution of 72,72 will create a 596x842 image
|
||||||
|
*/
|
||||||
|
$imagick->setResolution(36,36);
|
||||||
|
if($imagick->readImage($infile.'[0]')) {
|
||||||
|
if(!empty($params['width']))
|
||||||
|
$imagick->scaleImage((int) $params['width'], 0);
|
||||||
|
$imagick->setImageFormat('png');
|
||||||
|
$end = microtime(true);
|
||||||
|
if($this->logger) {
|
||||||
|
$this->logger->log('Conversion from '.$this->from.' to '.$this->to.' with pdf service took '.($end-$start).' sec.', PEAR_LOG_INFO);
|
||||||
|
}
|
||||||
|
if($target) {
|
||||||
|
return $imagick->writeImage($target);
|
||||||
|
} else {
|
||||||
|
return $imagick->getImageBlob();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
39
inc/inc.ClassConversionServiceTextToText.php
Normal file
39
inc/inc.ClassConversionServiceTextToText.php
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Implementation of conversion service class
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @license GPL 2
|
||||||
|
* @version @version@
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2021 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once("inc/inc.ClassConversionServiceBase.php");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of conversion service class for text to text
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2021 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
class SeedDMS_ConversionServiceTextToText extends SeedDMS_ConversionServiceBase {
|
||||||
|
public function __construct($from, $to) {
|
||||||
|
$this->from = $from;
|
||||||
|
$this->to = $to;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function convert($infile, $target = null, $params = array()) {
|
||||||
|
if($target) {
|
||||||
|
file_put_contents($target, file_get_contents($infile));
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
return file_get_contents($infile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -31,6 +31,11 @@ class SeedDMS_FulltextService {
|
||||||
*/
|
*/
|
||||||
protected $converters;
|
protected $converters;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var object
|
||||||
|
*/
|
||||||
|
protected $conversionmgr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Max file size for imediate indexing
|
* Max file size for imediate indexing
|
||||||
*/
|
*/
|
||||||
|
@ -43,6 +48,7 @@ class SeedDMS_FulltextService {
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->services = array();
|
$this->services = array();
|
||||||
$this->converters = array();
|
$this->converters = array();
|
||||||
|
$this->conversionmgr = null;
|
||||||
$this->maxsize = 0;
|
$this->maxsize = 0;
|
||||||
$this->index = null;
|
$this->index = null;
|
||||||
$this->search = null;
|
$this->search = null;
|
||||||
|
@ -57,6 +63,18 @@ class SeedDMS_FulltextService {
|
||||||
$this->converters = $converters;
|
$this->converters = $converters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set conversion service manager
|
||||||
|
*
|
||||||
|
* A conversion manager is a service for converting files from one format
|
||||||
|
* to another format.
|
||||||
|
*
|
||||||
|
* @param object $conversionmgr
|
||||||
|
*/
|
||||||
|
function setConversionMgr($conversionmgr) { /* {{{ */
|
||||||
|
$this->conversionmgr = $conversionmgr;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
public function setMaxSize($maxsize) {
|
public function setMaxSize($maxsize) {
|
||||||
$this->maxsize = $maxsize;
|
$this->maxsize = $maxsize;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +98,7 @@ class SeedDMS_FulltextService {
|
||||||
$nocontent = ($object->getLatestContent()->getFileSize() > $this->maxsize) && !$forceupdate;
|
$nocontent = ($object->getLatestContent()->getFileSize() > $this->maxsize) && !$forceupdate;
|
||||||
else
|
else
|
||||||
$nocontent = true;
|
$nocontent = true;
|
||||||
return new $this->services[0]['IndexedDocument']($object->getDMS(), $object, $this->converters, $nocontent, $this->cmdtimeout);
|
return new $this->services[0]['IndexedDocument']($object->getDMS(), $object, $this->conversionmgr ? $this->conversionmgr : $this->converters, $nocontent, $this->cmdtimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
36
inc/inc.ConversionInit.php
Normal file
36
inc/inc.ConversionInit.php
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
$conversionmgr = null;
|
||||||
|
require_once("inc.ClassConversionMgr.php");
|
||||||
|
$conversionmgr = new SeedDMS_ConversionMgr();
|
||||||
|
|
||||||
|
if(!empty($settings->_converters['preview'])) {
|
||||||
|
foreach($settings->_converters['preview'] as $mimetype=>$cmd) {
|
||||||
|
$conversionmgr->addService(new SeedDMS_ConversionServiceExec($mimetype, 'image/png', $cmd))->setLogger($logger);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($settings->_converters['pdf'])) {
|
||||||
|
foreach($settings->_converters['pdf'] as $mimetype=>$cmd) {
|
||||||
|
$conversionmgr->addService(new SeedDMS_ConversionServiceExec($mimetype, 'application/pdf', $cmd))->setLogger($logger);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$conversionmgr->addService(new SeedDMS_ConversionServicePdfToImage('application/pdf', 'image/png'))->setLogger($logger);
|
||||||
|
|
||||||
|
$conversionmgr->addService(new SeedDMS_ConversionServiceImageToImage('image/jpeg', 'image/png'))->setLogger($logger);
|
||||||
|
$conversionmgr->addService(new SeedDMS_ConversionServiceImageToImage('image/png', 'image/png'))->setLogger($logger);
|
||||||
|
$conversionmgr->addService(new SeedDMS_ConversionServiceImageToImage('image/jpg', 'image/png'))->setLogger($logger);
|
||||||
|
|
||||||
|
$conversionmgr->addService(new SeedDMS_ConversionServiceTextToText('text/plain', 'text/plain'))->setLogger($logger);
|
||||||
|
|
||||||
|
if(isset($GLOBALS['SEEDDMS_HOOKS']['initConversion'])) {
|
||||||
|
foreach($GLOBALS['SEEDDMS_HOOKS']['initConversion'] as $hookObj) {
|
||||||
|
if (method_exists($hookObj, 'getConversionServices')) {
|
||||||
|
if($services = $hookObj->getConversionServices(array('dms'=>$dms, 'settings'=>$settings, 'logger'=>$logger))) {
|
||||||
|
foreach($services as $service) {
|
||||||
|
$conversionmgr->addService($service)->setLogger($logger);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -67,4 +67,5 @@ if(isset($GLOBALS['SEEDDMS_HOOKS']['initDMS'])) {
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once('inc/inc.Tasks.php');
|
require_once('inc/inc.Tasks.php');
|
||||||
|
require_once("inc.ConversionInit.php");
|
||||||
require_once('inc.FulltextInit.php');
|
require_once('inc.FulltextInit.php');
|
||||||
|
|
|
@ -42,6 +42,7 @@ if($settings->_enableFullSearch) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$fulltextservice->setConverters(isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null);
|
$fulltextservice->setConverters(isset($settings->_converters['fulltext']) ? $settings->_converters['fulltext'] : null);
|
||||||
|
$fulltextservice->setConversionMgr($conversionmgr);
|
||||||
$fulltextservice->setMaxSize($settings->_maxSizeForFullText);
|
$fulltextservice->setMaxSize($settings->_maxSizeForFullText);
|
||||||
$fulltextservice->setCmdTimeout($settings->_cmdTimeout);
|
$fulltextservice->setCmdTimeout($settings->_cmdTimeout);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ if(isset($_GET['version'])) {
|
||||||
$controller->setParam('document', $document);
|
$controller->setParam('document', $document);
|
||||||
$controller->setParam('version', $version);
|
$controller->setParam('version', $version);
|
||||||
$controller->setParam('type', 'version');
|
$controller->setParam('type', 'version');
|
||||||
|
$controller->setParam('conversionmgr', $conversionmgr);
|
||||||
if(!$controller->run()) {
|
if(!$controller->run()) {
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@ if ($document->getAccessMode($user) < M_READ) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$controller->setParam('conversionmgr', $conversionmgr);
|
||||||
if(isset($_GET['version'])) {
|
if(isset($_GET['version'])) {
|
||||||
$version = $_GET["version"];
|
$version = $_GET["version"];
|
||||||
if (!is_numeric($version))
|
if (!is_numeric($version))
|
||||||
|
|
|
@ -70,6 +70,7 @@ if ($latestContent->getVersion()==$version->getVersion()) {
|
||||||
$folder = $document->getFolder();
|
$folder = $document->getFolder();
|
||||||
|
|
||||||
if($view) {
|
if($view) {
|
||||||
|
$view->setParam('conversionmgr', $conversionmgr);
|
||||||
$view->setParam('folder', $folder);
|
$view->setParam('folder', $folder);
|
||||||
$view->setParam('document', $document);
|
$view->setParam('document', $document);
|
||||||
$view->setParam('version', $version);
|
$view->setParam('version', $version);
|
||||||
|
|
|
@ -29,7 +29,7 @@ require_once("inc/inc.Authentication.php");
|
||||||
|
|
||||||
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
||||||
$view = UI::factory($theme, $tmp[1]);
|
$view = UI::factory($theme, $tmp[1]);
|
||||||
$accessop = new SeedDMS_AccessOperation($dms, null, $user, $settings);
|
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
|
||||||
|
|
||||||
if(isset($_GET['context']))
|
if(isset($_GET['context']))
|
||||||
$context = $_GET['context'];
|
$context = $_GET['context'];
|
||||||
|
|
|
@ -72,6 +72,7 @@ if ($document->checkForDueRevisionWorkflow($user)){
|
||||||
|
|
||||||
if($view) {
|
if($view) {
|
||||||
$view->setParam('fulltextservice', $fulltextservice);
|
$view->setParam('fulltextservice', $fulltextservice);
|
||||||
|
$view->setParam('conversionmgr', $conversionmgr);
|
||||||
$view->setParam('folder', $folder);
|
$view->setParam('folder', $folder);
|
||||||
$view->setParam('document', $document);
|
$view->setParam('document', $document);
|
||||||
$view->setParam('showtree', showtree());
|
$view->setParam('showtree', showtree());
|
||||||
|
|
|
@ -77,6 +77,7 @@ if($view) {
|
||||||
if(isset($_GET['action']) && $_GET['action'] == 'subtree')
|
if(isset($_GET['action']) && $_GET['action'] == 'subtree')
|
||||||
$view->setParam('node', $node);
|
$view->setParam('node', $node);
|
||||||
$view->setParam('fulltextservice', $fulltextservice);
|
$view->setParam('fulltextservice', $fulltextservice);
|
||||||
|
$view->setParam('conversionmgr', $conversionmgr);
|
||||||
$view->setParam('folder', $folder);
|
$view->setParam('folder', $folder);
|
||||||
$view->setParam('orderby', $orderby);
|
$view->setParam('orderby', $orderby);
|
||||||
$view->setParam('enableFolderTree', $settings->_enableFolderTree);
|
$view->setParam('enableFolderTree', $settings->_enableFolderTree);
|
||||||
|
|
|
@ -60,6 +60,7 @@ class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Theme_Style {
|
||||||
$converttopdf = $this->params['convertToPdf'];
|
$converttopdf = $this->params['convertToPdf'];
|
||||||
$pdfconverters = $this->params['pdfConverters'];
|
$pdfconverters = $this->params['pdfConverters'];
|
||||||
$cachedir = $this->params['cachedir'];
|
$cachedir = $this->params['cachedir'];
|
||||||
|
$conversionmgr = $this->params['conversionmgr'];
|
||||||
$version = $this->params['version'];
|
$version = $this->params['version'];
|
||||||
if(!$showfullpreview)
|
if(!$showfullpreview)
|
||||||
return;
|
return;
|
||||||
|
@ -125,7 +126,10 @@ class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Theme_Style {
|
||||||
|
|
||||||
if($converttopdf) {
|
if($converttopdf) {
|
||||||
$pdfpreviewer = new SeedDMS_Preview_PdfPreviewer($cachedir, $timeout, $xsendfile);
|
$pdfpreviewer = new SeedDMS_Preview_PdfPreviewer($cachedir, $timeout, $xsendfile);
|
||||||
$pdfpreviewer->setConverters($pdfconverters);
|
if($conversionmgr)
|
||||||
|
$pdfpreviewer->setConversionMgr($conversionmgr);
|
||||||
|
else
|
||||||
|
$pdfpreviewer->setConverters($pdfconverters);
|
||||||
if($pdfpreviewer->hasConverter($version->getMimeType())) {
|
if($pdfpreviewer->hasConverter($version->getMimeType())) {
|
||||||
$this->contentHeading(getMLText("preview_pdf"));
|
$this->contentHeading(getMLText("preview_pdf"));
|
||||||
?>
|
?>
|
||||||
|
@ -146,6 +150,7 @@ class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Theme_Style {
|
||||||
$viewonlinefiletypes = $this->params['viewonlinefiletypes'];
|
$viewonlinefiletypes = $this->params['viewonlinefiletypes'];
|
||||||
$enableversionmodification = $this->params['enableversionmodification'];
|
$enableversionmodification = $this->params['enableversionmodification'];
|
||||||
$cachedir = $this->params['cachedir'];
|
$cachedir = $this->params['cachedir'];
|
||||||
|
$conversionmgr = $this->params['conversionmgr'];
|
||||||
$previewwidthdetail = $this->params['previewWidthDetail'];
|
$previewwidthdetail = $this->params['previewWidthDetail'];
|
||||||
$previewconverters = $this->params['previewConverters'];
|
$previewconverters = $this->params['previewConverters'];
|
||||||
$timeout = $this->params['timeout'];
|
$timeout = $this->params['timeout'];
|
||||||
|
@ -263,7 +268,10 @@ class SeedDMS_View_DocumentVersionDetail extends SeedDMS_Theme_Style {
|
||||||
|
|
||||||
print "</ul>";
|
print "</ul>";
|
||||||
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidthdetail, $timeout, $xsendfile);
|
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidthdetail, $timeout, $xsendfile);
|
||||||
$previewer->setConverters($previewconverters);
|
if($conversionmgr)
|
||||||
|
$previewer->setConversionMgr($conversionmgr);
|
||||||
|
else
|
||||||
|
$previewer->setConverters($previewconverters);
|
||||||
$previewer->createPreview($version);
|
$previewer->createPreview($version);
|
||||||
if ($file_exists) {
|
if ($file_exists) {
|
||||||
if ($viewonlinefiletypes && (in_array(strtolower($version->getFileType()), $viewonlinefiletypes) || in_array(strtolower($version->getMimeType()), $viewonlinefiletypes))) {
|
if ($viewonlinefiletypes && (in_array(strtolower($version->getFileType()), $viewonlinefiletypes) || in_array(strtolower($version->getMimeType()), $viewonlinefiletypes))) {
|
||||||
|
|
|
@ -59,7 +59,7 @@ class SeedDMS_View_Settings extends SeedDMS_Theme_Style {
|
||||||
$class = 'input-medium';
|
$class = 'input-medium';
|
||||||
else
|
else
|
||||||
$class = 'input-small';
|
$class = 'input-small';
|
||||||
$html .= '<input '.($type=='password' ? 'type="password"' : 'type="text"').' class="form-control '.$class.'" name="'.$name.'" value="'.$value.'" placeholder="'.$placeholder.'"/>';
|
$html .= '<input '.($type=='password' ? 'type="password"' : ($type=='number' ? 'type="number"' : 'type="text"')).' class="form-control '.$class.'" name="'.$name.'" value="'.$value.'" placeholder="'.$placeholder.'"/>';
|
||||||
}
|
}
|
||||||
return $html;
|
return $html;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
|
@ -120,10 +120,19 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Theme_Style {
|
||||||
$user = $this->params['user'];
|
$user = $this->params['user'];
|
||||||
$previewwidth = $this->params['previewWidthList'];
|
$previewwidth = $this->params['previewWidthList'];
|
||||||
$cachedir = $this->params['cachedir'];
|
$cachedir = $this->params['cachedir'];
|
||||||
|
$conversionmgr = $this->params['conversionmgr'];
|
||||||
|
$previewconverters = $this->params['previewConverters'];
|
||||||
|
$timeout = $this->params['timeout'];
|
||||||
|
$xsendfile = $this->params['xsendfile'];
|
||||||
$document = $this->params['document'];
|
$document = $this->params['document'];
|
||||||
|
|
||||||
if($document) {
|
if($document) {
|
||||||
if ($document->getAccessMode($user) >= M_READ) {
|
if ($document->getAccessMode($user) >= M_READ) {
|
||||||
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth);
|
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile);
|
||||||
|
if($conversionmgr)
|
||||||
|
$previewer->setConversionMgr($conversionmgr);
|
||||||
|
else
|
||||||
|
$previewer->setConverters($previewconverters);
|
||||||
$txt = $this->callHook('documentListItem', $document, $previewer, false, 'viewitem');
|
$txt = $this->callHook('documentListItem', $document, $previewer, false, 'viewitem');
|
||||||
if(is_string($txt))
|
if(is_string($txt))
|
||||||
$content = $txt;
|
$content = $txt;
|
||||||
|
@ -239,6 +248,7 @@ $(document).ready( function() {
|
||||||
$accessobject = $this->params['accessobject'];
|
$accessobject = $this->params['accessobject'];
|
||||||
$viewonlinefiletypes = $this->params['viewonlinefiletypes'];
|
$viewonlinefiletypes = $this->params['viewonlinefiletypes'];
|
||||||
$cachedir = $this->params['cachedir'];
|
$cachedir = $this->params['cachedir'];
|
||||||
|
$conversionmgr = $this->params['conversionmgr'];
|
||||||
$previewwidthdetail = $this->params['previewWidthDetail'];
|
$previewwidthdetail = $this->params['previewWidthDetail'];
|
||||||
$previewconverters = $this->params['previewConverters'];
|
$previewconverters = $this->params['previewConverters'];
|
||||||
$timeout = $this->params['timeout'];
|
$timeout = $this->params['timeout'];
|
||||||
|
@ -246,7 +256,10 @@ $(document).ready( function() {
|
||||||
$documentid = $document->getId();
|
$documentid = $document->getId();
|
||||||
|
|
||||||
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidthdetail, $timeout, $xsendfile);
|
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidthdetail, $timeout, $xsendfile);
|
||||||
$previewer->setConverters($previewconverters);
|
if($conversionmgr)
|
||||||
|
$previewer->setConversionMgr($conversionmgr);
|
||||||
|
else
|
||||||
|
$previewer->setConverters($previewconverters);
|
||||||
$latestContent = $this->callHook('documentLatestContent', $document);
|
$latestContent = $this->callHook('documentLatestContent', $document);
|
||||||
if($latestContent === null)
|
if($latestContent === null)
|
||||||
$latestContent = $document->getLatestContent();
|
$latestContent = $document->getLatestContent();
|
||||||
|
@ -531,6 +544,7 @@ $(document).ready( function() {
|
||||||
$converttopdf = $this->params['convertToPdf'];
|
$converttopdf = $this->params['convertToPdf'];
|
||||||
$pdfconverters = $this->params['pdfConverters'];
|
$pdfconverters = $this->params['pdfConverters'];
|
||||||
$cachedir = $this->params['cachedir'];
|
$cachedir = $this->params['cachedir'];
|
||||||
|
$conversionmgr = $this->params['conversionmgr'];
|
||||||
if(!$showfullpreview)
|
if(!$showfullpreview)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -600,7 +614,10 @@ $(document).ready( function() {
|
||||||
|
|
||||||
if($converttopdf) {
|
if($converttopdf) {
|
||||||
$pdfpreviewer = new SeedDMS_Preview_PdfPreviewer($cachedir, $timeout, $xsendfile);
|
$pdfpreviewer = new SeedDMS_Preview_PdfPreviewer($cachedir, $timeout, $xsendfile);
|
||||||
$pdfpreviewer->setConverters($pdfconverters);
|
if($conversionmgr)
|
||||||
|
$pdfpreviewer->setConversionMgr($conversionmgr);
|
||||||
|
else
|
||||||
|
$pdfpreviewer->setConverters($pdfconverters);
|
||||||
if($pdfpreviewer->hasConverter($latestContent->getMimeType())) {
|
if($pdfpreviewer->hasConverter($latestContent->getMimeType())) {
|
||||||
$this->contentHeading(getMLText("preview_pdf"));
|
$this->contentHeading(getMLText("preview_pdf"));
|
||||||
?>
|
?>
|
||||||
|
@ -738,7 +755,7 @@ $(document).ready( function() {
|
||||||
$items[] = array('link'=>$this->params['settings']->_httpRoot."op/op.ViewOnline.php?documentid=".$latestContent->getDocument()->getId()."&version=". $latestContent->getVersion(), 'icon'=>'eye', 'label'=>'view_online', 'target'=>'_blank');
|
$items[] = array('link'=>$this->params['settings']->_httpRoot."op/op.ViewOnline.php?documentid=".$latestContent->getDocument()->getId()."&version=". $latestContent->getVersion(), 'icon'=>'eye', 'label'=>'view_online', 'target'=>'_blank');
|
||||||
if($newitems = $this->callHook('extraVersionViews', $latestContent))
|
if($newitems = $this->callHook('extraVersionViews', $latestContent))
|
||||||
$items = array_merge($items, $newitems);
|
$items = array_merge($items, $newitems);
|
||||||
if($items) {
|
if($items) {
|
||||||
$this->showActions($items);
|
$this->showActions($items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -827,6 +844,7 @@ $(document).ready( function() {
|
||||||
$enablerevisionworkflow = $this->params['enablerevisionworkflow'];
|
$enablerevisionworkflow = $this->params['enablerevisionworkflow'];
|
||||||
$workflowmode = $this->params['workflowmode'];
|
$workflowmode = $this->params['workflowmode'];
|
||||||
$cachedir = $this->params['cachedir'];
|
$cachedir = $this->params['cachedir'];
|
||||||
|
$conversionmgr = $this->params['conversionmgr'];
|
||||||
$previewwidthlist = $this->params['previewWidthList'];
|
$previewwidthlist = $this->params['previewWidthList'];
|
||||||
$previewwidthdetail = $this->params['previewWidthDetail'];
|
$previewwidthdetail = $this->params['previewWidthDetail'];
|
||||||
$previewconverters = $this->params['previewConverters'];
|
$previewconverters = $this->params['previewConverters'];
|
||||||
|
@ -982,7 +1000,10 @@ $(document).ready( function() {
|
||||||
|
|
||||||
$this->contentContainerStart();
|
$this->contentContainerStart();
|
||||||
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidthdetail, $timeout, $xsendfile);
|
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidthdetail, $timeout, $xsendfile);
|
||||||
$previewer->setConverters($previewconverters);
|
if($conversionmgr)
|
||||||
|
$previewer->setConversionMgr($conversionmgr);
|
||||||
|
else
|
||||||
|
$previewer->setConverters($previewconverters);
|
||||||
$this->showVersionDetails($latestContent, $previewer, true);
|
$this->showVersionDetails($latestContent, $previewer, true);
|
||||||
$this->contentContainerEnd();
|
$this->contentContainerEnd();
|
||||||
|
|
||||||
|
|
|
@ -353,6 +353,7 @@ $('body').on('click', '.order-btn', function(ev) {
|
||||||
$orderby = $this->params['orderby'];
|
$orderby = $this->params['orderby'];
|
||||||
$orderdir = (isset($orderby[1]) ? ($orderby[1] == 'd' ? 'desc' : 'asc') : 'asc');
|
$orderdir = (isset($orderby[1]) ? ($orderby[1] == 'd' ? 'desc' : 'asc') : 'asc');
|
||||||
$cachedir = $this->params['cachedir'];
|
$cachedir = $this->params['cachedir'];
|
||||||
|
$conversionmgr = $this->params['conversionmgr'];
|
||||||
$maxItemsPerPage = $this->params['maxItemsPerPage'];
|
$maxItemsPerPage = $this->params['maxItemsPerPage'];
|
||||||
$incItemsPerPage = $this->params['incItemsPerPage'];
|
$incItemsPerPage = $this->params['incItemsPerPage'];
|
||||||
$previewwidth = $this->params['previewWidthList'];
|
$previewwidth = $this->params['previewWidthList'];
|
||||||
|
@ -362,7 +363,10 @@ $('body').on('click', '.order-btn', function(ev) {
|
||||||
$onepage = $this->params['onepage'];
|
$onepage = $this->params['onepage'];
|
||||||
|
|
||||||
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile);
|
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile);
|
||||||
$previewer->setConverters($previewconverters);
|
if($conversionmgr)
|
||||||
|
$previewer->setConversionMgr($conversionmgr);
|
||||||
|
else
|
||||||
|
$previewer->setConverters($previewconverters);
|
||||||
|
|
||||||
$txt = $this->callHook('listHeader', $folder);
|
$txt = $this->callHook('listHeader', $folder);
|
||||||
if(is_string($txt))
|
if(is_string($txt))
|
||||||
|
@ -491,6 +495,7 @@ $('body').on('click', '.order-btn', function(ev) {
|
||||||
$orderby = $this->params['orderby'];
|
$orderby = $this->params['orderby'];
|
||||||
$orderdir = (isset($orderby[1]) ? ($orderby[1] == 'd' ? 'desc' : 'asc') : 'asc');
|
$orderdir = (isset($orderby[1]) ? ($orderby[1] == 'd' ? 'desc' : 'asc') : 'asc');
|
||||||
$cachedir = $this->params['cachedir'];
|
$cachedir = $this->params['cachedir'];
|
||||||
|
$conversionmgr = $this->params['conversionmgr'];
|
||||||
$previewwidth = $this->params['previewWidthList'];
|
$previewwidth = $this->params['previewWidthList'];
|
||||||
$previewconverters = $this->params['previewConverters'];
|
$previewconverters = $this->params['previewConverters'];
|
||||||
$timeout = $this->params['timeout'];
|
$timeout = $this->params['timeout'];
|
||||||
|
@ -501,7 +506,10 @@ $('body').on('click', '.order-btn', function(ev) {
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile);
|
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile);
|
||||||
$previewer->setConverters($previewconverters);
|
if($conversionmgr)
|
||||||
|
$previewer->setConversionMgr($conversionmgr);
|
||||||
|
else
|
||||||
|
$previewer->setConverters($previewconverters);
|
||||||
|
|
||||||
$subFolders = $this->callHook('folderGetSubFolders', $folder, $orderby[0]);
|
$subFolders = $this->callHook('folderGetSubFolders', $folder, $orderby[0]);
|
||||||
if($subFolders === null)
|
if($subFolders === null)
|
||||||
|
@ -568,6 +576,7 @@ $('body').on('click', '.order-btn', function(ev) {
|
||||||
$expandFolderTree = $this->params['expandFolderTree'];
|
$expandFolderTree = $this->params['expandFolderTree'];
|
||||||
$showtree = $this->params['showtree'];
|
$showtree = $this->params['showtree'];
|
||||||
$cachedir = $this->params['cachedir'];
|
$cachedir = $this->params['cachedir'];
|
||||||
|
$conversionmgr = $this->params['conversionmgr'];
|
||||||
$enableRecursiveCount = $this->params['enableRecursiveCount'];
|
$enableRecursiveCount = $this->params['enableRecursiveCount'];
|
||||||
$maxRecursiveCount = $this->params['maxRecursiveCount'];
|
$maxRecursiveCount = $this->params['maxRecursiveCount'];
|
||||||
$maxItemsPerPage = $this->params['maxItemsPerPage'];
|
$maxItemsPerPage = $this->params['maxItemsPerPage'];
|
||||||
|
@ -579,7 +588,10 @@ $('body').on('click', '.order-btn', function(ev) {
|
||||||
|
|
||||||
$folderid = $folder->getId();
|
$folderid = $folder->getId();
|
||||||
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile);
|
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile);
|
||||||
$previewer->setConverters($previewconverters);
|
if($conversionmgr)
|
||||||
|
$previewer->setConversionMgr($conversionmgr);
|
||||||
|
else
|
||||||
|
$previewer->setConverters($previewconverters);
|
||||||
|
|
||||||
// echo $this->callHook('startPage');
|
// echo $this->callHook('startPage');
|
||||||
$this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))));
|
$this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user