mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-12 04:31:32 +00:00
add methods to rewrite approval and review log
This commit is contained in:
parent
1200460cee
commit
bc1eecc08c
|
@ -315,8 +315,12 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
|
|
||||||
if(!$date)
|
if(!$date)
|
||||||
$date = time();
|
$date = time();
|
||||||
|
else {
|
||||||
|
if(!is_numeric($date))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$queryStr = "UPDATE tblDocuments SET date = " . $date . " WHERE id = ". $this->_id;
|
$queryStr = "UPDATE tblDocuments SET date = " . (int) $date . " WHERE id = ". $this->_id;
|
||||||
if (!$db->getResult($queryStr))
|
if (!$db->getResult($queryStr))
|
||||||
return false;
|
return false;
|
||||||
$this->_date = $date;
|
$this->_date = $date;
|
||||||
|
@ -2611,6 +2615,73 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
return $this->_reviewStatus;
|
return $this->_reviewStatus;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rewrites the complete review log
|
||||||
|
*
|
||||||
|
* Attention: this function is highly dangerous.
|
||||||
|
* It removes an existing review log and rewrites it.
|
||||||
|
* This method was added for importing an xml dump.
|
||||||
|
*
|
||||||
|
* @param array $reviewlog new status log with the newest log entry first.
|
||||||
|
* @return boolean true on success, otherwise false
|
||||||
|
*/
|
||||||
|
function rewriteReviewLog($reviewers) { /* {{{ */
|
||||||
|
$db = $this->_document->_dms->getDB();
|
||||||
|
|
||||||
|
$queryStr= "SELECT `tblDocumentReviewers`.* FROM `tblDocumentReviewers` WHERE `tblDocumentReviewers`.`documentID` = '". $this->_document->getID() ."' AND `tblDocumentReviewers`.`version` = '". $this->_version ."' ";
|
||||||
|
$res = $db->getResultArray($queryStr);
|
||||||
|
if (is_bool($res) && !$res)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$db->startTransaction();
|
||||||
|
|
||||||
|
if($res) {
|
||||||
|
foreach($res as $review) {
|
||||||
|
$reviewID = $review['reviewID'];
|
||||||
|
|
||||||
|
/* First, remove the old entries */
|
||||||
|
$queryStr = "DELETE from `tblDocumentReviewLog` where `reviewID`=".$reviewID;
|
||||||
|
if (!$db->getResult($queryStr)) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$queryStr = "DELETE from `tblDocumentReviewers` where `reviewID`=".$reviewID;
|
||||||
|
if (!$db->getResult($queryStr)) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Second, insert the new entries */
|
||||||
|
foreach($reviewers as $review) {
|
||||||
|
$queryStr = "INSERT INTO `tblDocumentReviewers` (`documentID`, `version`, `type`, `required`) ".
|
||||||
|
"VALUES ('".$this->_document->getID()."', '".$this->_version."', ".$review['type'] .", ".$review['required']->getID().")";
|
||||||
|
if (!$db->getResult($queryStr)) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$reviewID = $db->getInsertID();
|
||||||
|
$reviewlog = array_reverse($review['logs']);
|
||||||
|
foreach($reviewlog as $log) {
|
||||||
|
if(!SeedDMS_Core_DMS::checkDate($log['date'], 'Y-m-d H:i:s')) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$queryStr = "INSERT INTO `tblDocumentReviewLog` (`reviewID`, `status`, `comment`, `date`, `userID`) ".
|
||||||
|
"VALUES ('".$reviewID ."', '".(int) $log['status']."', ".$db->qstr($log['comment']) .", ".$db->qstr($log['date']).", ".$log['user']->getID().")";
|
||||||
|
if (!$db->getResult($queryStr)) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->commitTransaction();
|
||||||
|
return true;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current approval status of the document content
|
* Get the current approval status of the document content
|
||||||
* The approval status is a list of approvals and its current status
|
* The approval status is a list of approvals and its current status
|
||||||
|
@ -2668,6 +2739,73 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
return $this->_approvalStatus;
|
return $this->_approvalStatus;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rewrites the complete approval log
|
||||||
|
*
|
||||||
|
* Attention: this function is highly dangerous.
|
||||||
|
* It removes an existing review log and rewrites it.
|
||||||
|
* This method was added for importing an xml dump.
|
||||||
|
*
|
||||||
|
* @param array $reviewlog new status log with the newest log entry first.
|
||||||
|
* @return boolean true on success, otherwise false
|
||||||
|
*/
|
||||||
|
function rewriteApprovalLog($reviewers) { /* {{{ */
|
||||||
|
$db = $this->_document->_dms->getDB();
|
||||||
|
|
||||||
|
$queryStr= "SELECT `tblDocumentApprovers`.* FROM `tblDocumentApprovers` WHERE `tblDocumentApprovers`.`documentID` = '". $this->_document->getID() ."' AND `tblDocumentApprovers`.`version` = '". $this->_version ."' ";
|
||||||
|
$res = $db->getResultArray($queryStr);
|
||||||
|
if (is_bool($res) && !$res)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$db->startTransaction();
|
||||||
|
|
||||||
|
if($res) {
|
||||||
|
foreach($res as $review) {
|
||||||
|
$reviewID = $review['reviewID'];
|
||||||
|
|
||||||
|
/* First, remove the old entries */
|
||||||
|
$queryStr = "DELETE from `tblDocumentApproveLog` where `approveID`=".$reviewID;
|
||||||
|
if (!$db->getResult($queryStr)) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$queryStr = "DELETE from `tblDocumentApprovers` where `approveID`=".$reviewID;
|
||||||
|
if (!$db->getResult($queryStr)) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Second, insert the new entries */
|
||||||
|
foreach($reviewers as $review) {
|
||||||
|
$queryStr = "INSERT INTO `tblDocumentApprovers` (`documentID`, `version`, `type`, `required`) ".
|
||||||
|
"VALUES ('".$this->_document->getID()."', '".$this->_version."', ".$review['type'] .", ".$review['required']->getID().")";
|
||||||
|
if (!$db->getResult($queryStr)) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$reviewID = $db->getInsertID();
|
||||||
|
$reviewlog = array_reverse($review['logs']);
|
||||||
|
foreach($reviewlog as $log) {
|
||||||
|
if(!SeedDMS_Core_DMS::checkDate($log['date'], 'Y-m-d H:i:s')) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$queryStr = "INSERT INTO `tblDocumentApproveLog` (`approveID`, `status`, `comment`, `date`, `userID`) ".
|
||||||
|
"VALUES ('".$reviewID ."', '".(int) $log['status']."', ".$db->qstr($log['comment']) .", ".$db->qstr($log['date']).", ".$log['user']->getID().")";
|
||||||
|
if (!$db->getResult($queryStr)) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->commitTransaction();
|
||||||
|
return true;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
function addIndReviewer($user, $requestUser, $listadmin=false) { /* {{{ */
|
function addIndReviewer($user, $requestUser, $listadmin=false) { /* {{{ */
|
||||||
$db = $this->_document->_dms->getDB();
|
$db = $this->_document->_dms->getDB();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user