add discarding of checked out document

This commit is contained in:
Uwe Steinmann 2020-11-26 09:14:03 +01:00
parent c9a2aaca9c
commit 67a8d10797
8 changed files with 87 additions and 6 deletions

View File

@ -5,7 +5,8 @@
- merge changes up to 5.1.21 - merge changes up to 5.1.21
- document links can be added by regular users again - document links can be added by regular users again
- add list of checked out documents to tasks - add list of checked out documents to tasks
- issue a warning when removing a document with is checked out - issue a warning when removing a document which is checked out
- checked out can be discarded if it was changed
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Changes in version 6.0.13 Changes in version 6.0.13

View File

@ -1178,10 +1178,17 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
if($infos) { if($infos) {
$info = $infos[0]; $info = $infos[0];
$db->startTransaction();
$queryStr = "DELETE FROM `tblDocumentCheckOuts` WHERE `document` = ".$this->_id; $queryStr = "DELETE FROM `tblDocumentCheckOuts` WHERE `document` = ".$this->_id;
if (!$db->getResult($queryStr)) if (!$db->getResult($queryStr)) {
$db->rollbackTransaction();
return false; return false;
SeedDMS_Core_File::removeFile($info['filename']); }
if(!SeedDMS_Core_File::removeFile($info['filename'])) {
$db->rollbackTransaction();
return false;
}
$db->commitTransaction();
} }
return true; return true;

View File

@ -188,6 +188,8 @@ class Settings { /* {{{ */
var $_enableDuplicateDocNames = true; var $_enableDuplicateDocNames = true;
// enable/disable duplicate names of a subfolder in a folder // enable/disable duplicate names of a subfolder in a folder
var $_enableDuplicateSubFolderNames = true; var $_enableDuplicateSubFolderNames = true;
// allow/disallow to cancel a checkout
var $_enableCancelCheckout = true;
// override mimetype set by browser when uploading a file // override mimetype set by browser when uploading a file
var $_overrideMimeType = false; var $_overrideMimeType = false;
// advanced access control lists // advanced access control lists
@ -749,6 +751,7 @@ class Settings { /* {{{ */
$this->_enableVersionModification = Settings::boolval($tab["enableVersionModification"]); $this->_enableVersionModification = Settings::boolval($tab["enableVersionModification"]);
$this->_enableDuplicateDocNames = Settings::boolval($tab["enableDuplicateDocNames"]); $this->_enableDuplicateDocNames = Settings::boolval($tab["enableDuplicateDocNames"]);
$this->_enableDuplicateSubFolderNames = Settings::boolval($tab["enableDuplicateSubFolderNames"]); $this->_enableDuplicateSubFolderNames = Settings::boolval($tab["enableDuplicateSubFolderNames"]);
$this->_enableCancelCheckout = Settings::boolval($tab["enableCancelCheckout"]);
$this->_overrideMimeType = Settings::boolval($tab["overrideMimeType"]); $this->_overrideMimeType = Settings::boolval($tab["overrideMimeType"]);
$this->_advancedAcl = Settings::boolval($tab["advancedAcl"]); $this->_advancedAcl = Settings::boolval($tab["advancedAcl"]);
$this->_removeFromDropFolder = Settings::boolval($tab["removeFromDropFolder"]); $this->_removeFromDropFolder = Settings::boolval($tab["removeFromDropFolder"]);
@ -1099,6 +1102,7 @@ class Settings { /* {{{ */
$this->setXMLAttributValue($node, "enableVersionModification", $this->_enableVersionModification); $this->setXMLAttributValue($node, "enableVersionModification", $this->_enableVersionModification);
$this->setXMLAttributValue($node, "enableDuplicateDocNames", $this->_enableDuplicateDocNames); $this->setXMLAttributValue($node, "enableDuplicateDocNames", $this->_enableDuplicateDocNames);
$this->setXMLAttributValue($node, "enableDuplicateSubFolderNames", $this->_enableDuplicateSubFolderNames); $this->setXMLAttributValue($node, "enableDuplicateSubFolderNames", $this->_enableDuplicateSubFolderNames);
$this->setXMLAttributValue($node, "enableCancelCheckout", $this->_enableCancelCheckout);
$this->setXMLAttributValue($node, "overrideMimeType", $this->_overrideMimeType); $this->setXMLAttributValue($node, "overrideMimeType", $this->_overrideMimeType);
$this->setXMLAttributValue($node, "advancedAcl", $this->_advancedAcl); $this->setXMLAttributValue($node, "advancedAcl", $this->_advancedAcl);
$this->setXMLAttributValue($node, "removeFromDropFolder", $this->_removeFromDropFolder); $this->setXMLAttributValue($node, "removeFromDropFolder", $this->_removeFromDropFolder);

50
op/op.CancelCheckOut.php Normal file
View File

@ -0,0 +1,50 @@
<?php
// SeedDMS. Document Management System
// Copyright (C) 2015 Uwe Steinmann
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
include("../inc/inc.Settings.php");
include("../inc/inc.LogInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.Init.php");
include("../inc/inc.Extension.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
/* Check if the form data comes from a trusted request */
if(!checkFormKey('cancelcheckout')) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_request_token"))),getMLText("invalid_request_token"));
}
if (!isset($_POST["documentid"]) || !is_numeric($_POST["documentid"]) || intval($_POST["documentid"])<1) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
}
$documentid = $_POST["documentid"];
$document = $dms->getDocument($documentid);
if(empty($settings->_enableCancelCheckout)) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("operation_disallowed"));
}
$document->cancelCheckOut($comment);
if (is_bool($result) && !$result) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
}
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_cancel_checkout')));
add_log_line("?documentid=".$documentid);
header("Location:../out/out.ViewDocument.php?documentid=".$documentid);

