add new list type ´DueRevision' in getDocumentList()

This commit is contained in:
Uwe Steinmann 2019-02-14 12:33:11 +01:00
parent fa96dca929
commit feee5600c4

View File

@ -808,7 +808,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
} /* }}} */ } /* }}} */
/** /**
* Check if latest content of the document has a schedult * Check if latest content of the document has a scheduled
* revision workflow. * revision workflow.
* The method will update the document status log database table * The method will update the document status log database table
* if needed. * if needed.
@ -825,8 +825,9 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
if($lc) { if($lc) {
$st=$lc->getStatus(); $st=$lc->getStatus();
/* A revision workflow will only be started if the document is released */
if($st["status"] == S_RELEASED) { if($st["status"] == S_RELEASED) {
/* First check if there are any revisors left who need to revise */ /* First check if there are any scheduled revisions currently sleeping */
$pendingRevision=false; $pendingRevision=false;
unset($this->_revisionStatus); // force to be reloaded from DB unset($this->_revisionStatus); // force to be reloaded from DB
$revisionStatus=$lc->getRevisionStatus(); $revisionStatus=$lc->getRevisionStatus();
@ -841,7 +842,7 @@ class SeedDMS_Core_Document extends SeedDMS_Core_Object { /* {{{ */
if(!$pendingRevision) if(!$pendingRevision)
return false; return false;
/* Second check if revision is already due */ /* 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->getRevisionDate() && $lc->getRevisionDate() <= date('Y-m-d 00:00:00')) {
if($lc->startRevision($user, 'Automatic start of revision workflow')) { if($lc->startRevision($user, 'Automatic start of revision workflow')) {
if($next) { if($next) {
@ -3051,23 +3052,30 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
* This method will call {@see SeedDMS_Core_DocumentContent::setStatus()} * This method will call {@see SeedDMS_Core_DocumentContent::setStatus()}
* which checks if the state has actually changed. This is, why this * which checks if the state has actually changed. This is, why this
* function can be called at any time without harm to the status log. * function can be called at any time without harm to the status log.
* The $initialstatus can be set, to define the status set when no other
* status is set. This happens if the document has no
* *
* @param boolean $ignorecurrentstatus ignore the current status and * @param boolean $ignorecurrentstatus ignore the current status and
* recalculate a new status in any case * recalculate a new status in any case
* @param object $user the user initiating this method * @param object $user the user initiating this method
* @param string $msg message stored in status log when status is set * @param string $msg message stored in status log when status is set
* @param integer $initialstatus status to be set if no other status is set
*/ */
function verifyStatus($ignorecurrentstatus=false, $user=null, $msg='') { /* {{{ */ function verifyStatus($ignorecurrentstatus=false, $user=null, $msg='', $initialstatus=S_RELEASED) { /* {{{ */
unset($this->_status); unset($this->_status);
$st=$this->getStatus(); $st=$this->getStatus();
/* Documents already obsoleted, rejected or expired will not change
* its status anymore, unless explicitly requested.
*/
if (!$ignorecurrentstatus && ($st["status"]==S_OBSOLETE || $st["status"]==S_REJECTED || $st["status"]==S_EXPIRED )) return; if (!$ignorecurrentstatus && ($st["status"]==S_OBSOLETE || $st["status"]==S_REJECTED || $st["status"]==S_EXPIRED )) return;
unset($this->_workflow); // force to be reloaded from DB unset($this->_workflow); // force to be reloaded from DB
$hasworkflow = $this->getWorkflow() ? true : false; $hasworkflow = $this->getWorkflow() ? true : false;
$pendingReview=false; $pendingReview=false;
$hasReview=false;
unset($this->_reviewStatus); // force to be reloaded from DB unset($this->_reviewStatus); // force to be reloaded from DB
$reviewStatus=$this->getReviewStatus(); $reviewStatus=$this->getReviewStatus();
if (is_array($reviewStatus) && count($reviewStatus)>0) { if (is_array($reviewStatus) && count($reviewStatus)>0) {
@ -3075,10 +3083,13 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
if ($r["status"]==0){ if ($r["status"]==0){
$pendingReview=true; $pendingReview=true;
break; break;
} elseif($r["status"]==1){
$hasReview=true;
} }
} }
} }
$pendingApproval=false; $pendingApproval=false;
$hasApproval=false;
unset($this->_approvalStatus); // force to be reloaded from DB unset($this->_approvalStatus); // force to be reloaded from DB
$approvalStatus=$this->getApprovalStatus(); $approvalStatus=$this->getApprovalStatus();
if (is_array($approvalStatus) && count($approvalStatus)>0) { if (is_array($approvalStatus) && count($approvalStatus)>0) {
@ -3086,10 +3097,13 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
if ($a["status"]==0){ if ($a["status"]==0){
$pendingApproval=true; $pendingApproval=true;
break; break;
} elseif($a["status"]==1){
$hasApproval=true;
} }
} }
} }
$pendingRevision=false; $pendingRevision=false;
$hasRevision=false;
unset($this->_revisionStatus); // force to be reloaded from DB unset($this->_revisionStatus); // force to be reloaded from DB
$revsisionStatus=$this->getRevisionStatus(); $revsisionStatus=$this->getRevisionStatus();
if (is_array($revsisionStatus) && count($revsisionStatus)>0) { if (is_array($revsisionStatus) && count($revsisionStatus)>0) {
@ -3097,16 +3111,29 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
if ($a["status"]==0){ if ($a["status"]==0){
$pendingRevision=true; $pendingRevision=true;
break; break;
} elseif($a["status"]==1){
$hasRevision=true;
} }
} }
} }
/* First check for an open review, approval, revision. */
if ($hasworkflow) $this->setStatus(S_IN_WORKFLOW,$msg,$user); if ($hasworkflow) $this->setStatus(S_IN_WORKFLOW,$msg,$user);
elseif ($pendingReview) $this->setStatus(S_DRAFT_REV,$msg,$user); elseif ($pendingReview) $this->setStatus(S_DRAFT_REV,$msg,$user);
elseif ($pendingApproval) $this->setStatus(S_DRAFT_APP,$msg,$user); elseif ($pendingApproval) $this->setStatus(S_DRAFT_APP,$msg,$user);
elseif ($pendingRevision) $this->setStatus(S_IN_REVISION,$msg,$user); elseif ($pendingRevision) $this->setStatus(S_IN_REVISION,$msg,$user);
/* A document in status S_DRAFT will never go into S_RELEASED */ /* Finally decide what to do if either no review, approval, revision was
elseif ($st["status"]!=S_DRAFT) $this->setStatus(S_RELEASED,$msg,$user); * ever done or if one of them has been done. In the first case it will
* go to the initial status, in the second case, it will be released.
* A document in status S_DRAFT will never go into S_RELEASED and document
* already released will never go back at this point into the given
* initial status, which can only by S_DRAFT or S_RELEASED
*/
elseif ($st["status"]!=S_DRAFT && $st["status"]!=S_RELEASED ) {
if($hasReview || $hasApproval || $hasRevision) $this->setStatus(S_RELEASED,$msg,$user);
else $this->setStatus($initialstatus,$msg,$user);
}
} /* }}} */ } /* }}} */
function __construct($id, $document, $version, $comment, $date, $userID, $dir, $orgFileName, $fileType, $mimeType, $fileSize=0, $checksum='', $revisionDate=null) { /* {{{ */ function __construct($id, $document, $version, $comment, $date, $userID, $dir, $orgFileName, $fileType, $mimeType, $fileSize=0, $checksum='', $revisionDate=null) { /* {{{ */
@ -3398,6 +3425,15 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
if (is_bool($res) && !$res) if (is_bool($res) && !$res)
return false; return false;
/* Check if 'onSetStatus' callback is set */
if(isset($this->_dms->callbacks['onSetStatus'])) {
foreach($this->_dms->callbacks['onSetStatus'] as $callback) {
$ret = call_user_func($callback[0], $callback[1], $this, $this->_status["status"], $status);
if(is_bool($ret))
return $ret;
}
}
unset($this->_status); unset($this->_status);
return true; return true;
} /* }}} */ } /* }}} */