removeFromProcesses() will not touch documents for which the new user does not have at least read access

This commit is contained in:
Uwe Steinmann 2022-05-05 11:03:28 +02:00
parent 5dab792dba
commit 87fe831973
2 changed files with 24 additions and 3 deletions

View File

@ -932,11 +932,11 @@ class SeedDMS_Core_User { /* {{{ */
* Remove user from all processes
*
* This method adds another log entry to the reviews, approvals, receptions, revisions,
* which indicates the user has been deleted from the process. By default it will
* which indicates that the user has been deleted from the process. By default it will
* do so for each review/approval/reception/revision regardless of its current state unless
* the user has been removed already (status=-2). So even
* reviews/approvals/receptions/revisions already processed by the user will be added the log
* entry. Only if the last log entry was a removal already, it will not be
* entry. Only, if the last log entry was a removal already, it will not be
* added a second time.
* This behaviour can be changed by passing a list of states in the optional
* argument $states. Only reviews, etc. in the given state will be affected.
@ -944,7 +944,11 @@ class SeedDMS_Core_User { /* {{{ */
* (state = 0).
*
* The last optional parameter $newuser is for replacing the user currently in
* charge by another user.
* charge by another user. If this parameter is passed, the old user will
* be deleted first (like described above) and afterwards the new user will
* be addded. The deletion of the old user and adding the new user will only
* happen if the new user has at least read access on the document. If not,
* the document will be skipped and remained unchanged.
*
* @param object $user the user doing the removal (needed for entry in
* review and approve log).
@ -961,6 +965,10 @@ class SeedDMS_Core_User { /* {{{ */
$reviewStatus = $this->getReviewStatus();
$db->startTransaction();
foreach ($reviewStatus["indstatus"] as $ri) {
if(!($doc = $this->_dms->getDocument($ri['documentID'])))
continue;
if($newuser && $doc->getAccessMode($newuser) < M_READ)
continue;
if($ri['status'] != -2 && (!isset($states['review']) || in_array($ri['status'], $states['review']))) {
$queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $ri["reviewID"] ."', '-2', '".(($newuser && $ri['status'] == 0) ? 'Reviewer replaced by '.$newuser->getLogin() : 'Reviewer removed from process')."', ".$db->getCurrentDatetime().", '". $user->getID() ."')";
@ -990,6 +998,10 @@ class SeedDMS_Core_User { /* {{{ */
$approvalStatus = $this->getApprovalStatus();
$db->startTransaction();
foreach ($approvalStatus["indstatus"] as $ai) {
if(!($doc = $this->_dms->getDocument($ai['documentID'])))
continue;
if($newuser && $doc->getAccessMode($newuser) < M_READ)
continue;
if($ai['status'] != -2 && (!isset($states['approval']) || in_array($ai['status'], $states['approval']))) {
$queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $ai["approveID"] ."', '-2', '".(($newuser && $ai['status'] == 0)? 'Approver replaced by '.$newuser->getLogin() : 'Approver removed from process')."', ".$db->getCurrentDatetime().", '". $user->getID() ."')";
@ -1019,6 +1031,10 @@ class SeedDMS_Core_User { /* {{{ */
$receiptStatus = $this->getReceiptStatus();
$db->startTransaction();
foreach ($receiptStatus["indstatus"] as $ri) {
if(!($doc = $this->_dms->getDocument($ri['documentID'])))
continue;
if($newuser && $doc->getAccessMode($newuser) < M_READ)
continue;
if($ri['status'] != -2 && (!isset($states['receipt']) || in_array($ri['status'], $states['receipt']))) {
$queryStr = "INSERT INTO `tblDocumentReceiptLog` (`receiptID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $ri["receiptID"] ."', '-2', '".(($newuser && $ri['status'] == 0) ? 'Recipient replaced by '.$newuser->getLogin() : 'Recipient removed from process')."', ".$db->getCurrentDatetime().", '". $user->getID() ."')";
@ -1048,6 +1064,10 @@ class SeedDMS_Core_User { /* {{{ */
$revisionStatus = $this->getRevisionStatus();
$db->startTransaction();
foreach ($revisionStatus["indstatus"] as $ri) {
if(!($doc = $this->_dms->getDocument($ri['documentID'])))
continue;
if($newuser && $doc->getAccessMode($newuser) < M_READ)
continue;
if($ri['status'] != -2 && (!isset($states['revision']) || in_array($ri['status'], $states['revision']))) {
$queryStr = "INSERT INTO `tblDocumentRevisionLog` (`revisionID`, `status`, `comment`, `date`, `userID`) ".
"VALUES ('". $ri["revisionID"] ."', '-2', '".(($newuser && in_array($ri['status'], array(S_LOG_WAITING, S_LOG_SLEEPING))) ? 'Revisor replaced by '.$newuser->getLogin() : 'Revisor removed from process')."', ".$db->getCurrentDatetime().", '". $user->getID() ."')";

View File

@ -25,6 +25,7 @@
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
- all changes from 5.1.26
- removeFromProcesses() will not touch documents for which the new user does not have at least read access
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">