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

This commit is contained in:
Uwe Steinmann 2021-09-29 18:25:54 +02:00
commit ab5aec99ba
12 changed files with 367 additions and 200 deletions

View File

@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
/**
* Implementation of a document in the document management system
*
@ -3139,7 +3140,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
return false;
foreach ($resArr as $row) {
$date = date('Y-m-d H:i:s', $row['date']);
$date = date('Y-m-d H:i:s', (int) $row['date']);
$timeline[] = array('date'=>$date, 'msg'=>'Added attachment "'.$row['name'].'"', 'document'=>$this, 'type'=>'add_file', 'fileid'=>$row['id']);
}
@ -3351,7 +3352,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
* approvals. A document in status S_REJECTED may become S_RELEASED
* if there is at least one positive review or approval.
*/
if (!$ignorecurrentstatus && ($st["status"]==S_OBSOLETE || $st["status"]==S_REJECTED || $st["status"]==S_EXPIRED || $st["status"]==S_NEEDS_CORRECTION)) return;
if (!$ignorecurrentstatus && ($st["status"]==S_OBSOLETE || $st["status"]==S_REJECTED || $st["status"]==S_EXPIRED || $st["status"]==S_NEEDS_CORRECTION)) return $st['status'];
unset($this->_workflow); // force to be reloaded from DB
$hasworkflow = $this->getWorkflow() ? true : false;
@ -3408,10 +3409,10 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
}
/* First check for a running workflow or open reviews, approvals, revisions. */
if ($hasworkflow) $this->setStatus(S_IN_WORKFLOW,$msg,$user);
elseif ($pendingReview) $this->setStatus(S_DRAFT_REV,$msg,$user);
elseif ($pendingApproval) $this->setStatus(S_DRAFT_APP,$msg,$user);
elseif ($pendingRevision) $this->setStatus(S_IN_REVISION,$msg,$user);
if ($hasworkflow) { $newstatus = S_IN_WORKFLOW; $ret = $this->setStatus(S_IN_WORKFLOW,$msg,$user); }
elseif ($pendingReview) { $newstatus = S_DRAFT_REV; $ret = $this->setStatus(S_DRAFT_REV,$msg,$user); }
elseif ($pendingApproval) { $newstatus = S_DRAFT_APP; $ret = $this->setStatus(S_DRAFT_APP,$msg,$user); }
elseif ($pendingRevision) { $newstatus = S_IN_REVISION; $ret = $this->setStatus(S_IN_REVISION,$msg,$user); }
/* This point will only be reached if there is no pending workflow, review,
* approval or revision but the current status is one of S_DRAFT_REV,
* S_DRAFT_APP or S_IN_REVISION. This can happen if formely set reviewers,
@ -3434,19 +3435,19 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
elseif ($st["status"]!=S_DRAFT && $st["status"]!=S_RELEASED ) {
if($st["status"]==S_DRAFT_REV || $st["status"]==S_DRAFT_APP) {
if($hasReview || $hasApproval) $this->setStatus(S_RELEASED,$msg,$user);
else $this->setStatus($initialstatus,$msg,$user);
else { $newstatus = $initialstatus; $ret = $this->setStatus($initialstatus,$msg,$user); }
} elseif($st["status"]==S_IN_REVISION) {
if($needsCorrection) $this->setStatus(S_NEEDS_CORRECTION,$msg,$user);
if($needsCorrection) { $newstatus = S_NEEDS_CORRECTION; $ret = $this->setStatus(S_NEEDS_CORRECTION,$msg,$user); }
else {
$this->finishRevision($user, S_RELEASED, 'Finished revision workflow', $msg);
// $this->setStatus(S_RELEASED,$msg,$user);
$newstatus = S_RELEASED;
$ret = $this->finishRevision($user, S_RELEASED, 'Finished revision workflow', $msg);
}
} elseif($st["status"]==S_EXPIRED) {
$this->setStatus(S_RELEASED,$msg,$user);
$newstatus = S_RELEASED; $ret = $this->setStatus(S_RELEASED,$msg,$user);
}
}
return $ret ? $newstatus : $ret;
} /* }}} */
function __construct($id, $document, $version, $comment, $date, $userID, $dir, $orgFileName, $fileType, $mimeType, $fileSize=0, $checksum='', $revisionDate=null) { /* {{{ */
@ -3716,7 +3717,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
return false;
if (count($res)!=1)
return false;
$this->_status = $res[0];
$this->_status = $res[0];
}
return $this->_status;
} /* }}} */
@ -3814,7 +3815,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
}
$db->commitTransaction();
unset($this->_status);
unset($this->_status);
return true;
} /* }}} */
@ -4691,12 +4692,25 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
return false;
} /* }}} */
/**
* Add user as new reviewer
*
* @param object $user user in charge for the review
* @param object $requestUser user requesting the operation (usually the
* currently logged in user)
*
* @return integer|false if > 0 the id of the review log, if < 0 the error
* code, false in case of an sql error
*/
function addIndReviewer($user, $requestUser) { /* {{{ */
if(!$user || !$requestUser)
return -1;
$db = $this->_document->getDMS()->getDB();
if(!$user->isType('user'))
return -1;
$userID = $user->getID();
// Get the list of users and groups with read access to this document.
@ -4707,7 +4721,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
// Check to see if the user has already been added to the review list.
$reviewStatus = $user->getReviewStatus($this->_document->getID(), $this->_version);
if (is_bool($reviewStatus) && !$reviewStatus) {
return -1;
return false;
}
$indstatus = false;
if (count($reviewStatus["indstatus"]) > 0) {
@ -4724,7 +4738,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
"VALUES ('". $this->_document->getID() ."', '". $this->_version ."', '0', '". $userID ."')";
$res = $db->getResult($queryStr);
if (is_bool($res) && !$res) {
return -1;
return false;
}
$reviewID = $db->getInsertID('tblDocumentReviewers', 'reviewID');
}
@ -4736,18 +4750,33 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
"VALUES ('". $reviewID ."', '0', '', ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr);
if (is_bool($res) && !$res) {
return -1;
return false;
}
// Add reviewer to event notification table.
//$this->_document->addNotify($userID, true);
return 0;
$reviewLogID = $db->getInsertID('tblDocumentReviewLog', 'reviewLogID');
$db->dropTemporaryTable('ttreviewid');
return $reviewLogID;
} /* }}} */
/**
* Add group as new reviewer
*
* @param object $group group in charge for the review
* @param object $requestUser user requesting the operation (usually the
* currently logged in user)
*
* @return integer|false if > 0 the id of the review log, if < 0 the error
* code, false in case of an sql error
*/
function addGrpReviewer($group, $requestUser) { /* {{{ */
if(!$group || !$requestUser)
return -1;
$db = $this->_document->getDMS()->getDB();
if(!$group->isType('group'))
return -1;
$groupID = $group->getID();
// Get the list of users and groups with read access to this document.
@ -4768,8 +4797,8 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
// Check to see if the group has already been added to the review list.
$reviewStatus = $group->getReviewStatus($this->_document->getID(), $this->_version);
if (is_bool($reviewStatus) && !$reviewStatus) {
return -1;
if (is_bool($reviewStatus) && !$reviewStatus) {
return false;
}
if (count($reviewStatus) > 0 && $reviewStatus[0]["status"]!=-2) {
// Group is already on the list of reviewers; return an error.
@ -4794,13 +4823,12 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
"VALUES ('". $reviewID ."', '0', '', ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr);
if (is_bool($res) && !$res) {
return -1;
return false;
}
// Add reviewer to event notification table.
//$this->_document->addNotify($groupID, false);
return 0;
$reviewLogID = $db->getInsertID('tblDocumentReviewLog', 'reviewLogID');
$db->dropTemporaryTable('ttreviewid');
return $reviewLogID;
} /* }}} */
/**
@ -4815,21 +4843,30 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
* be set again and 0 will be returned. Іf the review could be succesfully
* added, the review log id will be returned.
*
* @see SeedDMS_Core_DocumentContent::setApprovalByInd()
* @param object $user user doing the review
* @param object $requestUser user asking for the review, this is mostly
* @see SeedDMS_Core_DocumentContent::setApprovalByInd()
*
* @param object $user user doing the review
* @param object $requestUser user asking for the review, this is mostly
* the user currently logged in.
* @param integer $status status of review
* @param string $comment comment for review
* @return integer new review log id
* @param string $comment comment for review
*
* @return integer|bool new review log id, error code 0 till -4,
* false in case of an sql error
*/
function setReviewByInd($user, $requestUser, $status, $comment, $file='') { /* {{{ */
if(!$user || !$requestUser)
return -1;
$db = $this->_document->getDMS()->getDB();
// Check to see if the user can be removed from the review list.
if(!$user->isType('user'))
return -1;
// Check if the user is on the review list at all.
$reviewStatus = $user->getReviewStatus($this->_document->getID(), $this->_version);
if (is_bool($reviewStatus) && !$reviewStatus) {
return -1;
return false;
}
if (count($reviewStatus["indstatus"])==0) {
// User is not assigned to review this document. No action required.
@ -4852,7 +4889,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
$requestUser->getID() ."')";
$res=$db->getResult($queryStr);
if (is_bool($res) && !$res)
return -1;
return false;
$reviewLogID = $db->getInsertID('tblDocumentReviewLog', 'reviewLogID');
if($file) {
@ -4866,13 +4903,17 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
*
* This method will not delete anything from the database, but will add
* a new review log entry which sets the status to 0. This is only allowed
* if the current status is either 1 or -1.
* if the current status is either 1 (reviewed) or -1 (rejected).
*
* After calling this method SeedDMS_Core_DocumentCategory::verifyStatus()
* should be called to recalculate the document status.
*
* @param SeedDMS_Core_User $user
* @return int 0 if successful
* @param integer $reviewid id of review
* @param SeedDMS_Core_User $requestUser user requesting the removal
* @param string $comment comment
*
* @return integer|bool true if successful, error code < 0,
* false in case of an sql error
*/
public function removeReview($reviewid, $requestUser, $comment='') { /* {{{ */
$db = $this->_document->getDMS()->getDB();
@ -4880,7 +4921,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
// Check to see if the user can be removed from the review list.
$reviews = $this->getReviewStatus();
if (is_bool($reviews) && !$reviews) {
return -1;
return false;
}
$reviewStatus = null;
foreach($reviews as $review) {
@ -4900,12 +4941,11 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
`comment`, `date`, `userID`) ".
"VALUES ('". $reviewStatus["reviewID"] ."', '0', ".$db->qstr($comment).", ".$db->getCurrentDatetime().", '".
$requestUser->getID() ."')";
//$queryStr = "DELETE FROM `tblDocumentReviewLog` WHERE `reviewLogID` = ".$reviewStatus['reviewLogID'];
$res=$db->getResult($queryStr);
if (is_bool($res) && !$res)
return -1;
return false;
return 0;
return true;
} /* }}} */
/**
@ -4915,27 +4955,35 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
* {@see SeedDMS_Core_DocumentContent::setReviewByInd()} but adds a review
* for a group instead of a user.
*
* @param object $group group doing the review
* @param object $requestUser user asking for the review, this is mostly
* @param object $group group doing the review
* @param object $requestUser user asking for the review, this is mostly
* the user currently logged in.
* @param integer $status status of review
* @param string $comment comment for review
* @return integer new review log id
* @param string $comment comment for review
*
* @return integer|bool new review log id, error code 0 till -4,
* false in case of an sql error
*/
function setReviewByGrp($group, $requestUser, $status, $comment, $file='') { /* {{{ */
if(!$group || !$requestUser)
return -1;
$db = $this->_document->getDMS()->getDB();
// Check to see if the user can be removed from the review list.
if(!$group->isType('group'))
return -1;
// Check if the group is on the review list at all.
$reviewStatus = $group->getReviewStatus($this->_document->getID(), $this->_version);
if (is_bool($reviewStatus) && !$reviewStatus) {
return -1;
}
return false;
}
if (count($reviewStatus)==0) {
// User is not assigned to review this document. No action required.
// Return an error.
return -3;
}
if ($reviewStatus[0]["status"]==-2) {
if ((int) $reviewStatus[0]["status"]==-2) {
// Group has been deleted from reviewers
return -4;
}
@ -4951,22 +4999,34 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
$requestUser->getID() ."')";
$res=$db->getResult($queryStr);
if (is_bool($res) && !$res)
return -1;
else {
$reviewLogID = $db->getInsertID('tblDocumentReviewLog', 'reviewLogID');
if($file) {
SeedDMS_Core_File::copyFile($file, $this->_dms->contentDir . $this->_document->getDir() . 'r' . $reviewLogID);
}
return $reviewLogID;
}
return false;
$reviewLogID = $db->getInsertID('tblDocumentReviewLog', 'reviewLogID');
if($file) {
SeedDMS_Core_File::copyFile($file, $this->_dms->contentDir . $this->_document->getDir() . 'r' . $reviewLogID);
}
return $reviewLogID;
} /* }}} */
/**
* Add user as new approver
*
* @param object $user user in charge for the approval
* @param object $requestUser user requesting the operation (usually the
* currently logged in user)
*
* @return integer|false if > 0 the id of the approval log, if < 0 the error
* code, false in case of an sql error
*/
function addIndApprover($user, $requestUser) { /* {{{ */
if(!$user || !$requestUser)
return -1;
$db = $this->_document->getDMS()->getDB();
if(!$user->isType('user'))
return -1;
$userID = $user->getID();
// Get the list of users and groups with read access to this document.
@ -4974,10 +5034,10 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
return -2;
}
// Check to see if the user has already been added to the approvers list.
// Check if the user has already been added to the approvers list.
$approvalStatus = $user->getApprovalStatus($this->_document->getID(), $this->_version);
if (is_bool($approvalStatus) && !$approvalStatus) {
return -1;
return false;
}
$indstatus = false;
if (count($approvalStatus["indstatus"]) > 0) {
@ -4994,7 +5054,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
"VALUES ('". $this->_document->getID() ."', '". $this->_version ."', '0', '". $userID ."')";
$res = $db->getResult($queryStr);
if (is_bool($res) && !$res) {
return -1;
return false;
}
$approveID = $db->getInsertID('tblDocumentApprovers', 'approveID');
}
@ -5006,16 +5066,33 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
"VALUES ('". $approveID ."', '0', '', ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr);
if (is_bool($res) && !$res) {
return -1;
return false;
}
$approveLogID = $db->getInsertID('tblDocumentApproveLog', 'approveLogID');
$db->dropTemporaryTable('ttapproveid');
return $approveLogID;
} /* }}} */
/**
* Add group as new approver
*
* @param object $group group in charge for the approval
* @param object $requestUser user requesting the operation (usually the
* currently logged in user)
*
* @return integer|false if > 0 the id of the approval log, if < 0 the error
* code, false in case of an sql error
*/
function addGrpApprover($group, $requestUser) { /* {{{ */
if(!$group || !$requestUser)
return -1;
$db = $this->_document->getDMS()->getDB();
if(!$group->isType('group'))
return -1;
$groupID = $group->getID();
// Get the list of users and groups with read access to this document.
@ -5034,10 +5111,10 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
return -2;
}
// Check to see if the group has already been added to the approver list.
// Check if the group has already been added to the approver list.
$approvalStatus = $group->getApprovalStatus($this->_document->getID(), $this->_version);
if (is_bool($approvalStatus) && !$approvalStatus) {
return -1;
return false;
}
if (count($approvalStatus) > 0 && $approvalStatus[0]["status"]!=-2) {
// Group is already on the list of approvers; return an error.
@ -5050,7 +5127,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
"VALUES ('". $this->_document->getID() ."', '". $this->_version ."', '1', '". $groupID ."')";
$res = $db->getResult($queryStr);
if (is_bool($res) && !$res) {
return -1;
return false;
}
$approveID = $db->getInsertID('tblDocumentApprovers', 'approveID');
}
@ -5062,13 +5139,11 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
"VALUES ('". $approveID ."', '0', '', ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr);
if (is_bool($res) && !$res) {
return -1;
return false;
}
// Add approver to event notification table.
//$this->_document->addNotify($groupID, false);
$approveLogID = $db->getInsertID('tblDocumentApproveLog', 'approveLogID');
$approveLogID = $db->getInsertID('tblDocumentApproveLog', 'approveLogID');
$db->dropTemporaryTable('ttapproveid');
return $approveLogID;
} /* }}} */
@ -5083,25 +5158,34 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
* Then it is check if the approval status is already -2. In both cases
* the function returns with an error.
*
* @see SeedDMS_Core_DocumentContent::setReviewByInd()
* @param object $user user in charge for doing the approval
* @param object $requestUser user actually calling this function
* @see SeedDMS_Core_DocumentContent::setReviewByInd()
*
* @param object $user user in charge for doing the approval
* @param object $requestUser user actually calling this function
* @param integer $status the status of the approval, possible values are
* 0=unprocessed (maybe used to reset a status)
* 1=approved,
* -1=rejected,
* -2=user is deleted (use {link
* SeedDMS_Core_DocumentContent::delIndApprover} instead)
* @param string $comment approval comment
* @return integer 0 on success, < 0 in case of an error
* @param string $comment approval comment
*
* @return integer|bool new review log id, error code 0 till -4,
* false in case of an sql error
*/
function setApprovalByInd($user, $requestUser, $status, $comment, $file='') { /* {{{ */
if(!$user || !$requestUser)
return -1;
$db = $this->_document->getDMS()->getDB();
// Check to see if the user can be removed from the approval list.
if(!$user->isType('user'))
return -1;
// Check if the user is on the approval list at all.
$approvalStatus = $user->getApprovalStatus($this->_document->getID(), $this->_version);
if (is_bool($approvalStatus) && !$approvalStatus) {
return -1;
return false;
}
if (count($approvalStatus["indstatus"])==0) {
// User is not assigned to approve this document. No action required.
@ -5124,7 +5208,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
$requestUser->getID() ."')";
$res=$db->getResult($queryStr);
if (is_bool($res) && !$res)
return -1;
return false;
$approveLogID = $db->getInsertID('tblDocumentApproveLog', 'approveLogID');
if($file) {
@ -5137,14 +5221,18 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
* Add another entry to approval log which resets the status
*
* This method will not delete anything from the database, but will add
* a new review log entry which sets the status to 0. This is only allowed
* if the current status is either 1 or -1.
* a new approval log entry which sets the status to 0. This is only allowed
* if the current status is either 1 (approved) or -1 (rejected).
*
* After calling this method SeedDMS_Core_DocumentCategory::verifyStatus()
* should be called to recalculate the document status.
*
* @param SeedDMS_Core_User $user
* @return int 0 if successful
* @param integer $approveid id of approval
* @param SeedDMS_Core_User $requestUser user requesting the removal
* @param string $comment comment
*
* @return integer|bool true if successful, error code < 0,
* false in case of an sql error
*/
public function removeApproval($approveid, $requestUser, $comment='') { /* {{{ */
$db = $this->_document->getDMS()->getDB();
@ -5152,7 +5240,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
// Check to see if the user can be removed from the approval list.
$approvals = $this->getApprovalStatus();
if (is_bool($approvals) && !$approvals) {
return -1;
return false;
}
$approvalStatus = null;
foreach($approvals as $approval) {
@ -5174,25 +5262,31 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
$requestUser->getID() ."')";
$res=$db->getResult($queryStr);
if (is_bool($res) && !$res)
return -1;
return false;
return 0;
return true;
} /* }}} */
/**
* Sets approval status of a document content for a group
* Sets approval status of a document content for a group
*
* The functions behaves like
* {link SeedDMS_Core_DocumentContent::setApprovalByInd} but does it for
* group instead of a user
* a group instead of a user
*/
function setApprovalByGrp($group, $requestUser, $status, $comment, $file='') { /* {{{ */
if(!$group || !$requestUser)
return -1;
$db = $this->_document->getDMS()->getDB();
// Check to see if the user can be removed from the approval list.
if(!$group->isType('group'))
return -1;
// Check if the group is on the approval list at all.
$approvalStatus = $group->getApprovalStatus($this->_document->getID(), $this->_version);
if (is_bool($approvalStatus) && !$approvalStatus) {
return -1;
return false;
}
if (count($approvalStatus)==0) {
// User is not assigned to approve this document. No action required.
@ -5215,7 +5309,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
$requestUser->getID() ."')";
$res=$db->getResult($queryStr);
if (is_bool($res) && !$res)
return -1;
return false;
$approveLogID = $db->getInsertID('tblDocumentApproveLog', 'approveLogID');
if($file) {
@ -5642,10 +5736,13 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
function delIndReviewer($user, $requestUser, $msg='') { /* {{{ */
$db = $this->_document->getDMS()->getDB();
if(!$user->isType('user'))
return -1;
// Check to see if the user can be removed from the review list.
$reviewStatus = $user->getReviewStatus($this->_document->getID(), $this->_version);
if (is_bool($reviewStatus) && !$reviewStatus) {
return -1;
return false;
}
if (count($reviewStatus["indstatus"])==0) {
// User is not assigned to review this document. No action required.
@ -5663,7 +5760,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
"VALUES ('". $indstatus["reviewID"] ."', '".S_LOG_USER_REMOVED."', ".$db->qstr($msg).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr);
if (is_bool($res) && !$res) {
return -1;
return false;
}
return 0;
@ -5672,12 +5769,15 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
function delGrpReviewer($group, $requestUser, $msg='') { /* {{{ */
$db = $this->_document->getDMS()->getDB();
if(!$group->isType('group'))
return -1;
$groupID = $group->getID();
// Check to see if the user can be removed from the review list.
$reviewStatus = $group->getReviewStatus($this->_document->getID(), $this->_version);
if (is_bool($reviewStatus) && !$reviewStatus) {
return -1;
return false;
}
if (count($reviewStatus)==0) {
// User is not assigned to review this document. No action required.
@ -5694,7 +5794,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
"VALUES ('". $reviewStatus[0]["reviewID"] ."', '".S_LOG_USER_REMOVED."', ".$db->qstr($msg).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr);
if (is_bool($res) && !$res) {
return -1;
return false;
}
return 0;
@ -5703,12 +5803,15 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
function delIndApprover($user, $requestUser, $msg='') { /* {{{ */
$db = $this->_document->getDMS()->getDB();
if(!$user->isType('user'))
return -1;
$userID = $user->getID();
// Check to see if the user can be removed from the approval list.
// Check if the user is on the approval list at all.
$approvalStatus = $user->getApprovalStatus($this->_document->getID(), $this->_version);
if (is_bool($approvalStatus) && !$approvalStatus) {
return -1;
return false;
}
if (count($approvalStatus["indstatus"])==0) {
// User is not assigned to approve this document. No action required.
@ -5726,7 +5829,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
"VALUES ('". $indstatus["approveID"] ."', '".S_LOG_USER_REMOVED."', ".$db->qstr($msg).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr);
if (is_bool($res) && !$res) {
return -1;
return false;
}
return 0;
@ -5735,12 +5838,15 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
function delGrpApprover($group, $requestUser, $msg='') { /* {{{ */
$db = $this->_document->getDMS()->getDB();
if(!$group->isType('group'))
return -1;
$groupID = $group->getID();
// Check to see if the user can be removed from the approver list.
// Check if the group is on the approval list at all.
$approvalStatus = $group->getApprovalStatus($this->_document->getID(), $this->_version);
if (is_bool($approvalStatus) && !$approvalStatus) {
return -1;
return false;
}
if (count($approvalStatus)==0) {
// User is not assigned to approve this document. No action required.
@ -5757,7 +5863,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
"VALUES ('". $approvalStatus[0]["approveID"] ."', '".S_LOG_USER_REMOVED."', ".$db->qstr($msg).", ".$db->getCurrentDatetime().", '". $requestUser->getID() ."')";
$res = $db->getResult($queryStr);
if (is_bool($res) && !$res) {
return -1;
return false;
}
return 0;

View File

@ -453,10 +453,11 @@ class SeedDMS_Core_Group { /* {{{ */
($documentID==null ? "" : "AND `tblDocumentReviewers`.`documentID` = '". (int) $documentID ."' ").
($version==null ? "" : "AND `tblDocumentReviewers`.`version` = '". (int) $version ."' ").
"AND `tblDocumentReviewers`.`type`='1' ".
"AND `tblDocumentReviewers`.`required`='". $this->_id ."' ";
"AND `tblDocumentReviewers`.`required`='". $this->_id ."' ".
"ORDER BY `tblDocumentReviewLog`.`reviewLogID` DESC";
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false)
return false;
return false;
if (count($resArr)>0) {
foreach ($resArr as $res)
$status[] = $res;

View File

@ -1727,25 +1727,33 @@ class SeedDMS_Core_User { /* {{{ */
function getReviewStatus($documentID=null, $version=null) { /* {{{ */
$db = $this->_dms->getDB();
if (!$db->createTemporaryTable("ttreviewid", true)) {
return false;
}
$status = array("indstatus"=>array(), "grpstatus"=>array());
// See if the user is assigned as an individual reviewer.
/* FIXME: See query of getRevisionStatus() because it also restricts on
* latest version. This may be needed here too.
*/
// Attention: this method didn't use ttreviewid to filter out the latest
// log entry. This was added 2021-09-29 because $group->getReviewStatus()
// does it as well. The check below if the date is larger than the date
// of a previos entry is still required to just take the latest version
// of a document into account.
$queryStr = "SELECT `tblDocumentReviewers`.*, `tblDocumentReviewLog`.`status`, ".
"`tblDocumentReviewLog`.`comment`, `tblDocumentReviewLog`.`date`, ".
"`tblDocumentReviewLog`.`userID` ".
"FROM `tblDocumentReviewers` ".
"LEFT JOIN `tblDocumentReviewLog` USING (`reviewID`) ".
"WHERE `tblDocumentReviewers`.`type`='0' ".
"LEFT JOIN `ttreviewid` on `ttreviewid`.`maxLogID` = `tblDocumentReviewLog`.`reviewLogID` ".
"WHERE `ttreviewid`.`maxLogID`=`tblDocumentReviewLog`.`reviewLogID` ".
($documentID==null ? "" : "AND `tblDocumentReviewers`.`documentID` = '". (int) $documentID ."' ").
($version==null ? "" : "AND `tblDocumentReviewers`.`version` = '". (int) $version ."' ").
"AND `tblDocumentReviewers`.`type`='0' ".
"AND `tblDocumentReviewers`.`required`='". $this->_id ."' ".
"ORDER BY `tblDocumentReviewLog`.`reviewLogID` DESC";
$resArr = $db->getResultArray($queryStr);
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr === false)
return false;
return false;
if (count($resArr)>0) {
foreach ($resArr as $res) {
if(isset($status["indstatus"][$res['documentID']])) {
@ -1756,7 +1764,7 @@ class SeedDMS_Core_User { /* {{{ */
$status["indstatus"][$res['documentID']] = $res;
}
}
}
}
// See if the user is the member of a group that has been assigned to
// review the document version.
@ -1765,10 +1773,12 @@ class SeedDMS_Core_User { /* {{{ */
"`tblDocumentReviewLog`.`userID` ".
"FROM `tblDocumentReviewers` ".
"LEFT JOIN `tblDocumentReviewLog` USING (`reviewID`) ".
"LEFT JOIN `ttreviewid` on `ttreviewid`.`maxLogID` = `tblDocumentReviewLog`.`reviewLogID` ".
"LEFT JOIN `tblGroupMembers` ON `tblGroupMembers`.`groupID` = `tblDocumentReviewers`.`required` ".
"WHERE `tblDocumentReviewers`.`type`='1' ".
"WHERE `ttreviewid`.`maxLogID`=`tblDocumentReviewLog`.`reviewLogID` ".
($documentID==null ? "" : "AND `tblDocumentReviewers`.`documentID` = '". (int) $documentID ."' ").
($version==null ? "" : "AND `tblDocumentReviewers`.`version` = '". (int) $version ."' ").
"AND `tblDocumentReviewers`.`type`='1' ".
"AND `tblGroupMembers`.`userID`='". $this->_id ."' ".
"ORDER BY `tblDocumentReviewLog`.`reviewLogID` DESC";
$resArr = $db->getResultArray($queryStr);
@ -1823,19 +1833,29 @@ class SeedDMS_Core_User { /* {{{ */
function getApprovalStatus($documentID=null, $version=null) { /* {{{ */
$db = $this->_dms->getDB();
if (!$db->createTemporaryTable("ttapproveid")) {
return false;
}
$status = array("indstatus"=>array(), "grpstatus"=>array());
/* FIXME: See query of getRevisionStatus() because it also restricts on
* latest version. This may be needed here too.
*/
// See if the user is assigned as an individual approver.
// Attention: this method didn't use ttapproveid to filter out the latest
// log entry. This was added 2021-09-29 because $group->getApprovalStatus()
// does it as well. The check below if the date is larger than the date
// of a previos entry is still required to just take the latest version
// of a document into account.
$queryStr =
"SELECT `tblDocumentApprovers`.*, `tblDocumentApproveLog`.`status`, ".
"`tblDocumentApproveLog`.`comment`, `tblDocumentApproveLog`.`date`, ".
"`tblDocumentApproveLog`.`userID` ".
"FROM `tblDocumentApprovers` ".
"LEFT JOIN `tblDocumentApproveLog` USING (`approveID`) ".
"WHERE `tblDocumentApprovers`.`type`='0' ".
"LEFT JOIN `ttapproveid` on `ttapproveid`.`maxLogID` = `tblDocumentApproveLog`.`approveLogID` ".
"WHERE `ttapproveid`.`maxLogID`=`tblDocumentApproveLog`.`approveLogID` ".
($documentID==null ? "" : "AND `tblDocumentApprovers`.`documentID` = '". (int) $documentID ."' ").
($version==null ? "" : "AND `tblDocumentApprovers`.`version` = '". (int) $version ."' ").
"AND `tblDocumentApprovers`.`type`='0' ".
"AND `tblDocumentApprovers`.`required`='". $this->_id ."' ".
"ORDER BY `tblDocumentApproveLog`.`approveLogID` DESC";
@ -1862,10 +1882,12 @@ class SeedDMS_Core_User { /* {{{ */
"`tblDocumentApproveLog`.`userID` ".
"FROM `tblDocumentApprovers` ".
"LEFT JOIN `tblDocumentApproveLog` USING (`approveID`) ".
"LEFT JOIN `ttapproveid` on `ttapproveid`.`maxLogID` = `tblDocumentApproveLog`.`approveLogID` ".
"LEFT JOIN `tblGroupMembers` ON `tblGroupMembers`.`groupID` = `tblDocumentApprovers`.`required` ".
"WHERE `tblDocumentApprovers`.`type`='1' ".
"WHERE `ttapproveid`.`maxLogID`=`tblDocumentApproveLog`.`approveLogID` ".
($documentID==null ? "" : "AND `tblDocumentApprovers`.`documentID` = '". (int) $documentID ."' ").
($version==null ? "" : "AND `tblDocumentApprovers`.`version` = '". (int) $version ."' ").
"AND `tblDocumentApprovers`.`type`='1' ".
"AND `tblGroupMembers`.`userID`='". $this->_id ."' ".
"ORDER BY `tblDocumentApproveLog`.`approveLogID` DESC";
$resArr = $db->getResultArray($queryStr);

View File

@ -532,14 +532,14 @@ class SeedDMS_Core_DatabaseAccess {
"GROUP BY `tblDocumentReviewLog`.`reviewID` "; //.
// "ORDER BY `maxLogID`";
}
if (!$this->_ttreviewid) {
if (!$this->_ttreviewid) {
if (!$this->getResult($queryStr))
return false;
$this->_ttreviewid=true;
}
else {
if (is_bool($override) && $override) {
if (!$this->getResult("DELETE FROM `ttreviewid`"))
if (is_bool($override) && $override) {
if (!$this->getResult("DROP TABLE IF EXISTS `ttreviewid`"))
return false;
if (!$this->getResult($queryStr))
return false;
@ -580,7 +580,7 @@ class SeedDMS_Core_DatabaseAccess {
}
else {
if (is_bool($override) && $override) {
if (!$this->getResult("DELETE FROM `ttapproveid`"))
if (!$this->getResult("DROP TABLE IF NOT EXISTS `ttapproveid`"))
return false;
if (!$this->getResult($queryStr))
return false;
@ -621,7 +621,7 @@ class SeedDMS_Core_DatabaseAccess {
}
else {
if (is_bool($override) && $override) {
if (!$this->getResult("DELETE FROM `ttstatid`"))
if (!$this->getResult("DROP TABLE IF NOT EXISTS `ttstatid`"))
return false;
if (!$this->getResult($queryStr))
return false;
@ -662,7 +662,7 @@ class SeedDMS_Core_DatabaseAccess {
}
else {
if (is_bool($override) && $override) {
if (!$this->getResult("DELETE FROM `ttcontentid`"))
if (!$this->getResult("DROP TABLE IF NOT EXISTS `ttcontentid`"))
return false;
if (!$this->getResult($queryStr))
return false;
@ -755,11 +755,44 @@ class SeedDMS_Core_DatabaseAccess {
return false;
} /* }}} */
/**
* Drop various temporary tables to enforce recreation when needed
*
* @param string $tableName
*
* @return bool
*/
private function __dropTemporaryTable($tableName) { /* {{{ */
$queryStr = '';
if (!strcasecmp($tableName, "ttreviewid")) {
$queryStr = "DROP TABLE IF EXISTS `ttreviewid`";
}
elseif (!strcasecmp($tableName, "ttapproveid")) {
$queryStr = "DROP TABLE IF EXISTS `ttapproveid`";
}
elseif (!strcasecmp($tableName, "ttstatid")) {
$queryStr = "DROP TABLE IF EXISTS `ttstatid`";
}
elseif (!strcasecmp($tableName, "ttcontentid")) {
$queryStr = "DROP TABLE IF EXISTS `ttcontentid`";
}
if($queryStr) {
if (!$this->getResult($queryStr))
return false;
else {
$this->{'_'.$tableName} = false;
return true;
}
}
return false;
} /* }}} */
/**
* Create various views to speed up and simplify sql queries
*
* @param string $tableName
* @param bool $override
*
* @return bool
*/
private function __createView($tableName, $override=false) { /* {{{ */
@ -1001,7 +1034,8 @@ class SeedDMS_Core_DatabaseAccess {
* Create various temporary tables or view to speed up and simplify sql queries
*
* @param string $tableName
* @param bool $override
* @param bool $override
*
* @return bool
*/
public function createTemporaryTable($tableName, $override=false) { /* {{{ */
@ -1011,6 +1045,20 @@ class SeedDMS_Core_DatabaseAccess {
return $this->__createTemporaryTable($tableName, $override);
} /* }}} */
/**
* Drop various temporary tables to force recreation when next time needed
*
* @param string $tableName
*
* @return bool
*/
public function dropTemporaryTable($tableName) { /* {{{ */
if($this->_useviews)
return true; // No need to recreate a view
else
return $this->__dropTemporaryTable($tableName);
} /* }}} */
/**
* Return sql statement for extracting the date part from a field
* containing a unix timestamp

View File

@ -44,13 +44,15 @@ class SeedDMS_Controller_ApproveDocument extends SeedDMS_Controller_Common {
$result = $this->callHook('approveDocument', $content);
if($result === null) {
if ($approvaltype == "ind") {
if(0 > $content->setApprovalByInd($user, $user, $approvalstatus, $comment, $file)) {
$approvalLogID = $content->setApprovalByInd($user, $user, $approvalstatus, $comment, $file);
if($approvalLogID === false || 0 > $approvalLogID) {
$this->error = 1;
$this->errormsg = "approval_update_failed";
return false;
}
} elseif ($approvaltype == "grp") {
if(0 > $content->setApprovalByGrp($group, $user, $approvalstatus, $comment, $file)) {
$approvalLogID = $content->setApprovalByGrp($group, $user, $approvalstatus, $comment, $file);
if($approvalLogID === false || 0 > $approvalLogID) {
$this->error = 1;
$this->errormsg = "approval_update_failed";
return false;

View File

@ -45,13 +45,15 @@ class SeedDMS_Controller_ReviewDocument extends SeedDMS_Controller_Common {
if($result === null) {
if ($reviewtype == "ind") {
if(0 > $content->setReviewByInd($user, $user, $reviewstatus, $comment, $file)) {
$reviewLogID > $content->setReviewByInd($user, $user, $reviewstatus, $comment, $file);
if($reviewLogID === false || 0 > $reviewLogID) {
$this->error = 1;
$this->errormsg = "review_update_failed";
return false;
}
} elseif ($reviewtype == "grp") {
if(0 > $content->setReviewByGrp($group, $user, $reviewstatus, $comment, $file)) {
$reviewLogID = $content->setReviewByGrp($group, $user, $reviewstatus, $comment, $file);
if($reviewLogID === false || 0 > $reviewLogID) {
$this->error = 1;
$this->errormsg = "review_update_failed";
return false;

View File

@ -1103,9 +1103,9 @@ class SeedDMS_NotificationService {
$params['version'] = $content->getVersion();
$params['comment'] = $content->getComment();
$params['username'] = $user->getFullName();
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$params['sitename'] = $this->settings->_siteName;
$params['http_root'] = $this->settings->_httpRoot;
if($approver->isType('user'))
$this->toIndividual($user, $approver, $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER);
@ -1133,9 +1133,9 @@ class SeedDMS_NotificationService {
$params['version'] = $content->getVersion();
$params['comment'] = $content->getComment();
$params['username'] = $user->getFullName();
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$params['sitename'] = $this->settings->_siteName;
$params['http_root'] = $this->settings->_httpRoot;
if($reviewer->isType('user'))
$this->toIndividual($user, $reviewer, $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER);

View File

@ -93,7 +93,7 @@ if($approveStatus['type'] == 0) {
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("invalid_approveid"));
$comment = $_POST["comment"];
if(0 == $latestContent->removeApproval($approveid, $user, $comment)) {
if(true === $latestContent->removeApproval($approveid, $user, $comment)) {
$latestContent->verifyStatus(true, $user, $msg);
}
header("Location:../out/out.ViewDocument.php?documentid=".$documentid."&currenttab=revapp");

View File

@ -94,7 +94,7 @@ if($reviewStatus['type'] == 0) {
$comment = $_POST["comment"];
$overallStatus = $latestContent->getStatus();
if(0 == $latestContent->removeReview($reviewid, $user, $comment)) {
if(true === $latestContent->removeReview($reviewid, $user, $comment)) {
$latestContent->verifyStatus(true, $user, $msg);
if($notifier) {
$notifier->sendReviewRequestMail($latestContent, $user);

View File

@ -139,8 +139,8 @@ foreach ($pIndRev as $p) {
// Proposed reviewer is not a current reviewer, so add as a new
// reviewer.
$res = $content->addIndReviewer($docAccess["users"][$accessIndex["i"][$p]], $user);
switch ($res) {
case 0:
switch (true) {
case $res > 0:
// Send an email notification to the new reviewer.
if($settings->_enableNotificationAppRev) {
if ($notifier) {
@ -148,18 +148,16 @@ foreach ($pIndRev as $p) {
}
}
break;
case -1:
case $res === -1:
case $res === false:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));
break;
case -2:
case $res === -2:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
break;
case -3:
case $res === -3:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("reviewer_already_assigned"));
break;
case -4:
// email error
break;
}
}
else {
@ -193,8 +191,8 @@ if (count($reviewIndex["i"]) > 0) {
}
else {
$res = $content->delIndReviewer($docAccess["users"][$accessIndex["i"][$rx]], $user);
switch ($res) {
case 0:
switch (true) {
case $res === 0:
// Send an email notification to the reviewer.
if($settings->_enableNotificationAppRev) {
if ($notifier) {
@ -202,18 +200,16 @@ if (count($reviewIndex["i"]) > 0) {
}
}
break;
case -1:
case $res === -1:
case $res === false:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));
break;
case -2:
case $res === -2:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
break;
case -3:
case $res === -3:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("reviewer_already_removed"));
break;
case -4:
// email error
break;
}
}
}
@ -227,8 +223,8 @@ foreach ($pGrpRev as $p) {
// Proposed reviewer is not a current reviewer, so add as a new
// reviewer.
$res = $content->addGrpReviewer($docAccess["groups"][$accessIndex["g"][$p]], $user);
switch ($res) {
case 0:
switch (true) {
case $res > 0:
// Send an email notification to the new reviewer.
if($settings->_enableNotificationAppRev) {
if ($notifier) {
@ -236,18 +232,16 @@ foreach ($pGrpRev as $p) {
}
}
break;
case -1:
case $res === -1:
case $res === false:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));
break;
case -2:
case $res === -2:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
break;
case -3:
case $res === -3:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("reviewer_already_assigned"));
break;
case -4:
// email error
break;
}
}
else {
@ -273,8 +267,8 @@ if (count($reviewIndex["g"]) > 0) {
}
else {
$res = $content->delGrpReviewer($docAccess["groups"][$accessIndex["g"][$rx]], $user);
switch ($res) {
case 0:
switch (true) {
case $res === 0:
// Send an email notification to the review group.
if($settings->_enableNotificationAppRev) {
if ($notifier) {
@ -282,18 +276,16 @@ if (count($reviewIndex["g"]) > 0) {
}
}
break;
case -1:
case $res === -1:
case $res === false:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));
break;
case -2:
case $res === -2:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
break;
case -3:
case $res === -3:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("reviewer_already_removed"));
break;
case -4:
// email error
break;
}
}
}
@ -335,8 +327,8 @@ foreach ($pIndApp as $p) {
// Proposed approver is not a current approver, so add as a new
// approver.
$res = $content->addIndApprover($docAccess["users"][$accessIndex["i"][$p]], $user);
switch ($res) {
case 0:
switch (true) {
case $res > 0:
// Send an email notification to the new approver.
if($settings->_enableNotificationAppRev) {
/* Send notification only if document is currently not in review state,
@ -348,18 +340,16 @@ foreach ($pIndApp as $p) {
}
}
break;
case -1:
case $res === -1:
case $res === false:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));
break;
case -2:
case $res === -2:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
break;
case -3:
case $res === -3:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("reviewer_already_assigned"));
break;
case -4:
// email error
break;
}
}
else {
@ -385,8 +375,8 @@ if (count($approvalIndex["i"]) > 0) {
}
else {
$res = $content->delIndApprover($docAccess["users"][$accessIndex["i"][$rx]], $user);
switch ($res) {
case 0:
switch (true) {
case $res === 0:
// Send an email notification to the approver.
if($settings->_enableNotificationAppRev) {
if ($notifier) {
@ -394,18 +384,16 @@ if (count($approvalIndex["i"]) > 0) {
}
}
break;
case -1:
case $res === -1:
case $res === false:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));
break;
case -2:
case $res === -2:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
break;
case -3:
case $res === -3:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("reviewer_already_removed"));
break;
case -4:
// email error
break;
}
}
}
@ -419,8 +407,8 @@ foreach ($pGrpApp as $p) {
// Proposed approver is not a current approver, so add as a new
// approver.
$res = $content->addGrpApprover($docAccess["groups"][$accessIndex["g"][$p]], $user);
switch ($res) {
case 0:
switch (true) {
case $res > 0:
// Send an email notification to the new approver.
if($settings->_enableNotificationAppRev) {
/* Send notification only if document is currently not in review state,
@ -432,18 +420,16 @@ foreach ($pGrpApp as $p) {
}
}
break;
case -1:
case $res === -1:
case $res === false:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));
break;
case -2:
case $res === -2:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
break;
case -3:
case $res === -3:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("approver_already_assigned"));
break;
case -4:
// email error
break;
}
}
else {
@ -469,8 +455,8 @@ if (count($approvalIndex["g"]) > 0) {
}
else {
$res = $content->delGrpApprover($docAccess["groups"][$accessIndex["g"][$rx]], $user);
switch ($res) {
case 0:
switch (true) {
case $res === 0:
// Send an email notification to the approval group.
if($settings->_enableNotificationAppRev) {
if ($notifier) {
@ -478,18 +464,16 @@ if (count($approvalIndex["g"]) > 0) {
}
}
break;
case -1:
case $res === -1:
case $res === false:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));
break;
case -2:
case $res === -2:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
break;
case -3:
case $res === -3:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("approver_already_removed"));
break;
case -4:
// email error
break;
}
}
}

View File

@ -126,6 +126,7 @@ class SeedDMS_View_ApprovalSummary extends SeedDMS_Theme_Style {
$version = $document->getContentByVersion($st['version']);
$modgroup = $dms->getGroup($st['required']);
/* Filter out those documents which already require an approval as an individual */
if (!in_array($st["documentID"], $iRev) && $document && $version) {
if ($printheader){

View File

@ -128,6 +128,7 @@ class SeedDMS_View_ReviewSummary extends SeedDMS_Theme_Style {
$version = $document->getContentByVersion($st['version']);
$modgroup = $dms->getGroup($st['required']);
/* Filter out those documents which already require a review as an individual */
if (!in_array($st["documentID"], $iRev) && $document && $version) {
if ($printheader){