add global and group manager reviewers/approvers

This commit is contained in:
Uwe Steinmann 2024-02-08 21:02:12 +01:00
parent 7c538ad5d1
commit 663ce7f675
10 changed files with 392 additions and 368 deletions

View File

@ -180,8 +180,16 @@ class Settings { /* {{{ */
var $_enableHiddenRevApp = true;
// enable/disable update of a review/approval by the reviewer/approver
var $_enableUpdateRevApp = false;
// enable/disable removal of a review/approval by the admiistrator
// enable/disable removal of a review/approval by the administrator
var $_enableRemoveRevApp = false;
// group manager is mandatory reviewer
var $_addManagerAsReviewer = false;
// group manager is mandatory approver
var $_addManagerAsApprover = false;
// global reviewer
var $_globalReviewer = array();
// global approver
var $_globalApprover = array();
// enable/disable default notification for owner
var $_enableOwnerNotification = false;
// enable/disable deleting of versions for regular users
@ -747,6 +755,12 @@ class Settings { /* {{{ */
$this->_enableHiddenRevApp = Settings::boolval($tab["enableHiddenRevApp"]);
$this->_enableUpdateRevApp = Settings::boolval($tab["enableUpdateRevApp"]);
$this->_enableRemoveRevApp = Settings::boolval($tab["enableRemoveRevApp"]);
$this->_addManagerAsReviewer = Settings::boolval($tab["addManagerAsReviewer"]);
$this->_addManagerAsApprover = Settings::boolval($tab["addManagerAsApprover"]);
if(trim(strval($tab["globalReviewer"])))
$this->_globalReviewer = explode(',',strval($tab["globalReviewer"]));
if(trim(strval($tab["globalApprover"])))
$this->_globalApprover = explode(',',strval($tab["globalApprover"]));
$this->_presetExpirationDate = strval($tab["presetExpirationDate"]);
$this->_versioningFileName = strval($tab["versioningFileName"]);
$this->_workflowMode = strval($tab["workflowMode"]);
@ -1097,7 +1111,12 @@ class Settings { /* {{{ */
$this->setXMLAttributValue($node, "enableHiddenRevApp", $this->_enableHiddenRevApp);
$this->setXMLAttributValue($node, "enableUpdateRevApp", $this->_enableUpdateRevApp);
$this->setXMLAttributValue($node, "enableRemoveRevApp", $this->_enableRemoveRevApp);
$this->setXMLAttributValue($node, "addManagerAsReviewer", $this->_addManagerAsReviewer);
$this->setXMLAttributValue($node, "addManagerAsApprover", $this->_addManagerAsApprover);
$this->setXMLAttributValue($node, "globalReviewer", implode(',', $this->_globalReviewer));
$this->setXMLAttributValue($node, "globalApprover", implode(',', $this->_globalApprover));
$this->setXMLAttributValue($node, "presetExpirationDate", $this->_presetExpirationDate);
$this->setXMLAttributValue($node, "apiOrigin", $this->_apiOrigin);
$this->setXMLAttributValue($node, "versioningFileName", $this->_versioningFileName);
$this->setXMLAttributValue($node, "presetExpirationDate", $this->_presetExpirationDate);
$this->setXMLAttributValue($node, "workflowMode", $this->_workflowMode);

View File

@ -947,7 +947,7 @@ function isAjax() { /* {{{ */
} /* }}} */
/**
* Hash a password
* Hash a password
*
* @param string $password
* @return string hashed password
@ -957,7 +957,7 @@ function seed_pass_hash($password) { /* {{{ */
} /* }}} */
/**
* Verify a password
* Verify a password
*
* @param string $password
* @return string hashed password
@ -1019,7 +1019,7 @@ function cmp_user_login($a, $b) { /* {{{ */
} /* }}} */
/**
* Compare function for sorting users by name
* Compare function for sorting users by name
*
* Use this for usort()
*
@ -1041,36 +1041,80 @@ function cmp_user_fullname($a, $b) { /* {{{ */
* Returns the mandatory reviewers
*
* This function checks if the reviewers have at least read access
* on the folder containing the document.
* on the folder containing the document. It also checks if the
* mandatory reviewer is an admin or the uploading user and if
* those are allowed to review/approve a document.
*
* @param $folder folder where document is located
* @param $document document which is updated, null when adding a new document
* @param $user user creating the new version or document
* @return array
* @return array containing the elements 'i' and 'g'. Each is a list of user/group ids
*/
function getMandatoryReviewers($folder, $user) { /* {{{ */
function getMandatoryReviewers($folder, $document, $user) { /* {{{ */
global $settings;
/* Get a list of all users and groups with read access on the folder.
* Only those users and groups will be added as reviewers
*/
$docAccess = $folder->getReadAccessList($settings->_enableAdminRevApp, $settings->_enableOwnerRevApp);
$res=$user->getMandatoryReviewers();
$reviewers = array('i'=>[], 'g'=>[]);
/* Get mandatory reviewers of user */
$res = $user->getMandatoryReviewers();
$revi = $revg = [];
foreach ($res as $r){
if ($r['reviewerUserID']!=0){
foreach ($docAccess["users"] as $usr)
if ($usr->getID()==$r['reviewerUserID']){
$reviewers["i"][] = $r['reviewerUserID'];
break;
}
$revi[] = $r['reviewerUserID'];
} elseif ($r['reviewerGroupID']!=0){
foreach ($docAccess["groups"] as $grp)
if ($grp->getID()==$r['reviewerGroupID']){
$reviewers["g"][] = $r['reviewerGroupID'];
break;
}
$revg[] = $r['reviewerGroupID'];
}
}
/* Add managers of groups as mandatory reviewers */
if(!empty($settings->_addManagerAsReviewer)) {
$groups = $user->getGroups();
foreach($groups as $group) {
$managers = $group->getManagers();
foreach($managers as $manager) {
$revi[] = $manager->getId();
}
}
}
/* Add global reviewers as mandatory reviewers */
if(!empty($settings->_globalReviewer)) {
$revi = array_merge($revi, $settings->_globalReviewer);
}
/* Check if reviewers are allowed to review */
$revi = array_unique($revi);
$revg = array_unique($revg);
$reviewers["i"] = []; // users
$reviewers["g"] = []; // groups
$reviewers["ni"] = []; // users being filtered out
$reviewers["ng"] = []; // groups being filtered out
$dms = $user->getDMS();
foreach($revi as $uid) {
if($u = $dms->getUser($uid)) {
/* need at least read access on parent folder */
if($folder->getAccessMode($u) < M_READ)
$reviewers["ni"][] = $u->getId();
/* admins as reviewers must be enabled */
elseif(!$settings->_enableAdminRevApp && $u->isAdmin())
$reviewers["ni"][] = $u->getId();
/* the owner of the document as a reviewer must be enabled */
elseif(!$settings->_enableOwnerRevApp && $document && $document->getOwner()->getId() == $u->getId())
$reviewers["ni"][] = $u->getId();
/* the updloader as a reviewer must be enabled */
elseif(!$settings->_enableSelfRevApp && $u->getId() == $user->getId())
$reviewers["ni"][] = $u->getId();
else
$reviewers["i"][] = $u->getId();
}
}
foreach($revg as $gid) {
if($g = $dms->getGroup($gid)) {
if($folder->getGroupAccessMode($g) < M_READ)
$reviewers["ng"][] = $g->getId();
else
$reviewers["g"][] = $g->getId();
}
}
return $reviewers;
} /* }}} */
@ -1078,38 +1122,80 @@ function getMandatoryReviewers($folder, $user) { /* {{{ */
* Returns the mandatory approvers
*
* This function checks if the approvers have at least read access
* on the folder containing the document.
* on the folder containing the document. It also checks if the
* mandatory approver is an admin or the uploading user and if
* those are allowed to review/approve a document.
*
* @param $folder folder where document is located
* @param $document document which is updated, null when adding a new document
* @param $user user creating the new version or document
* @return array
* @return array containing the elements 'i' and 'g'. Each is a list of user/group ids
*/
function getMandatoryApprovers($folder, $user) { /* {{{ */
function getMandatoryApprovers($folder, $document, $user) { /* {{{ */
global $settings;
/* Get a list of all users and groups with read access on the folder.
* Only those users and groups will be added as approvers
*/
$docAccess = $folder->getReadAccessList($settings->_enableAdminRevApp, $settings->_enableOwnerRevApp);
$res=$user->getMandatoryApprovers();
$approvers = array('i'=>[], 'g'=>[]);
/* Get mandatory approvers of user */
$res = $user->getMandatoryApprovers();
$appi = $appg = [];
foreach ($res as $r){
if ($r['approverUserID']!=0){
foreach ($docAccess["users"] as $usr)
if ($usr->getID()==$r['approverUserID']){
$approvers["i"][] = $r['approverUserID'];
break;
}
}
else if ($r['approverGroupID']!=0){
foreach ($docAccess["groups"] as $grp)
if ($grp->getID()==$r['approverGroupID']){
$approvers["g"][] = $r['approverGroupID'];
break;
}
$appi[] = $r['approverUserID'];
} elseif ($r['approverGroupID']!=0){
$appg[] = $r['approverGroupID'];
}
}
/* Add managers of groups as mandatory approvers */
if(!empty($settings->_addManagerAsApprover)) {
$groups = $user->getGroups();
foreach($groups as $group) {
$managers = $group->getManagers();
foreach($managers as $manager) {
$appi[] = $manager->getId();
}
}
}
/* Add global approvers as mandatory approvers */
if(!empty($settings->_globalApprover)) {
$appi = array_merge($appi, $settings->_globalApprover);
}
/* Check if approvers are allowed to approve */
$appi = array_unique($appi);
$appg = array_unique($appg);
$approvers["i"] = []; // users
$approvers["g"] = []; // groups
$approvers["ni"] = []; // users being filtered out
$approvers["ng"] = []; // groups being filtered out
$dms = $user->getDMS();
foreach($appi as $uid) {
if($u = $dms->getUser($uid)) {
/* need at least read access on parent folder */
if($folder->getAccessMode($u) < M_READ)
$approvers["ni"][] = $u->getId();
/* admins as approvers must be enabled */
elseif(!$settings->_enableAdminRevApp && $u->isAdmin())
$approvers["ni"][] = $u->getId();
/* the owner of the document as a approver must be enabled */
elseif(!$settings->_enableOwnerRevApp && $document && $document->getOwner()->getId() == $u->getId())
$approvers["ni"][] = $u->getId();
/* the updloader as a approver must be enabled */
elseif(!$settings->_enableSelfRevApp && $u->getId() == $user->getId())
$approvers["ni"][] = $u->getId();
else
$approvers["i"][] = $u->getId();
}
}
foreach($appg as $gid) {
if($g = $dms->getGroup($gid)) {
if($folder->getGroupAccessMode($g) < M_READ)
$approvers["ng"][] = $g->getId();
else
$approvers["g"][] = $g->getId();
}
}
return $approvers;
} /* }}} */

View File

@ -209,13 +209,13 @@ if($settings->_workflowMode == 'traditional' || $settings->_workflowMode == 'tra
}
// add mandatory reviewers/approvers
if($settings->_workflowMode == 'traditional') {
$mreviewers = getMandatoryReviewers($folder, $user);
$mreviewers = getMandatoryReviewers($folder, null, $user);
if($mreviewers['i'])
$reviewers['i'] = array_merge($reviewers['i'], $mreviewers['i']);
if($mreviewers['g'])
$reviewers['g'] = array_merge($reviewers['g'], $mreviewers['g']);
}
$mapprovers = getMandatoryApprovers($folder, $user);
$mapprovers = getMandatoryApprovers($folder, null, $user);
if($mapprovers['i'])
$approvers['i'] = array_merge($approvers['i'], $mapprovers['i']);
if($mapprovers['g'])

View File

@ -784,13 +784,13 @@ switch($command) {
if($settings->_workflowMode == 'traditional' || $settings->_workflowMode == 'traditional_only_approval') {
// add mandatory reviewers/approvers
if($settings->_workflowMode == 'traditional') {
$mreviewers = getMandatoryReviewers($folder, $user);
$mreviewers = getMandatoryReviewers($folder, null, $user);
if($mreviewers['i'])
$reviewers['i'] = array_merge($reviewers['i'], $mreviewers['i']);
if($mreviewers['g'])
$reviewers['g'] = array_merge($reviewers['g'], $mreviewers['g']);
}
$mapprovers = getMandatoryApprovers($folder, $user);
$mapprovers = getMandatoryApprovers($folder, null, $user);
if($mapprovers['i'])
$approvers['i'] = array_merge($approvers['i'], $mapprovers['i']);
if($mapprovers['g'])

View File

@ -247,6 +247,10 @@ if ($action == "saveSettings")
setBoolValue("enableAdminRevApp");
setBoolValue("enableOwnerRevApp");
setBoolValue("enableSelfRevApp");
setBoolValue("addManagerAsReviewer");
setBoolValue("addManagerAsApprover");
setArrayValue("globalReviewer");
setArrayValue("globalApprover");
setBoolValue("enableUpdateRevApp");
setBoolValue("enableRemoveRevApp");
setBoolValue("enableVersionDeletion");

View File

@ -251,13 +251,13 @@ default:
// add mandatory reviewers/approvers
if($settings->_workflowMode == 'traditional') {
$mreviewers = getMandatoryReviewers($folder, $user);
$mreviewers = getMandatoryReviewers($folder, $document, $user);
if($mreviewers['i'])
$reviewers['i'] = array_merge($reviewers['i'], $mreviewers['i']);
if($mreviewers['g'])
$reviewers['g'] = array_merge($reviewers['g'], $mreviewers['g']);
}
$mapprovers = getMandatoryApprovers($folder, $user);
$mapprovers = getMandatoryApprovers($folder, $document, $user);
if($mapprovers['i'])
$approvers['i'] = array_merge($approvers['i'], $mapprovers['i']);
if($mapprovers['g'])

View File

@ -492,33 +492,30 @@ console.log(params);
);
}
$this->warningMsg(getMLText("add_doc_workflow_warning"));
$this->contentContainerEnd();
} elseif($workflowmode == 'traditional' || $workflowmode == 'traditional_only_approval') {
$this->contentContainerEnd();
if($workflowmode == 'traditional') {
$this->contentSubHeading(getMLText("assign_reviewers"));
$this->contentContainerStart();
$mreviewers = getMandatoryReviewers($folder, null, $user);
/* List all mandatory reviewers */
$res=$user->getMandatoryReviewers();
$tmp = array();
if($res) {
foreach ($res as $r) {
if($r['reviewerUserID'] > 0) {
$u = $dms->getUser($r['reviewerUserID']);
$tmp[] = htmlspecialchars($u->getFullName().' ('.$u->getLogin().')');
}
}
foreach ($mreviewers['i'] as $r) {
$u = $dms->getUser($r);
$tmp[] = htmlspecialchars($u->getFullName().' ('.$u->getLogin().')');
}
$options = array();
foreach ($docAccess["users"] as $usr) {
if(!$enablehiddenrevapp && $usr->isHidden()) continue;
if (!$enableselfrevapp && $usr->getID()==$user->getID()) continue;
$mandatory=false;
foreach ($res as $r) if ($r['reviewerUserID']==$usr->getID()) $mandatory=true;
if(!$enableselfrevapp && $usr->getID()==$user->getID()) continue;
$option = array($usr->getID(), htmlspecialchars($usr->getLogin()." - ".$usr->getFullName()), null);
if ($mandatory) $option[] = array(array('disabled', 'disabled'));
if(in_array($usr->getId(), $mreviewers['i']))
$option[] = array(array('disabled', 'disabled'), array('data-subtitle', getMLText('user_is_mandatory_reviewer')));
$options[] = $option;
}
$this->formField(
@ -535,38 +532,29 @@ console.log(params);
);
/* Check for mandatory reviewer without access */
foreach($res as $r) {
if($r['reviewerUserID']) {
$hasAccess = false;
foreach ($docAccess["users"] as $usr) {
if ($r['reviewerUserID']==$usr->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessUser = $dms->getUser($r['reviewerUserID']);
$this->warningMsg(getMLText("mandatory_reviewer_no_access", array('user'=>htmlspecialchars($noAccessUser->getFullName()." (".$noAccessUser->getLogin().")"))));
}
foreach($mreviewers['ni'] as $r) {
$hasAccess = false;
foreach ($docAccess["users"] as $usr) {
if ($r == $usr->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessUser = $dms->getUser($r);
$this->warningMsg(getMLText("mandatory_reviewer_no_access", array('user'=>htmlspecialchars($noAccessUser->getFullName()." (".$noAccessUser->getLogin().")"))));
}
}
/* List all mandatory groups of reviewers */
$tmp = array();
if($res) {
foreach ($res as $r) {
if($r['reviewerGroupID'] > 0) {
$u = $dms->getGroup($r['reviewerGroupID']);
$tmp[] = htmlspecialchars($u->getName());
}
}
foreach ($mreviewers['g'] as $r) {
$u = $dms->getGroup($r);
$tmp[] = htmlspecialchars($u->getName());
}
$options = array();
foreach ($docAccess["groups"] as $grp) {
$mandatory=false;
foreach ($res as $r) if ($r['reviewerGroupID']==$grp->getID()) $mandatory=true;
$option = array($grp->getID(), htmlspecialchars($grp->getName()), null);
if ($mandatory || !$grp->getUsers()) $option[] = array(array('disabled', 'disabled'));
if(in_array($grp->getId(), $mreviewers['g']))
$option[] = array(array('disabled', 'disabled'), array('data-subtitle', getMLText('group_is_mandatory_reviewer')));
$options[] = $option;
}
$this->formField(
@ -582,17 +570,15 @@ console.log(params);
array('field_wrap'=>array('', ($tmp ? '<div class="mandatories"><span>'.getMLText('mandatory_reviewergroups').':</span> '.implode(', ', $tmp).'</div>' : '')))
);
/* Check for mandatory reviewer group without access */
foreach($res as $r) {
if ($r['reviewerGroupID']) {
$hasAccess = false;
foreach ($docAccess["groups"] as $grp) {
if ($r['reviewerGroupID']==$grp->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessGroup = $dms->getGroup($r['reviewerGroupID']);
$this->warningMsg(getMLText("mandatory_reviewergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName()))));
}
foreach($mreviewers['ng'] as $r) {
$hasAccess = false;
foreach ($docAccess["groups"] as $grp) {
if ($r == $grp->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessGroup = $dms->getGroup($r['reviewerGroupID']);
$this->warningMsg(getMLText("mandatory_reviewergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName()))));
}
}
$this->contentContainerEnd();
@ -600,28 +586,24 @@ console.log(params);
$this->contentSubHeading(getMLText("assign_approvers"));
$this->contentContainerStart();
$res=$user->getMandatoryApprovers();
$mapprovers = getMandatoryApprovers($folder, null, $user);
/* List all mandatory approvers */
$tmp = array();
if($res) {
foreach ($res as $r) {
if($r['approverUserID'] > 0) {
$u = $dms->getUser($r['approverUserID']);
$tmp[] = htmlspecialchars($u->getFullName().' ('.$u->getLogin().')');
}
}
foreach ($mapprovers['i'] as $r) {
$u = $dms->getUser($r);
$tmp[] = htmlspecialchars($u->getFullName().' ('.$u->getLogin().')');
}
$options = array();
foreach ($docAccess["users"] as $usr) {
if(!$enablehiddenrevapp && $usr->isHidden()) continue;
if (!$enableselfrevapp && $usr->getID()==$user->getID()) continue;
if(!$enableselfrevapp && $usr->getID()==$user->getID()) continue;
$mandatory=false;
foreach ($res as $r) if ($r['approverUserID']==$usr->getID()) $mandatory=true;
$option = array($usr->getID(), htmlspecialchars($usr->getLogin()." - ".$usr->getFullName()), null);
if ($mandatory) $option[] = array(array('disabled', 'disabled'));
if(in_array($usr->getId(), $mapprovers['i']))
$option[] = array(array('disabled', 'disabled'), array('data-subtitle', getMLText('user_is_mandatory_approver')));
$options[] = $option;
}
$this->formField(
@ -638,39 +620,30 @@ console.log(params);
);
/* Check for mandatory approvers without access */
foreach($res as $r) {
if($r['approverUserID']) {
$hasAccess = false;
foreach ($docAccess["users"] as $usr) {
if ($r['approverUserID']==$usr->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessUser = $dms->getUser($r['approverUserID']);
$this->warningMsg(getMLText("mandatory_approver_no_access", array('user'=>htmlspecialchars($noAccessUser->getFullName()." (".$noAccessUser->getLogin().")"))));
}
foreach($mapprovers['ni'] as $r) {
$hasAccess = false;
foreach ($docAccess["users"] as $usr) {
if ($r == $usr->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessUser = $dms->getUser($r);
$this->warningMsg(getMLText("mandatory_approver_no_access", array('user'=>htmlspecialchars($noAccessUser->getFullName()." (".$noAccessUser->getLogin().")"))));
}
}
/* List all mandatory groups of approvers */
$tmp = array();
if($res) {
foreach ($res as $r) {
if($r['approverGroupID'] > 0) {
$u = $dms->getGroup($r['approverGroupID']);
$tmp[] = htmlspecialchars($u->getName());
}
}
foreach ($mapprovers['g'] as $r) {
$u = $dms->getGroup($r);
$tmp[] = htmlspecialchars($u->getName());
}
$options = array();
foreach ($docAccess["groups"] as $grp) {
$mandatory=false;
foreach ($res as $r) if ($r['approverGroupID']==$grp->getID()) $mandatory=true;
$option = array($grp->getID(), htmlspecialchars($grp->getName()), null);
if ($mandatory || !$grp->getUsers()) $option[] = array(array('disabled', 'disabled'));
if(in_array($usr->getId(), $mapprovers['g']))
$option[] = array(array('disabled', 'disabled'), array('data-subtitle', getMLText('group_is_mandatory_approver')));
$options[] = $option;
}
$this->formField(
@ -687,23 +660,21 @@ console.log(params);
);
/* Check for mandatory approver groups without access */
foreach($res as $r) {
if ($r['approverGroupID']) {
$hasAccess = false;
foreach ($docAccess["groups"] as $grp) {
if ($r['approverGroupID']==$grp->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessGroup = $dms->getGroup($r['approverGroupID']);
$this->warningMsg(getMLText("mandatory_approvergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName()))));
}
foreach($mapprovers['ng'] as $r) {
$hasAccess = false;
foreach ($docAccess["groups"] as $grp) {
if ($r == $grp->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessGroup = $dms->getGroup($r);
$this->warningMsg(getMLText("mandatory_approvergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName()))));
}
}
$this->contentContainerEnd();
$this->warningMsg(getMLText("add_doc_reviewer_approver_warning"));
} else {
}
$this->contentContainerEnd();
$this->columnEnd();
$this->rowEnd();
$this->formSubmit("<i class=\"fa fa-save\"></i> ".getMLText('add_document'));

View File

@ -89,52 +89,48 @@ class SeedDMS_View_SetReviewersApprovers extends SeedDMS_Theme_Style {
$this->contentSubHeading(getMLText("update_reviewers"));
$this->contentContainerStart();
if($user->getID() != $owner->getID()) {
$res=$owner->getMandatoryReviewers();
if($user->isAdmin())
$res = array();
} else
$res=$user->getMandatoryReviewers();
/*
if($user->getID() != $owner->getID()) {
$res=$owner->getMandatoryReviewers();
if($user->isAdmin())
$res = array();
} else
$res=$user->getMandatoryReviewers();
*/
$mreviewers = getMandatoryReviewers($folder, $document, $user);
$options = [];
foreach ($docAccess["users"] as $usr) {
$mandatory=false;
foreach ($res as $r) if ($r['reviewerUserID']==$usr->getID()) $mandatory=true;
if ($mandatory){
$options[] = array($usr->getID(), htmlspecialchars($usr->getLogin() . " - ". $usr->getFullName()), false, array(array('disabled', 'disabled'), array('data-subtitle', getMLText('user_is_mandatory_reviewer'))));
} elseif (isset($reviewIndex["i"][$usr->getID()])) {
switch ($reviewIndex["i"][$usr->getID()]["status"]) {
case S_LOG_WAITING:
$options[] = array($usr->getID(), htmlspecialchars($usr->getLogin() . " - ". $usr->getFullName()), true);
break;
case S_LOG_USER_REMOVED:
$options[] = array($usr->getID(), htmlspecialchars($usr->getLogin() . " - ". $usr->getFullName()), false, array(array('data-subtitle', getMLText('user_previously_removed_from_reviewers'))));
break;
default:
$options[] = array($usr->getID(), htmlspecialchars($usr->getLogin() . " - ". $usr->getFullName()), false, array(array('disabled', 'disabled')));
break;
$options = [];
foreach ($docAccess["users"] as $usr) {
if(in_array($usr->getId(), $mreviewers['i'])) {
$options[] = array($usr->getID(), htmlspecialchars($usr->getLogin() . " - ". $usr->getFullName()), false, array(array('disabled', 'disabled'), array('data-subtitle', getMLText('user_is_mandatory_reviewer'))));
} elseif (isset($reviewIndex["i"][$usr->getID()])) {
switch ($reviewIndex["i"][$usr->getID()]["status"]) {
case S_LOG_WAITING:
$options[] = array($usr->getID(), htmlspecialchars($usr->getLogin() . " - ". $usr->getFullName()), true);
break;
case S_LOG_USER_REMOVED:
$options[] = array($usr->getID(), htmlspecialchars($usr->getLogin() . " - ". $usr->getFullName()), false, array(array('data-subtitle', getMLText('user_previously_removed_from_reviewers'))));
break;
default:
$options[] = array($usr->getID(), htmlspecialchars($usr->getLogin() . " - ". $usr->getFullName()), false, array(array('disabled', 'disabled')));
break;
}
} else {
if(!$enablehiddenrevapp && $usr->isHidden()) continue;
if(!$enableselfrevapp && $usr->getID()==$user->getID()) continue;
$options[] = array($usr->getID(), htmlspecialchars($usr->getLogin() . " - ". $usr->getFullName()));
}
} else {
if(!$enablehiddenrevapp && $usr->isHidden()) continue;
if (!$enableselfrevapp && $usr->getID()==$user->getID()) continue;
$options[] = array($usr->getID(), htmlspecialchars($usr->getLogin() . " - ". $usr->getFullName()));
}
}
/* List all mandatory reviewers */
$extraparams = [];
if($res) {
$tmp = array();
foreach ($res as $r) {
if($r['reviewerUserID'] > 0) {
$u = $dms->getUser($r['reviewerUserID']);
$tmp[] = htmlspecialchars($u->getFullName().' ('.$u->getLogin().')');
}
}
if($tmp) {
$extraparams['field_wrap'] = ['', '<div class="mandatories"><span>'.getMLText('mandatory_reviewers').':</span> '.implode(', ', $tmp)."</div>\n"];
}
$tmp = array();
foreach ($mreviewers['i'] as $r) {
$u = $dms->getUser($r);
$tmp[] = htmlspecialchars($u->getFullName().' ('.$u->getLogin().')');
}
if($tmp) {
$extraparams['field_wrap'] = ['', '<div class="mandatories"><span>'.getMLText('mandatory_reviewers').':</span> '.implode(', ', $tmp)."</div>\n"];
}
$this->formField(
getMLText("individuals"),
@ -153,10 +149,7 @@ class SeedDMS_View_SetReviewersApprovers extends SeedDMS_Theme_Style {
$options = [];
foreach ($docAccess["groups"] as $group) {
$grpusers = $group->getUsers();
$mandatory=false;
foreach ($res as $r) if ($r['reviewerGroupID']==$group->getID()) $mandatory=true;
if ($mandatory) {
if(in_array($group->getId(), $mreviewers['g'])) {
$options[] = array($group->getID(), htmlspecialchars($group->getName().' ('.count($grpusers).')'), false, array(array('disabled', 'disabled'), array('data-subtitle', getMLText('group_is_mandatory_reviewer'))));
} elseif (isset($reviewIndex["g"][$group->getID()])) {
switch ($reviewIndex["g"][$group->getID()]["status"]) {
@ -177,17 +170,13 @@ class SeedDMS_View_SetReviewersApprovers extends SeedDMS_Theme_Style {
/* List all mandatory groups of reviewers */
$extraparams = [];
if($res) {
$tmp = array();
foreach ($res as $r) {
if($r['reviewerGroupID'] > 0) {
$u = $dms->getGroup($r['reviewerGroupID']);
$tmp[] = htmlspecialchars($u->getName());
}
}
if($tmp) {
$extraparams['field_wrap'] = ['', '<div class="mandatories"><span>'.getMLText('mandatory_reviewergroups').':</span> '.implode(', ', $tmp)."</div>\n"];
}
$tmp = array();
foreach ($mreviewers['g'] as $r) {
$u = $dms->getGroup($r);
$tmp[] = htmlspecialchars($u->getName());
}
if($tmp) {
$extraparams['field_wrap'] = ['', '<div class="mandatories"><span>'.getMLText('mandatory_reviewergroups').':</span> '.implode(', ', $tmp)."</div>\n"];
}
$this->formField(
getMLText("groups"),
@ -208,20 +197,21 @@ class SeedDMS_View_SetReviewersApprovers extends SeedDMS_Theme_Style {
$this->contentSubHeading(getMLText("update_approvers"));
$this->contentContainerStart();
/*
if($user->getID() != $owner->getID()) {
$res=$owner->getMandatoryApprovers();
if($user->isAdmin())
$res = array();
} else
$res=$user->getMandatoryApprovers();
*/
$mapprovers = getMandatoryApprovers($folder, $document, $user);
$options = [];
foreach ($docAccess["users"] as $usr) {
$mandatory=false;
foreach ($res as $r) if ($r['approverUserID']==$usr->getID()) $mandatory=true;
if ($mandatory){
if(in_array($usr->getId(), $mapprovers['i'])) {
$options[] = array($usr->getID(), htmlspecialchars($usr->getLogin() . " - ". $usr->getFullName()), false, array(array('disabled', 'disabled'), array('data-subtitle', getMLText('user_is_mandatory_approver'))));
} elseif (isset($approvalIndex["i"][$usr->getID()])) {
@ -239,24 +229,20 @@ class SeedDMS_View_SetReviewersApprovers extends SeedDMS_Theme_Style {
}
else {
if(!$enablehiddenrevapp && $usr->isHidden()) continue;
if (!$enableselfrevapp && $usr->getID()==$user->getID()) continue;
if(!$enableselfrevapp && $usr->getID()==$user->getID()) continue;
$options[] = array($usr->getID(), htmlspecialchars($usr->getLogin() . " - ". $usr->getFullName()));
}
}
/* List all mandatory approvers */
$extraparams = [];
if($res) {
$tmp = array();
foreach ($res as $r) {
if($r['approverUserID'] > 0) {
$u = $dms->getUser($r['approverUserID']);
$tmp[] = htmlspecialchars($u->getFullName().' ('.$u->getLogin().')');
}
}
if($tmp) {
$extraparams['field_wrap'] = ['', '<div class="mandatories"><span>'.getMLText('mandatory_approvers').':</span> '.implode(', ', $tmp)."</div>\n"];
}
$tmp = array();
foreach ($mapprovers['i'] as $r) {
$u = $dms->getUser($r);
$tmp[] = htmlspecialchars($u->getFullName().' ('.$u->getLogin().')');
}
if($tmp) {
$extraparams['field_wrap'] = ['', '<div class="mandatories"><span>'.getMLText('mandatory_approvers').':</span> '.implode(', ', $tmp)."</div>\n"];
}
$this->formField(
getMLText("individuals"),
@ -275,10 +261,7 @@ class SeedDMS_View_SetReviewersApprovers extends SeedDMS_Theme_Style {
$options = [];
foreach ($docAccess["groups"] as $group) {
$grpusers = $group->getUsers();
$mandatory=false;
foreach ($res as $r) if ($r['approverGroupID']==$group->getID()) $mandatory=true;
if ($mandatory) {
if(in_array($group->getId(), $mapprovers['g'])) {
$options[] = array($group->getID(), htmlspecialchars($group->getName().' ('.count($grpusers).')'), false, array(array('disabled', 'disabled'), array('data-subtitle', getMLText('group_is_mandatory_approver'))));
} elseif (isset($approvalIndex["g"][$group->getID()])) {
@ -301,17 +284,13 @@ class SeedDMS_View_SetReviewersApprovers extends SeedDMS_Theme_Style {
/* List all mandatory groups of approvers */
$extraparams = [];
if($res) {
$tmp = array();
foreach ($res as $r) {
if($r['approverGroupID'] > 0) {
$u = $dms->getGroup($r['approverGroupID']);
$tmp[] = htmlspecialchars($u->getName());
}
}
if($tmp) {
$extraparams['field_wrap'] = ['', '<div class="mandatories"><span>'.getMLText('mandatory_reviewergroups').':</span> '.implode(', ', $tmp)."</div>\n"];
}
$tmp = array();
foreach ($mapprovers['g'] as $r) {
$u = $dms->getGroup($r);
$tmp[] = htmlspecialchars($u->getName());
}
if($tmp) {
$extraparams['field_wrap'] = ['', '<div class="mandatories"><span>'.getMLText('mandatory_approvergroups').':</span> '.implode(', ', $tmp)."</div>\n"];
}
$this->formField(
getMLText("groups"),

View File

@ -512,6 +512,10 @@ if(($kkk = $this->callHook('getFullSearchEngine')) && is_array($kkk))
<?php $this->showConfigCheckbox('settings_enableHiddenRevApp', 'enableHiddenRevApp'); ?>
<?php $this->showConfigCheckbox('settings_enableUpdateRevApp', 'enableUpdateRevApp'); ?>
<?php $this->showConfigCheckbox('settings_enableRemoveRevApp', 'enableRemoveRevApp'); ?>
<?php $this->showConfigCheckbox('settings_addManagerAsReviewer', 'addManagerAsReviewer'); ?>
<?php $this->showConfigCheckbox('settings_addManagerAsApprover', 'addManagerAsApprover'); ?>
<?php $this->showConfigUser('settings_globalReviewer', 'globalReviewer', true, true); ?>
<?php $this->showConfigUser('settings_globalApprover', 'globalApprover', true, true); ?>
<?php $this->showConfigCheckbox('settings_enableVersionDeletion', 'enableVersionDeletion'); ?>
<?php $this->showConfigCheckbox('settings_enableVersionModification', 'enableVersionModification'); ?>
<?php $this->showConfigCheckbox('settings_enableDuplicateDocNames', 'enableDuplicateDocNames'); ?>

View File

@ -337,28 +337,24 @@ console.log(element);
$this->contentContainerEnd();
$this->contentSubHeading(getMLText("assign_reviewers"));
$this->contentContainerStart();
$res=$user->getMandatoryReviewers();
$mreviewers = getMandatoryReviewers($folder, $document, $user);
$options = array();
foreach ($docAccess["users"] as $usr) {
if(!$enablehiddenrevapp && $usr->isHidden()) continue;
if (!$enableselfrevapp && $usr->getID()==$user->getID()) continue;
$mandatory=false;
foreach ($res as $r) if ($r['reviewerUserID']==$usr->getID()) $mandatory=true;
if(!$enableselfrevapp && $usr->getID()==$user->getID()) continue;
$option = array($usr->getID(), htmlspecialchars($usr->getLogin()." - ".$usr->getFullName()), null);
if ($mandatory) $option[] = array(array('disabled', 'disabled'));
if(in_array($usr->getId(), $mreviewers['i']))
$option[] = array(array('disabled', 'disabled'), array('data-subtitle', getMLText('user_is_mandatory_reviewer')));
$options[] = $option;
}
$tmp = array();
foreach($reviewStatus as $r) {
if($r['type'] == 0) {
if($res) {
$mandatory=false;
foreach ($res as $rr)
if ($rr['reviewerUserID']==$r['required']) {
$mandatory=true;
}
if(!$mandatory)
if($mreviewers) {
if(!in_array($r['required'], $mreviewers['i']))
$tmp[] = $r['required'];
} else {
$tmp[] = $r['required'];
@ -370,20 +366,17 @@ console.log(element);
$fieldwrap = array('', $this->getSelectPresetButtonHtml("IndReviewers", $tmp));
}
/* List all mandatory reviewers */
if($res) {
$tmp = array();
foreach ($res as $r) {
if($r['reviewerUserID'] > 0) {
$u = $dms->getUser($r['reviewerUserID']);
$tmp[] = htmlspecialchars($u->getFullName().' ('.$u->getLogin().')');
}
}
if($tmp) {
if(isset($fieldwrap[1]))
$fieldwrap[1] .= '<div class="mandatories"><span>'.getMLText('mandatory_reviewers').':</span> '.implode(', ', $tmp)."</div>\n";
else
$fieldwrap[1] = '<div class="mandatories"><span>'.getMLText('mandatory_reviewers').':</span> '.implode(', ', $tmp)."</div>\n";
}
$tmp = array();
foreach ($mreviewers['i'] as $r) {
$u = $dms->getUser($r);
$tmp[] = htmlspecialchars($u->getFullName().' ('.$u->getLogin().')');
}
if($tmp) {
if(isset($fieldwrap[1]))
$fieldwrap[1] .= '<div class="mandatories"><span>'.getMLText('mandatory_reviewers').':</span> '.implode(', ', $tmp)."</div>\n";
else
$fieldwrap[1] = '<div class="mandatories"><span>'.getMLText('mandatory_reviewers').':</span> '.implode(', ', $tmp)."</div>\n";
}
$this->formField(
@ -401,39 +394,31 @@ console.log(element);
);
/* Check for mandatory reviewer without access */
foreach($res as $r) {
if($r['reviewerUserID']) {
$hasAccess = false;
foreach ($docAccess["users"] as $usr) {
if ($r['reviewerUserID']==$usr->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessUser = $dms->getUser($r['reviewerUserID']);
$this->warningMsg(getMLText("mandatory_reviewer_no_access", array('user'=>htmlspecialchars($noAccessUser->getFullName()." (".$noAccessUser->getLogin().")"))));
}
foreach($mreviewers['ni'] as $r) {
$hasAccess = false;
foreach ($docAccess["users"] as $usr) {
if ($r == $usr->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessUser = $dms->getUser($r);
$this->warningMsg(getMLText("mandatory_reviewer_no_access", array('user'=>htmlspecialchars($noAccessUser->getFullName()." (".$noAccessUser->getLogin().")"))));
}
}
$options = array();
foreach ($docAccess["groups"] as $grp) {
$mandatory=false;
foreach ($res as $r) if ($r['reviewerGroupID']==$grp->getID()) $mandatory=true;
$option = array($grp->getID(), htmlspecialchars($grp->getName()), null);
if ($mandatory || !$grp->getUsers()) $option[] = array(array('disabled', 'disabled'));
if(in_array($grp->getId(), $mreviewers['g']) || !$grp->getUsers())
$option[] = array(array('disabled', 'disabled'), array('data-subtitle', getMLText('group_is_mandatory_reviewer')));
$options[] = $option;
}
$tmp = array();
foreach($reviewStatus as $r) {
if($r['type'] == 1) {
if($res) {
$mandatory=false;
foreach ($res as $rr)
if ($rr['reviewerGroupID']==$r['required']) {
$mandatory=true;
}
if(!$mandatory)
if($mreviewers) {
if(!in_array($r['required'], $mreviewers['g']))
$tmp[] = $r['required'];
} else {
$tmp[] = $r['required'];
@ -445,18 +430,18 @@ console.log(element);
$fieldwrap = array('', $this->getSelectPresetButtonHtml("GrpReviewers", $tmp));
}
/* List all mandatory groups of reviewers */
if($res) {
$tmp = array();
foreach ($res as $r) {
if($r['reviewerGroupID'] > 0) {
$u = $dms->getGroup($r['reviewerGroupID']);
$tmp[] = htmlspecialchars($u->getName());
}
}
if($tmp) {
$fieldwrap[1] .= '<div class="mandatories"><span>'.getMLText('mandatory_reviewergroups').':</span> '.implode(', ', $tmp)."</div>\n";
}
$tmp = array();
foreach ($mreviewers['g'] as $r) {
$u = $dms->getGroup($r);
$tmp[] = htmlspecialchars($u->getName());
}
if($tmp) {
if(isset($fieldwrap[1]))
$fieldwrap[1] .= '<div class="mandatories"><span>'.getMLText('mandatory_reviewergroups').':</span> '.implode(', ', $tmp)."</div>\n";
else
$fieldwrap[1] = '<div class="mandatories"><span>'.getMLText('mandatory_reviewergroups').':</span> '.implode(', ', $tmp)."</div>\n";
}
$this->formField(
getMLText("groups"),
array(
@ -472,17 +457,15 @@ console.log(element);
);
/* Check for mandatory reviewer group without access */
foreach($res as $r) {
if ($r['reviewerGroupID']) {
$hasAccess = false;
foreach ($docAccess["groups"] as $grp) {
if ($r['reviewerGroupID']==$grp->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessGroup = $dms->getGroup($r['reviewerGroupID']);
$this->warningMsg(getMLText("mandatory_reviewergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName()))));
}
foreach($mreviewers['ng'] as $r) {
$hasAccess = false;
foreach ($docAccess["groups"] as $grp) {
if ($r == $grp->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessGroup = $dms->getGroup($r['reviewerGroupID']);
$this->warningMsg(getMLText("mandatory_reviewergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName()))));
}
}
$this->contentContainerEnd();
@ -490,29 +473,25 @@ console.log(element);
$this->contentSubHeading(getMLText("assign_approvers"));
$this->contentContainerStart();
$mapprovers = getMandatoryApprovers($folder, $document, $user);
$options = array();
$res=$user->getMandatoryApprovers();
foreach ($docAccess["users"] as $usr) {
if(!$enablehiddenrevapp && $usr->isHidden()) continue;
if (!$enableselfrevapp && $usr->getID()==$user->getID()) continue;
if(!$enableselfrevapp && $usr->getID()==$user->getID()) continue;
$mandatory=false;
foreach ($res as $r) if ($r['approverUserID']==$usr->getID()) $mandatory=true;
$option = array($usr->getID(), htmlspecialchars($usr->getLogin()." - ".$usr->getFullName()), null);
if ($mandatory) $option[] = array(array('disabled', 'disabled'));
if(in_array($usr->getId(), $mapprovers['i']))
$option[] = array(array('disabled', 'disabled'), array('data-subtitle', getMLText('user_is_mandatory_approver')));
$options[] = $option;
}
$tmp = array();
foreach($approvalStatus as $r) {
if($r['type'] == 0) {
if($res) {
$mandatory=false;
foreach ($res as $rr)
if ($rr['approverUserID']==$r['required']) {
$mandatory=true;
}
if(!$mandatory)
if($mapprovers) {
if(!in_array($r['required'], $mapprovers['i']))
$tmp[] = $r['required'];
} else {
$tmp[] = $r['required'];
@ -523,18 +502,18 @@ console.log(element);
if($tmp) {
$fieldwrap = array('', $this->getSelectPresetButtonHtml("IndApprovers", $tmp));
}
/* List all mandatory approvers */
if($res) {
$tmp = array();
foreach ($res as $r) {
if($r['approverUserID'] > 0) {
$u = $dms->getUser($r['approverUserID']);
$tmp[] = htmlspecialchars($u->getFullName().' ('.$u->getLogin().')');
}
}
if($tmp) {
$tmp = array();
foreach ($mapprovers['i'] as $r) {
$u = $dms->getUser($r);
$tmp[] = htmlspecialchars($u->getFullName().' ('.$u->getLogin().')');
}
if($tmp) {
if(isset($fieldwrap[1]))
$fieldwrap[1] .= '<div class="mandatories"><span>'.getMLText('mandatory_approvers').':</span> '.implode(', ', $tmp)."</div>\n";
}
else
$fieldwrap[1] = '<div class="mandatories"><span>'.getMLText('mandatory_approvers').':</span> '.implode(', ', $tmp)."</div>\n";
}
$this->formField(
@ -552,45 +531,33 @@ console.log(element);
);
/* Check for mandatory approvers without access */
foreach($res as $r) {
if($r['approverUserID']) {
foreach($mapprovers['ni'] as $r) {
$hasAccess = false;
foreach ($docAccess["users"] as $usr) {
if ($r['approverUserID']==$usr->getID())
if ($r == $usr->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessUser = $dms->getUser($r['approverUserID']);
$noAccessUser = $dms->getUser($r);
$this->warningMsg(getMLText("mandatory_approver_no_access", array('user'=>htmlspecialchars($noAccessUser->getFullName()." (".$noAccessUser->getLogin().")"))));
}
}
}
$options = array();
foreach ($docAccess["groups"] as $grp) {
$mandatory=false;
foreach ($res as $r) if ($r['approverGroupID']==$grp->getID()) $mandatory=true;
$option = array($grp->getID(), htmlspecialchars($grp->getName()), null);
if ($mandatory || !$grp->getUsers()) $option[] = array(array('disabled', 'disabled'));
if(in_array($grp->getId(), $mapprovers['g']))
$option[] = array(array('disabled', 'disabled'), array('data-subtitle', getMLText('group_is_mandatory_approver')));
$options[] = $option;
}
$tmp = array();
foreach($approvalStatus as $r) {
if($r['type'] == 1) {
if($res) {
$mandatory=false;
foreach ($res as $rr)
if ($rr['approverGroupID']==$r['required']) {
$mandatory=true;
}
if(!$mandatory)
$tmp[] = $r['required'];
} else {
if(!in_array($r['required'], $mapprovers['g']))
$tmp[] = $r['required'];
}
} else {
$tmp[] = $r['required'];
}
}
$fieldwrap = array('', '');
@ -598,17 +565,13 @@ console.log(element);
$fieldwrap = array('', $this->getSelectPresetButtonHtml("GrpApprovers", $tmp));
}
/* List all mandatory groups of approvers */
if($res) {
$tmp = array();
foreach ($res as $r) {
if($r['approverGroupID'] > 0) {
$u = $dms->getGroup($r['approverGroupID']);
$tmp[] = htmlspecialchars($u->getName());
}
}
if($tmp) {
$fieldwrap[1] .= '<div class="mandatories"><span>'.getMLText('mandatory_approvergroups').':</span> '.implode(', ', $tmp)."</div>\n";
}
$tmp = array();
foreach ($mapprovers['g'] as $r) {
$u = $dms->getGroup($r);
$tmp[] = htmlspecialchars($u->getName());
}
if($tmp) {
$fieldwrap[1] .= '<div class="mandatories"><span>'.getMLText('mandatory_approvergroups').':</span> '.implode(', ', $tmp)."</div>\n";
}
$this->formField(
@ -626,17 +589,15 @@ console.log(element);
);
/* Check for mandatory approver groups without access */
foreach($res as $r) {
if ($r['approverGroupID']) {
$hasAccess = false;
foreach ($docAccess["groups"] as $grp) {
if ($r['approverGroupID']==$grp->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessGroup = $dms->getGroup($r['approverGroupID']);
$this->warningMsg(getMLText("mandatory_approvergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName()))));
}
foreach($mapprovers['ng'] as $r) {
$hasAccess = false;
foreach ($docAccess["groups"] as $grp) {
if ($r == $grp->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessGroup = $dms->getGroup($r);
$this->warningMsg(getMLText("mandatory_approvergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName()))));
}
}
$this->contentContainerEnd();