mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-13 21:21:27 +00:00
move checkForDueRevisionWorkflow() into document version
This commit is contained in:
parent
a7deac7948
commit
2c7ab1cfb1
|
@ -898,14 +898,10 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
/**
|
/**
|
||||||
* Check if latest content of the document has a scheduled
|
* Check if latest content of the document has a scheduled
|
||||||
* revision workflow.
|
* 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
|
* This method was moved into SeedDMS_Core_DocumentContent and
|
||||||
* if all revisors have been removed, it will still start the revision workflow!
|
* the original method in SeedDMS_Core_Document now uses it for
|
||||||
* NOTE: This seems not the case anymore. The status of each revision is
|
* the latest version.
|
||||||
* 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 object $user user requesting the possible automatic change
|
||||||
* @param string $next next date for review
|
* @param string $next next date for review
|
||||||
|
@ -914,39 +910,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
|
||||||
function checkForDueRevisionWorkflow($user, $next=''){ /* {{{ */
|
function checkForDueRevisionWorkflow($user, $next=''){ /* {{{ */
|
||||||
$lc=$this->getLatestContent();
|
$lc=$this->getLatestContent();
|
||||||
if($lc) {
|
if($lc) {
|
||||||
$st=$lc->getStatus();
|
return $lc->checkForDueRevisionWorkflow($user, $next);
|
||||||
|
|
||||||
/* 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 false;
|
return false;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
@ -4503,6 +4467,58 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
||||||
return true;
|
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) { /* {{{ */
|
function addIndReviewer($user, $requestUser) { /* {{{ */
|
||||||
$db = $this->_document->getDMS()->getDB();
|
$db = $this->_document->getDMS()->getDB();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user