removing a document version will not remove attachments of the document anymore

This commit is contained in:
Uwe Steinmann 2020-09-17 09:26:08 +02:00
parent 3d5aec62ce
commit 999f4f76c9
3 changed files with 13 additions and 5 deletions

View File

@ -5,6 +5,7 @@
- major rework of scripts in utils, unify reading of settings, use PHP_EOL
- allow inline editing of document name
- import of users does not issue an error if a group column isn't set
- removing a document version will not remove attachments of the document anymore
--------------------------------------------------------------------------------
Changes in version 5.1.19

View File

@ -1994,8 +1994,8 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
return false;
}
// remove document files attached to version
$res = $this->getDocumentFiles($version->getVersion());
// remove only those document files attached to version
$res = $this->getDocumentFiles($version->getVersion(), false);
if (is_bool($res) && !$res) {
$db->rollbackTransaction();
return false;
@ -2217,15 +2217,20 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
/**
* Get list of files attached to document
*
* @param integer $version get only attachments for this version
*@param boolean $incnoversion include attachments without a version
* @return array list of files, false in case of an sql error
*/
function getDocumentFiles($version=0) { /* {{{ */
function getDocumentFiles($version=0, $incnoversion=true) { /* {{{ */
if (!isset($this->_documentFiles)) {
$db = $this->_dms->getDB();
$queryStr = "SELECT * FROM `tblDocumentFiles` WHERE `document` = " . $this->_id;
if($version) {
$queryStr .= " AND (`version`=0 OR `version`=".(int) $version.")";
if($incnoversion)
$queryStr .= " AND (`version`=0 OR `version`=".(int) $version.")";
else
$queryStr .= " AND (`version`=".(int) $version.")";
}
$queryStr .= " ORDER BY ";
if($version) {
@ -2347,7 +2352,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
}
}
// remove document file
// remove all document files
$res = $this->getDocumentFiles();
if (is_bool($res) && !$res) {
$db->rollbackTransaction();

View File

@ -25,6 +25,8 @@
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
- SeedDMS_Core_DMS::getDocumentList() returns false, if an unknown list passed
- SeedDMS_Core_Document::getDocumentFiles() has new parameter to select only those files attached to a specific version of the document
- removing a document version will not remove attachments of the document anymore
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">