mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-10-09 10:32:40 +00:00
add method rewriteRevisionLog()
This commit is contained in:
parent
ee4215f89e
commit
43b613c210
|
@ -3716,6 +3716,77 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
return $this->_revisionStatus;
|
return $this->_revisionStatus;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rewrites the complete revision log
|
||||||
|
*
|
||||||
|
* Attention: this function is highly dangerous.
|
||||||
|
* It removes an existing receipt log and rewrites it.
|
||||||
|
* This method was added for importing an xml dump.
|
||||||
|
*
|
||||||
|
* @param array $revisionlog new status log with the newest log entry first.
|
||||||
|
* @return boolean true on success, otherwise false
|
||||||
|
*/
|
||||||
|
function rewriteRevisionLog($revisions) { /* {{{ */
|
||||||
|
$db = $this->_document->_dms->getDB();
|
||||||
|
|
||||||
|
$queryStr= "SELECT `tblDocumentRevisors`.* FROM `tblDocumentRevisors` WHERE `tblDocumentRevisors`.`documentID` = '". $this->_document->getID() ."' AND `tblDocumentRevisors`.`version` = '". $this->_version ."' ";
|
||||||
|
$res = $db->getResultArray($queryStr);
|
||||||
|
if (is_bool($res) && !$res)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
$db->startTransaction();
|
||||||
|
|
||||||
|
if($res) {
|
||||||
|
foreach($res as $revision) {
|
||||||
|
$revisionID = $revision['revisionID'];
|
||||||
|
|
||||||
|
/* First, remove the old entries */
|
||||||
|
$queryStr = "DELETE from `tblDocumentRevisionLog` where `revisionID`=".$revisionID;
|
||||||
|
if (!$db->getResult($queryStr)) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$queryStr = "DELETE from `tblDocumentRevisors` where `revisionID`=".$revisionID;
|
||||||
|
if (!$db->getResult($queryStr)) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Second, insert the new entries */
|
||||||
|
foreach($revisions as $revision) {
|
||||||
|
$queryStr = "INSERT INTO `tblDocumentRevisors` (`documentID`, `version`, `type`, `required`) ".
|
||||||
|
"VALUES ('".$this->_document->getID()."', '".$this->_version."', ".$revision['type'] .", ".(is_object($revision['required']) ? $revision['required']->getID() : (int) $revision['required']).")";
|
||||||
|
if (!$db->getResult($queryStr)) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$revisionID = $db->getInsertID('tblDocumentRevisors', 'revisionID');
|
||||||
|
$revisionlog = array_reverse($revision['logs']);
|
||||||
|
foreach($revisionlog as $log) {
|
||||||
|
if(!SeedDMS_Core_DMS::checkDate($log['date'], 'Y-m-d H:i:s')) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$queryStr = "INSERT INTO `tblDocumentRevisionLog` (`revisionID`, `status`, `comment`, `date`, `userID`) ".
|
||||||
|
"VALUES ('".$revisionID ."', '".(int) $log['status']."', ".$db->qstr($log['comment']) .", ".$db->qstr($log['date']).", ".(is_object($log['user']) ? $log['user']->getID() : (int) $log['user']).")";
|
||||||
|
if (!$db->getResult($queryStr)) {
|
||||||
|
$db->rollbackTransaction();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$revisionLogID = $db->getInsertID('tblDocumentRevisionLog', 'revisionLogID');
|
||||||
|
if(!empty($log['file'])) {
|
||||||
|
SeedDMS_Core_File::copyFile($log['file'], $this->_dms->contentDir . $this->_document->getDir() . 'r' . $revisionLogID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->commitTransaction();
|
||||||
|
return true;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
function addIndReviewer($user, $requestUser) { /* {{{ */
|
function addIndReviewer($user, $requestUser) { /* {{{ */
|
||||||
$db = $this->_document->_dms->getDB();
|
$db = $this->_document->_dms->getDB();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user