View File

@ -25,6 +25,11 @@ include("../inc/inc.DBInit.php");
include("../inc/inc.ClassUI.php"); include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php"); include("../inc/inc.Authentication.php");
/* Check if the form data comes from a trusted request */
if(!checkFormKey('checkindocument')) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_request_token"))),getMLText("invalid_request_token"));
}
if (!isset($_POST["documentid"]) || !is_numeric($_POST["documentid"]) || intval($_POST["documentid"])<1) { if (!isset($_POST["documentid"]) || !is_numeric($_POST["documentid"]) || intval($_POST["documentid"])<1) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id")); UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
} }
@ -427,5 +432,3 @@ else
add_log_line("?documentid=".$documentid); add_log_line("?documentid=".$documentid);
header("Location:../out/out.ViewDocument.php?documentid=".$documentid); header("Location:../out/out.ViewDocument.php?documentid=".$documentid);
?>

View File

@ -216,6 +216,7 @@ if ($action == "saveSettings")
$settings->_enableVersionModification = getBoolValue("enableVersionModification"); $settings->_enableVersionModification = getBoolValue("enableVersionModification");
$settings->_enableDuplicateDocNames = getBoolValue("enableDuplicateDocNames"); $settings->_enableDuplicateDocNames = getBoolValue("enableDuplicateDocNames");
$settings->_enableDuplicateSubFolderNames = getBoolValue("enableDuplicateSubFolderNames"); $settings->_enableDuplicateSubFolderNames = getBoolValue("enableDuplicateSubFolderNames");
$settings->_enableCancelCheckout = getBoolValue("enableCancelCheckout");
$settings->_overrideMimeType = getBoolValue("overrideMimeType"); $settings->_overrideMimeType = getBoolValue("overrideMimeType");
$settings->_advancedAcl = getBoolValue("advancedAcl"); $settings->_advancedAcl = getBoolValue("advancedAcl");
$settings->_removeFromDropFolder = getBoolValue("removeFromDropFolder"); $settings->_removeFromDropFolder = getBoolValue("removeFromDropFolder");

View File

@ -77,6 +77,7 @@ $(document).ready(function() {
function show() { /* {{{ */ function show() { /* {{{ */
$dms = $this->params['dms']; $dms = $this->params['dms'];
$user = $this->params['user']; $user = $this->params['user'];
$settings = $this->params['settings'];
$folder = $this->params['folder']; $folder = $this->params['folder'];
$document = $this->params['document']; $document = $this->params['document'];
$strictformcheck = $this->params['strictformcheck']; $strictformcheck = $this->params['strictformcheck'];
@ -688,9 +689,22 @@ $(document).ready(function() {
$this->formSubmit(getMLText('checkin_document')); $this->formSubmit(getMLText('checkin_document'));
?> ?>
</form> </form>
<?php <?php
$this->contentContainerEnd(); $this->contentContainerEnd();
if(!empty($settings->_enableCancelCheckout)) {
$this->contentContainerStart();
$this->warningMsg(getMLText('cancel_checkout_warning'));
?>
<form class="form-horizontal" action="../op/op.CancelCheckOut.php" method="post">
<input type="hidden" name="documentid" value="<?php print $document->getID(); ?>">
<?php
echo createHiddenFieldWithKey('cancelcheckout');
$this->formSubmit(getMLText('cancel_checkout'));
?>
</form>
<?php
$this->contentContainerEnd();
}
} else { } else {
?> ?>
<form action="../op/op.CheckInDocument.php" method="post"> <form action="../op/op.CheckInDocument.php" method="post">

View File

@ -485,6 +485,7 @@ if(($kkk = $this->callHook('getFullSearchEngine')) && is_array($kkk))
<?php $this->showConfigCheckbox('settings_enableVersionModification', 'enableVersionModification'); ?> <?php $this->showConfigCheckbox('settings_enableVersionModification', 'enableVersionModification'); ?>
<?php $this->showConfigCheckbox('settings_enableDuplicateDocNames', 'enableDuplicateDocNames'); ?> <?php $this->showConfigCheckbox('settings_enableDuplicateDocNames', 'enableDuplicateDocNames'); ?>
<?php $this->showConfigCheckbox('settings_enableDuplicateSubFolderNames', 'enableDuplicateSubFolderNames'); ?> <?php $this->showConfigCheckbox('settings_enableDuplicateSubFolderNames', 'enableDuplicateSubFolderNames'); ?>
<?php $this->showConfigCheckbox('settings_enableCancelCheckout', 'enableCancelCheckout'); ?>
<?php $this->showConfigCheckbox('settings_overrideMimeType', 'overrideMimeType'); ?> <?php $this->showConfigCheckbox('settings_overrideMimeType', 'overrideMimeType'); ?>
<?php $this->showConfigCheckbox('settings_advancedAcl', 'advancedAcl'); ?> <?php $this->showConfigCheckbox('settings_advancedAcl', 'advancedAcl'); ?>
<?php $this->showConfigCheckbox('settings_removeFromDropFolder', 'removeFromDropFolder'); ?> <?php $this->showConfigCheckbox('settings_removeFromDropFolder', 'removeFromDropFolder'); ?>