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

This commit is contained in:
Uwe Steinmann 2020-08-21 14:06:21 +02:00
commit 19502debea
7 changed files with 106 additions and 18 deletions

View File

@ -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

View File

@ -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) {

View File

@ -25,6 +25,9 @@
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
- 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()
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">

View File

@ -0,0 +1,51 @@
<?php
/**
* Implementation of ClearCache controller
*
* @category DMS
* @package SeedDMS
* @license GPL 2
* @version @version@
* @author Uwe Steinmann <uwe@steinmann.cx>
* @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 <uwe@steinmann.cx>
* @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;
}
}

View File

@ -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')));

View File

@ -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."&currenttab=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."&currenttab=previous");
header("Location:".$nexturl);
?>

View File

@ -54,6 +54,13 @@ class SeedDMS_View_ClearCache extends SeedDMS_Bootstrap_Style {
</p>
<p>
<input type="checkbox" name="js" value="1" checked> <?php printMLText('temp_jscode'); ?>
<?php
$addcache = array();
if($addcache = $this->callHook('additionalCache')) {
foreach($addcache as $c)
echo "<p><input type=\"checkbox\" name=\"".$c[0]."\" value=\"1\" checked> ".$c[1]."</p>";
}
?>
<p><button type="submit" class="btn"><i class="icon-remove"></i> <?php printMLText("clear_cache");?></button></p>
</form>
<?php