From eebc1de5aaa872d7e716a063d74a5d4c7e162fa1 Mon Sep 17 00:00:00 2001
From: Uwe Steinmann
Date: Fri, 21 Aug 2020 08:00:50 +0200
Subject: [PATCH 1/6] add note for 5.1.19
---
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
diff --git a/CHANGELOG b/CHANGELOG
index 7306fe042..f0753247a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@
- sort versions of extension in extension manager propperly
- fix output of help text for config vars in extension
- configuring a user id in the settings uses a list of existing users
+- form elements can have a help text
--------------------------------------------------------------------------------
Changes in version 5.1.18
From 991268a18b50c8bdca89d136496cd1a88b2e09c2 Mon Sep 17 00:00:00 2001
From: Uwe Steinmann
Date: Fri, 21 Aug 2020 10:03:22 +0200
Subject: [PATCH 2/6] put ClearCache into controller, add hooks when clearing
the cache
---
controllers/class.ClearCache.php | 51 ++++++++++++++++++++++++++++
op/op.ClearCache.php | 19 ++++-------
views/bootstrap/class.ClearCache.php | 7 ++++
3 files changed, 64 insertions(+), 13 deletions(-)
create mode 100644 controllers/class.ClearCache.php
diff --git a/controllers/class.ClearCache.php b/controllers/class.ClearCache.php
new file mode 100644
index 000000000..770abcdea
--- /dev/null
+++ b/controllers/class.ClearCache.php
@@ -0,0 +1,51 @@
+
+ * @copyright Copyright (C) 2010-2013 Uwe Steinmann
+ * @version Release: @package_version@
+ */
+
+/**
+ * Class which does the busines logic for clearing the cache
+ *
+ * @category DMS
+ * @package SeedDMS
+ * @author Uwe Steinmann
+ * @copyright Copyright (C) 2010-2013 Uwe Steinmann
+ * @version Release: @package_version@
+ */
+class SeedDMS_Controller_ClearCache extends SeedDMS_Controller_Common {
+
+ public function run() {
+ $dms = $this->params['dms'];
+ $user = $this->params['user'];
+ $settings = $this->params['settings'];
+ $post = $this->params['post'];
+
+ $ret = '';
+ if(!empty($post['preview'])) {
+ $cmd = 'rm -rf '.$settings->_cacheDir.'/[1-9]*';
+ system($cmd, $ret);
+ }
+
+ if(!empty($post['js'])) {
+ $cmd = 'rm -rf '.$settings->_cacheDir.'/js/*';
+ system($cmd, $ret);
+ }
+
+ if(false === $this->callHook('clear', $post)) {
+ if(empty($this->errormsg))
+ $this->errormsg = 'hook_clear_failed';
+ return false;
+ }
+
+ return true;
+ }
+}
+
diff --git a/op/op.ClearCache.php b/op/op.ClearCache.php
index 921bb713f..77dfcb2ed 100644
--- a/op/op.ClearCache.php
+++ b/op/op.ClearCache.php
@@ -24,8 +24,12 @@ include("../inc/inc.Init.php");
include("../inc/inc.Extension.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.ClassUI.php");
+include("../inc/inc.ClassController.php");
include("../inc/inc.Authentication.php");
+$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
+$controller = Controller::factory($tmp[1], array('dms'=>$dms, 'user'=>$user));
+
/* Check if the form data comes from a trusted request */
if(!checkFormKey('clearcache')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
@@ -38,19 +42,8 @@ if(!is_dir($settings->_cacheDir)) {
UI::exitError(getMLText("admin_tools"),getMLText("error_cleared_cache"));
}
-if(!empty($_POST['preview'])) {
- $cmd = 'rm -rf '.$settings->_cacheDir.'/[1-9]*';
- $ret = null;
- system($cmd, $ret);
-}
-
-if(!empty($_POST['js'])) {
- $cmd = 'rm -rf '.$settings->_cacheDir.'/js/*';
- $ret = null;
- system($cmd, $ret);
-}
-
-if($ret)
+$controller->setParam('post', $_POST);
+if(!$controller->run())
$session->setSplashMsg(array('type'=>'error', 'msg'=>getMLText('error_cleared_cache')));
else
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_cleared_cache')));
diff --git a/views/bootstrap/class.ClearCache.php b/views/bootstrap/class.ClearCache.php
index 1d562d507..c925c04a9 100644
--- a/views/bootstrap/class.ClearCache.php
+++ b/views/bootstrap/class.ClearCache.php
@@ -54,6 +54,13 @@ class SeedDMS_View_ClearCache extends SeedDMS_Bootstrap_Style {
+callHook('additionalCache', $addcache)) {
+ foreach($addcache as $c)
+ echo "
".$c[1]."
";
+ }
+?>
Date: Fri, 21 Aug 2020 12:34:35 +0200
Subject: [PATCH 3/6] invalidate list of versions after removing a version
---
SeedDMS_Core/Core/inc.ClassDocument.php | 11 +++++++++++
SeedDMS_Core/package.xml | 2 ++
2 files changed, 13 insertions(+)
diff --git a/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php
index 054be2674..00e7c24fa 100644
--- a/SeedDMS_Core/Core/inc.ClassDocument.php
+++ b/SeedDMS_Core/Core/inc.ClassDocument.php
@@ -1745,6 +1745,10 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
foreach ($resArr as $row) {
/** @var SeedDMS_Core_DocumentContent $content */
$content = new $classname($row["id"], $this, $row["version"], $row["comment"], $row["date"], $row["createdBy"], $row["dir"], $row["orgFileName"], $row["fileType"], $row["mimeType"], $row['fileSize'], $row['checksum']);
+ /* TODO: Better use content id as key in $this->_content. This
+ * would allow to remove a single content object in removeContent().
+ * Currently removeContent() must clear $this->_content completely
+ */
if($user) {
if($content->getAccessMode($user) >= M_READ)
array_push($this->_content, $content);
@@ -2018,6 +2022,13 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
return false;
}
+ /* Invalidate the content list and the latest content of this document,
+ * otherwise getContent() and getLatestContent()
+ * will still return the content just deleted.
+ */
+ $this->_latestContent = null;
+ $this->_content = null;
+
/* Check if 'onPostRemoveDocument' callback is set */
if(isset($this->_dms->callbacks['onPostRemoveContent'])) {
foreach($this->_dms->callbacks['onPostRemoveContent'] as $callback) {
diff --git a/SeedDMS_Core/package.xml b/SeedDMS_Core/package.xml
index f5d232221..ced81b2e8 100644
--- a/SeedDMS_Core/package.xml
+++ b/SeedDMS_Core/package.xml
@@ -25,6 +25,8 @@
GPL License
- add method SeedDMS_Core_Document::setParent() as an alias for setFolder()
+- clear the save content list and latest content in SeedDMS_Core_Document after
+ a version has been deleted.
From ad8a501506316a4d41d2fee8256f05ac45a36de5 Mon Sep 17 00:00:00 2001
From: Uwe Steinmann
Date: Fri, 21 Aug 2020 12:35:06 +0200
Subject: [PATCH 4/6] go to right url after deleting a document version
---
CHANGELOG | 4 ++++
op/op.RemoveVersion.php | 13 ++++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index f0753247a..b87a61800 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,10 @@
- fix output of help text for config vars in extension
- configuring a user id in the settings uses a list of existing users
- form elements can have a help text
+- open the right page or tab after a document version has been removed
+ (go to folder page if the whole document was removed, go to previous tab
+ if an old version was removed and there are other older version, otherwise
+ to to current tab)
--------------------------------------------------------------------------------
Changes in version 5.1.18
diff --git a/op/op.RemoveVersion.php b/op/op.RemoveVersion.php
index 41ce8d429..d3f2eac94 100644
--- a/op/op.RemoveVersion.php
+++ b/op/op.RemoveVersion.php
@@ -63,6 +63,8 @@ if (!is_object($version)) {
require_once("SeedDMS/Preview.php");
$previewer = new SeedDMS_Preview_Previewer($settings->_cacheDir);
+$folder = $document->getFolder();
+/* Check if there is just one version. In that case remove the document */
if (count($document->getContent())==1) {
$previewer->deleteDocumentPreviews($document);
$nl = $document->getNotifyList();
@@ -70,6 +72,7 @@ if (count($document->getContent())==1) {
if (!$document->remove()) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
} else {
+ $nexturl = "../out/out.ViewFolder.php?folderid=".$folder->getId();
/* Remove the document from the fulltext index */
if($settings->_enableFullSearch) {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
@@ -127,9 +130,17 @@ else {
$previewer->deletePreview($version, $settings->_previewWidthDetail);
$previewer->deletePreview($version, $settings->_previewWidthList);
+ /* Check if the version to be delete is the latest version. This is
+ * later used to set the redirect url.
+ */
+ $islatest = $version->getVersion() == $document->getLatestContent()->getVersion();
if (!$document->removeContent($version)) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
} else {
+ if($islatest || count($document->getContent()) == 1)
+ $nexturl = "../out/out.ViewDocument.php?documentid=".$documentid;
+ else
+ $nexturl = "../out/out.ViewDocument.php?documentid=".$documentid."¤ttab=previous";
/* Remove the document from the fulltext index and reindex latest version */
if($settings->_enableFullSearch) {
$index = $indexconf['Indexer']::open($settings->_luceneDir);
@@ -183,6 +194,6 @@ else {
add_log_line("?documentid=".$documentid."&version".$version_num);
-header("Location:../out/out.ViewDocument.php?documentid=".$documentid."¤ttab=previous");
+header("Location:".$nexturl);
?>
From b083ebb40e4da6118c19ee04694ac0696503df82 Mon Sep 17 00:00:00 2001
From: Uwe Steinmann
Date: Fri, 21 Aug 2020 13:19:22 +0200
Subject: [PATCH 5/6] add new method SeedDMS_Core_Document::isLatestContent()
---
SeedDMS_Core/Core/inc.ClassDocument.php | 11 +++++++++++
SeedDMS_Core/package.xml | 1 +
2 files changed, 12 insertions(+)
diff --git a/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php
index 00e7c24fa..8ad2040a2 100644
--- a/SeedDMS_Core/Core/inc.ClassDocument.php
+++ b/SeedDMS_Core/Core/inc.ClassDocument.php
@@ -1806,6 +1806,17 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
}
} /* }}} */
+ /**
+ * Check if a given version is the latest version of the document
+ *
+ * @param integer $version version number of content element
+ * @return SeedDMS_Core_DocumentContent|boolean object of class {@link SeedDMS_Core_DocumentContent}
+ * or false
+ */
+ function isLatestContent($version) { /* {{{ */
+ return $this->getLatestContent()->getVersion() == $version;
+ } /* }}} */
+
/**
* @return bool|null|SeedDMS_Core_DocumentContent
*/
diff --git a/SeedDMS_Core/package.xml b/SeedDMS_Core/package.xml
index ced81b2e8..724ee1371 100644
--- a/SeedDMS_Core/package.xml
+++ b/SeedDMS_Core/package.xml
@@ -27,6 +27,7 @@
- add method SeedDMS_Core_Document::setParent() as an alias for setFolder()
- clear the save content list and latest content in SeedDMS_Core_Document after
a version has been deleted.
+- new method SeedDMS_Core_Document::isLatestVersion()
From 2372cb8d09bae5e4a03dac6341e1e8eb55fbbf9f Mon Sep 17 00:00:00 2001
From: Uwe Steinmann
Date: Fri, 21 Aug 2020 13:20:07 +0200
Subject: [PATCH 6/6] no need to pass parameter to hook additionalCache
---
views/bootstrap/class.ClearCache.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/views/bootstrap/class.ClearCache.php b/views/bootstrap/class.ClearCache.php
index c925c04a9..91c8f4cd7 100644
--- a/views/bootstrap/class.ClearCache.php
+++ b/views/bootstrap/class.ClearCache.php
@@ -56,7 +56,7 @@ class SeedDMS_View_ClearCache extends SeedDMS_Bootstrap_Style {
callHook('additionalCache', $addcache)) {
+ if($addcache = $this->callHook('additionalCache')) {
foreach($addcache as $c)
echo "