diff --git a/CHANGELOG b/CHANGELOG index f0b1a4085..f86481bfd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -108,6 +108,9 @@ - minor improvements of installation - better checking in out/*.php for allowed operation (e.g. EditOnline, RemoveVersion, SetReviewersApprovers, ...) +- SetReviewersApprovers checks for mandatory reviewers/approvers +- reviewers/approvers can only be modified by users with unrestricted access + and as long as no reviewer/approver has reviewed/approved the document -------------------------------------------------------------------------------- Changes in version 4.3.35 diff --git a/inc/inc.ClassAccessOperation.php b/inc/inc.ClassAccessOperation.php index d6a84931b..bfbe66010 100644 --- a/inc/inc.ClassAccessOperation.php +++ b/inc/inc.ClassAccessOperation.php @@ -121,15 +121,28 @@ class SeedDMS_AccessOperation { * * This check can only be done for documents. Overwriting the document * reviewers/approvers is only allowed if version modification is turned on - * in the settings and the document is in 'draft review' status. The - * admin may even set reviewers/approvers if is disallowed in the + * in the settings and the document has not been reviewed/approved by any + * user/group already. + * The admin may even set reviewers/approvers if is disallowed in the * settings. */ function maySetReviewersApprovers() { /* {{{ */ if(get_class($this->obj) == $this->dms->getClassname('document')) { $latestContent = $this->obj->getLatestContent(); $status = $latestContent->getStatus(); - if ((($this->settings->_enableVersionModification && ($this->obj->getAccessMode($this->user) == M_ALL)) || $this->user->isAdmin()) && ($status["status"]==S_DRAFT_REV || $status["status"]==S_DRAFT_APP && $this->settings->_workflowMode == 'traditional_only_approval')) { + $reviewstatus = $latestContent->getReviewStatus(); + $hasreview = false; + foreach($reviewstatus as $r) { + if($r['status'] == 1 || $r['status'] == -1) + $hasreview = true; + } + $approvalstatus = $latestContent->getApprovalStatus(); + $hasapproval = false; + foreach($approvalstatus as $r) { + if($r['status'] == 1 || $r['status'] == -1) + $hasapproval = true; + } + if ((($this->settings->_enableVersionModification && ($this->obj->getAccessMode($this->user) == M_ALL)) || $this->user->isAdmin()) && (($status["status"]==S_DRAFT_REV && !$hasreview) || ($status["status"]==S_DRAFT_APP && !$hasreview && !$hasapproval))) { return true; } } diff --git a/op/op.SetReviewersApprovers.php b/op/op.SetReviewersApprovers.php index 378967fb8..d009b026d 100644 --- a/op/op.SetReviewersApprovers.php +++ b/op/op.SetReviewersApprovers.php @@ -62,6 +62,7 @@ if ($overallStatus["status"]==S_REJECTED || $overallStatus["status"]==S_OBSOLETE } $folder = $document->getFolder(); +$owner = $document->getOwner(); // Retrieve a list of all users and groups that have review / approve // privileges. @@ -106,6 +107,18 @@ foreach ($approvalStatus as $i=>$rs) { // Get the list of proposed reviewers, stripping out any duplicates. $pIndRev = (isset($_POST["indReviewers"]) ? array_values(array_unique($_POST["indReviewers"])) : array()); $pGrpRev = (isset($_POST["grpReviewers"]) ? array_values(array_unique($_POST["grpReviewers"])) : array()); +if($user->getID() != $owner->getID()) { + $res=$owner->getMandatoryReviewers(); + if($user->isAdmin()) + $res = array(); +} else + $res=$user->getMandatoryReviewers(); +foreach ($res as $r) { + if(!in_array($r['reviewerUserID'], $pIndRev)) + $pIndRev[] = $r['reviewerUserID']; + if(!in_array($r['reviewerGroupID'], $pGrpRev)) + $pGrpRev[] = $r['reviewerGroupID']; +} foreach ($pIndRev as $p) { if (is_numeric($p)) { if (isset($accessIndex["i"][$p])) { @@ -326,6 +339,18 @@ if (count($reviewIndex["g"]) > 0) { // Get the list of proposed approvers, stripping out any duplicates. $pIndApp = (isset($_POST["indApprovers"]) ? array_values(array_unique($_POST["indApprovers"])) : array()); $pGrpApp = (isset($_POST["grpApprovers"]) ? array_values(array_unique($_POST["grpApprovers"])) : array()); +if($user->getID() != $owner->getID()) { + $res=$owner->getMandatoryApprovers(); + if($user->isAdmin()) + $res = array(); +} else + $res=$user->getMandatoryApprovers(); +foreach ($res as $r) { + if(!in_array($r['approverUserID'], $pIndApp)) + $pIndApp[] = $r['approverUserID']; + if(!in_array($r['approverGroupID'], $pGrpApp)) + $pGrpApp[] = $r['approverGroupID']; +} foreach ($pIndApp as $p) { if (is_numeric($p)) { if (isset($accessIndex["i"][$p])) { diff --git a/views/bootstrap/class.SetReviewersApprovers.php b/views/bootstrap/class.SetReviewersApprovers.php index b58f73fd4..ffd4f2780 100644 --- a/views/bootstrap/class.SetReviewersApprovers.php +++ b/views/bootstrap/class.SetReviewersApprovers.php @@ -43,6 +43,7 @@ class SeedDMS_View_SetReviewersApprovers extends SeedDMS_Bootstrap_Style { $enableselfrevapp = $this->params['enableselfrevapp']; $overallStatus = $content->getStatus(); + $owner = $document->getOwner(); $this->htmlStartPage(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName())))); $this->globalNavigation($folder); @@ -92,7 +93,12 @@ class SeedDMS_View_SetReviewersApprovers extends SeedDMS_Bootstrap_Style { - + + 0) { + $u = $dms->getUser($r['reviewerUserID']); + $tmp[] = htmlspecialchars($u->getFullName().' ('.$u->getLogin().')'); + } + } + if($tmp) { + echo '