move checkForDueRevisionWorkflow() into document version

This commit is contained in:
Uwe Steinmann 2021-04-28 14:24:40 +02:00
parent a7deac7948
commit 2c7ab1cfb1

View File

@ -898,14 +898,10 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
/**
* Check if latest content of the document has a scheduled
* revision workflow.
* The method will update the document status log database table
* if needed and set the revisiondate of the content to $next.
*
* FIXME: This method does not check if there are any revisors left. Even
* if all revisors have been removed, it will still start the revision workflow!
* NOTE: This seems not the case anymore. The status of each revision is
* checked. Only if at least one status is S_LOG_SLEEPING the revision will be
* started. This wouldn't be the case if all revisors had been removed.
* This method was moved into SeedDMS_Core_DocumentContent and
* the original method in SeedDMS_Core_Document now uses it for
* the latest version.
*
* @param object $user user requesting the possible automatic change
* @param string $next next date for review
@ -914,39 +910,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
function checkForDueRevisionWorkflow($user, $next=''){ /* {{{ */
$lc=$this->getLatestContent();
if($lc) {
$st=$lc->getStatus();
/* A revision workflow will only be started if the document is released */
if($st["status"] == S_RELEASED) {
/* First check if there are any scheduled revisions currently sleeping */
$pendingRevision=false;
unset($this->_revisionStatus); // force to be reloaded from DB
$revisionStatus=$lc->getRevisionStatus();
if (is_array($revisionStatus) && count($revisionStatus)>0) {
foreach ($revisionStatus as $a){
if ($a["status"]==S_LOG_SLEEPING || $a["status"]==S_LOG_SLEEPING){
$pendingRevision=true;
break;
}
}
}
if(!$pendingRevision)
return false;
/* We have sleeping revision, next check if the revision is already due */
if($lc->getRevisionDate() && $lc->getRevisionDate() <= date('Y-m-d 00:00:00')) {
if($lc->startRevision($user, 'Automatic start of revision workflow scheduled for '.$lc->getRevisionDate())) {
if($next) {
$tmp = explode('-', substr($next, 0, 10));
if(checkdate($tmp[1], $tmp[2], $tmp[0]))
$lc->setRevisionDate($next);
} else {
$lc->setRevisionDate(false);
}
return true;
}
}
}
return $lc->checkForDueRevisionWorkflow($user, $next);
}
return false;
} /* }}} */
@ -4503,6 +4467,58 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
return true;
} /* }}} */
/**
* Check if document version has a scheduled revision workflow.
* The method will update the document status log database table
* if needed and set the revisiondate of the content to $next.
*
* FIXME: This method does not check if there are any revisors left. Even
* if all revisors have been removed, it will still start the revision workflow!
* NOTE: This seems not the case anymore. The status of each revision is
* checked. Only if at least one status is S_LOG_SLEEPING the revision will be
* started. This wouldn't be the case if all revisors had been removed.
*
* @param object $user user requesting the possible automatic change
* @param string $next next date for review
* @return boolean true if status has changed
*/
function checkForDueRevisionWorkflow($user, $next=''){ /* {{{ */
$st=$this->getStatus();
/* A revision workflow will only be started if the document version is released */
if($st["status"] == S_RELEASED) {
/* First check if there are any scheduled revisions currently sleeping */
$pendingRevision=false;
unset($this->_revisionStatus); // force to be reloaded from DB
$revisionStatus=$this->getRevisionStatus();
if (is_array($revisionStatus) && count($revisionStatus)>0) {
foreach ($revisionStatus as $a){
if ($a["status"]==S_LOG_SLEEPING || $a["status"]==S_LOG_SLEEPING){
$pendingRevision=true;
break;
}
}
}
if(!$pendingRevision)
return false;
/* We have sleeping revision, next check if the revision is already due */
if($this->getRevisionDate() && $this->getRevisionDate() <= date('Y-m-d 00:00:00')) {
if($this->startRevision($user, 'Automatic start of revision workflow scheduled for '.$this->getRevisionDate())) {
if($next) {
$tmp = explode('-', substr($next, 0, 10));
if(checkdate($tmp[1], $tmp[2], $tmp[0]))
$this->setRevisionDate($next);
} else {
$this->setRevisionDate(false);
}
return true;
}
}
}
return false;
} /* }}} */
function addIndReviewer($user, $requestUser) { /* {{{ */
$db = $this->_document->getDMS()->getDB();