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

This commit is contained in:
Uwe Steinmann 2024-02-08 21:20:28 +01:00
commit 9300d92311
11 changed files with 404 additions and 369 deletions

View File

@ -7,7 +7,17 @@ http://petstore.swagger.io/ or http://editor.swagger.io/
You may as well set up your own swagger-ui installation as described at
https://medium.com/@tatianaensslin/how-to-add-swagger-ui-to-php-server-code-f1610c01dc03
Your apache needs to have the module 'header' enabled, because some HTTP headers
are set when the file swagger.yaml is accessed by the editor.
Your apache needs to have the module `header` enabled, because some HTTP headers
are set when the file `swagger.yaml` is accessed by the editor.
Currently, the swagger.yaml shipped with SeedDMS uses still swagger 2.0
If you are using php-fpm you will have to ensure that files with
extension .yaml are allowed to be parsed. Extend the
`security.limit_extensions` in the pool configuration by `.yaml`. Also
check the contents of the file `.htaccess` in directory `restapi`. It
by default sets the handler for php to `application/x-httpd-php` which
uses the apache module of php. If you would like to use php-fpm
instead, then set it to
SetHandler "proxy:unix:/var/run/php/php8.2-fpm.sock|fcgi://localhost/"

View File

@ -188,7 +188,7 @@ 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;
// enable/disable listing logged in user as recipient
var $_enableSelfReceipt = false;
@ -202,6 +202,14 @@ class Settings { /* {{{ */
var $_enableOwnerReceipt = false;
// enable/disable filter for receipt by the recipient
var $_enableFilterReceipt = 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
@ -805,6 +813,12 @@ class Settings { /* {{{ */
$this->_enableOwnerReceipt = Settings::boolval($tab["enableOwnerReceipt"]);
$this->_enableUpdateReceipt = Settings::boolval($tab["enableUpdateReceipt"]);
$this->_enableFilterReceipt = Settings::boolval($tab["enableFilterReceipt"]);
$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->_initialDocumentStatus = intval($tab["initialDocumentStatus"]);
$this->_versioningFileName = strval($tab["versioningFileName"]);
@ -1177,6 +1191,12 @@ class Settings { /* {{{ */
$this->setXMLAttributValue($node, "enableFilterReceipt", $this->_enableFilterReceipt);
$this->setXMLAttributValue($node, "presetExpirationDate", $this->_presetExpirationDate);
$this->setXMLAttributValue($node, "initialDocumentStatus", $this->_initialDocumentStatus);
$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, "workflowMode", $this->_workflowMode);
$this->setXMLAttributValue($node, "enableReceiptWorkflow", $this->_enableReceiptWorkflow);

View File

@ -1066,36 +1066,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;
} /* }}} */
@ -1103,38 +1147,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;
$appi[] = $r['approverUserID'];
} elseif ($r['approverGroupID']!=0){
$appg[] = $r['approverGroupID'];
}
}
else if ($r['approverGroupID']!=0){
foreach ($docAccess["groups"] as $grp)
if ($grp->getID()==$r['approverGroupID']){
$approvers["g"][] = $r['approverGroupID'];
break;
/* 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

@ -234,13 +234,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

@ -794,13 +794,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

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

View File

@ -278,13 +278,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

@ -514,33 +514,30 @@ console.log(params);
}
if($settings->_initialDocumentStatus == S_RELEASED)
$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']);
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(
@ -557,19 +554,17 @@ console.log(params);
);
/* Check for mandatory reviewer without access */
foreach($res as $r) {
if($r['reviewerUserID']) {
foreach($mreviewers['ni'] as $r) {
$hasAccess = false;
foreach ($docAccess["users"] as $usr) {
if ($r['reviewerUserID']==$usr->getID())
if ($r == $usr->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessUser = $dms->getUser($r['reviewerUserID']);
$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) {
@ -590,22 +585,15 @@ console.log(params);
/* List all mandatory groups of reviewers */
$tmp = array();
if($res) {
foreach ($res as $r) {
if($r['reviewerGroupID'] > 0) {
$u = $dms->getGroup($r['reviewerGroupID']);
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(
@ -621,11 +609,10 @@ 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']) {
foreach($mreviewers['ng'] as $r) {
$hasAccess = false;
foreach ($docAccess["groups"] as $grp) {
if ($r['reviewerGroupID']==$grp->getID())
if ($r == $grp->getID())
$hasAccess = true;
}
if(!$hasAccess) {
@ -633,34 +620,29 @@ console.log(params);
$this->warningMsg(getMLText("mandatory_reviewergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName()))));
}
}
}
$this->contentContainerEnd();
}
$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']);
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;
$mandatory=false;
foreach ($res as $r) if ($r['approverUserID']==$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(), $mapprovers['i']))
$option[] = array(array('disabled', 'disabled'), array('data-subtitle', getMLText('user_is_mandatory_approver')));
$options[] = $option;
}
$this->formField(
@ -677,19 +659,17 @@ console.log(params);
);
/* 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) {
@ -710,24 +690,16 @@ console.log(params);
/* List all mandatory groups of approvers */
$tmp = array();
if($res) {
foreach ($res as $r) {
if($r['approverGroupID'] > 0) {
$u = $dms->getGroup($r['approverGroupID']);
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(
@ -744,19 +716,18 @@ console.log(params);
);
/* Check for mandatory approver groups without access */
foreach($res as $r) {
if ($r['approverGroupID']) {
foreach($mapprovers['ng'] as $r) {
$hasAccess = false;
foreach ($docAccess["groups"] as $grp) {
if ($r['approverGroupID']==$grp->getID())
if ($r == $grp->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessGroup = $dms->getGroup($r['approverGroupID']);
$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 {
}

View File

@ -89,19 +89,19 @@ 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();
*/
$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){
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"]) {
@ -117,24 +117,21 @@ 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 reviewers */
$extraparams = [];
if($res) {
$tmp = array();
foreach ($res as $r) {
if($r['reviewerUserID'] > 0) {
$u = $dms->getUser($r['reviewerUserID']);
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"),
array(
@ -173,10 +170,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"]) {
@ -197,18 +191,14 @@ 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']);
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"),
array(
@ -228,20 +218,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()])) {
@ -259,25 +250,21 @@ 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']);
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"),
array(
@ -316,10 +303,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()])) {
@ -342,17 +326,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']);
foreach ($mapprovers['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"];
}
$extraparams['field_wrap'] = ['', '<div class="mandatories"><span>'.getMLText('mandatory_approvergroups').':</span> '.implode(', ', $tmp)."</div>\n"];
}
$this->formField(
getMLText("groups"),

View File

@ -544,6 +544,10 @@ if(($kkk = $this->callHook('getFullSearchEngine')) && is_array($kkk))
<?php $this->showConfigCheckbox('settings_enableOwnerReceipt', 'enableOwnerReceipt'); ?>
<?php $this->showConfigCheckbox('settings_enableUpdateReceipt', 'enableUpdateReceipt'); ?>
<?php $this->showConfigCheckbox('settings_enableFilterReceipt', 'enableFilterReceipt'); ?>
<?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

@ -348,28 +348,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'];
@ -381,21 +377,18 @@ 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']);
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(
getMLText("individuals"),
@ -412,19 +405,17 @@ console.log(element);
);
/* Check for mandatory reviewer without access */
foreach($res as $r) {
if($r['reviewerUserID']) {
foreach($mreviewers['ni'] as $r) {
$hasAccess = false;
foreach ($docAccess["users"] as $usr) {
if ($r['reviewerUserID']==$usr->getID())
if ($r == $usr->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessUser = $dms->getUser($r['reviewerUserID']);
$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) {
@ -445,24 +436,17 @@ console.log(element);
$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'];
@ -474,18 +458,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']);
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(
@ -501,11 +485,10 @@ console.log(element);
);
/* Check for mandatory reviewer group without access */
foreach($res as $r) {
if ($r['reviewerGroupID']) {
foreach($mreviewers['ng'] as $r) {
$hasAccess = false;
foreach ($docAccess["groups"] as $grp) {
if ($r['reviewerGroupID']==$grp->getID())
if ($r == $grp->getID())
$hasAccess = true;
}
if(!$hasAccess) {
@ -513,35 +496,30 @@ console.log(element);
$this->warningMsg(getMLText("mandatory_reviewergroup_no_access", array('group'=>htmlspecialchars($noAccessGroup->getName()))));
}
}
}
$this->contentContainerEnd();
}
$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;
$mandatory=false;
foreach ($res as $r) if ($r['approverUserID']==$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(), $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'];
@ -552,18 +530,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']);
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(
@ -581,19 +559,17 @@ 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) {
@ -615,47 +591,33 @@ console.log(element);
$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)
if(!in_array($r['required'], $mapprovers['g']))
$tmp[] = $r['required'];
} else {
$tmp[] = $r['required'];
}
}
}
$fieldwrap = array('', '');
if($tmp) {
$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']);
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(
getMLText("groups"),
@ -672,19 +634,17 @@ console.log(element);
);
/* Check for mandatory approver groups without access */
foreach($res as $r) {
if ($r['approverGroupID']) {
foreach($mapprovers['ng'] as $r) {
$hasAccess = false;
foreach ($docAccess["groups"] as $grp) {
if ($r['approverGroupID']==$grp->getID())
if ($r == $grp->getID())
$hasAccess = true;
}
if(!$hasAccess) {
$noAccessGroup = $dms->getGroup($r['approverGroupID']);
$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 {