add new method SeedDMS_Core_DocumentContent::removeReview()

This commit is contained in:
Uwe Steinmann 2021-07-01 11:44:49 +02:00
parent 189f962012
commit 0cd9910c25
2 changed files with 48 additions and 0 deletions

View File

@ -3925,6 +3925,53 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
return $reviewLogID;
} /* }}} */
/**
* Add another entry to review 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 removeReview($reviewid, $requestUser, $comment='') { /* {{{ */
$db = $this->_document->getDMS()->getDB();
// Check to see if the user can be removed from the review list.
$reviews = $this->getReviewStatus();
if (is_bool($reviews) && !$reviews) {
return -1;
}
$reviewStatus = null;
foreach($reviews as $review) {
if($review['reviewID'] == $reviewid) {
$reviewStatus = $review;
break;
}
}
if(!$reviewStatus)
return -2;
// The review log entry may only be removed if the status is 1 or -1
if ($reviewStatus["status"] != 1 && $reviewStatus["status"] != -1)
return -3;
$queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`,
`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 0;
} /* }}} */
/**
* Add a review to the document content
*

View File

@ -30,6 +30,7 @@
- better handling of document with an empty workflow state
- 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()
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">