add new method removeApproval()

This commit is contained in:
Uwe Steinmann 2021-07-02 08:32:18 +02:00
parent f28153497e
commit 2c4dc73be3
2 changed files with 48 additions and 0 deletions

View File

@ -4194,6 +4194,53 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
return $approveLogID;
} /* }}} */
/**
* 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.
*
* 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
*/
public function removeApproval($approveid, $requestUser, $comment='') { /* {{{ */
$db = $this->_document->getDMS()->getDB();
// Check to see if the user can be removed from the approval list.
$approvals = $this->getApprovalStatus();
if (is_bool($approvals) && !$approvals) {
return -1;
}
$approvalStatus = null;
foreach($approvals as $approval) {
if($approval['approveID'] == $approveid) {
$approvalStatus = $approval;
break;
}
}
if(!$approvalStatus)
return -2;
// The approval log entry may only be removed if the status is 1 or -1
if ($approvalStatus["status"] != 1 && $approvalStatus["status"] != -1)
return -3;
$queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`,
`comment`, `date`, `userID`) ".
"VALUES ('". $approvalStatus["approveID"] ."', '0', ".$db->qstr($comment).", ".$db->getCurrentDatetime().", '".
$requestUser->getID() ."')";
$res=$db->getResult($queryStr);
if (is_bool($res) && !$res)
return -1;
return 0;
} /* }}} */
/**
* Sets approval status of a document content for a group
* The functions behaves like

View File

@ -31,6 +31,7 @@
- fix checking of email addresses by using filter_var instead of regex
- add new method SeedDMS_Core_Document::hasCategory()
- add new method SeedDMS_Core_DocumentContent::removeReview()
- add new method SeedDMS_Core_DocumentContent::removeApproval()
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">