diff --git a/CHANGELOG b/CHANGELOG index a1cbed863..4b714fa63 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -173,6 +173,11 @@ - 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 +- 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/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php index 1ddf0bdd1..24adb30f2 100644 --- a/SeedDMS_Core/Core/inc.ClassDocument.php +++ b/SeedDMS_Core/Core/inc.ClassDocument.php @@ -999,7 +999,6 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ } /* }}} */ /** -<<<<<<< HEAD * Check if document is checked out * * @return boolean true if checked out otherwise false @@ -1219,10 +1218,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */ } /* }}} */ /** - * @return int -======= * @return float ->>>>>>> seeddms-5.1.x */ function getSequence() { return $this->_sequence; } @@ -2081,6 +2077,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'], $row['revisiondate']); + /* 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); @@ -2138,6 +2138,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 */ @@ -2421,6 +2432,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 fe6c72087..a6e01739e 100644 --- a/SeedDMS_Core/package.xml +++ b/SeedDMS_Core/package.xml @@ -25,6 +25,9 @@ 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. +- new method SeedDMS_Core_Document::isLatestVersion() 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/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); ?> diff --git a/views/bootstrap/class.ClearCache.php b/views/bootstrap/class.ClearCache.php index 1d562d507..91c8f4cd7 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')) { + foreach($addcache as $c) + echo "

".$c[1]."

"; + } +?>