diff --git a/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php index 183e7b872..799d3f243 100644 --- a/SeedDMS_Core/Core/inc.ClassDocument.php +++ b/SeedDMS_Core/Core/inc.ClassDocument.php @@ -3163,12 +3163,13 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ * If status is draft and there are no approver and no reviewers => set * status to S_RELEASED * The status of a document with the current status S_OBSOLETE, S_REJECTED, - * or S_EXPIRED will not be changed unless the parameter + * S_NEEDS_CORRECTION or S_EXPIRED will not be changed unless the parameter * $ignorecurrentstatus is set to true. * * This method may not be called after a negative approval or review to * recalculated the status, because - * it doesn't take a defeating approval or review into account. It will + * it doesn't take a defeating approval or review into account. This method + * does not set the status to S_REJECTED! It will * just check for a pending workflow, approval or review and set the status * accordingly, e.g. after the list of reviewers or appovers has been * modified. If there is not pending workflow, approval or review the @@ -3192,15 +3193,19 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ $st=$this->getStatus(); /* Documents already obsoleted, rejected or expired will not change - * its status anymore, unless explicitly requested. + * its status anymore, unless explicitly requested. Be aware, that + * this method has an unsufficient check for negative reviews and + * approvals. A document in status S_REJECTED may become S_RELEASED + * if there is at least one positive review or approval. */ - 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 || $st["status"]==S_NEEDS_CORRECTION)) return; unset($this->_workflow); // force to be reloaded from DB $hasworkflow = $this->getWorkflow() ? true : false; /* $pendingReview will be set when there are still open reviews */ $pendingReview=false; + /* $hasReview will be set if there is at least one positiv review */ $hasReview=false; unset($this->_reviewStatus); // force to be reloaded from DB $reviewStatus=$this->getReviewStatus(); @@ -3217,6 +3222,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ /* $pendingApproval will be set when there are still open approvals */ $pendingApproval=false; + /* $hasApproval will be set if there is at least one positiv review */ $hasApproval=false; unset($this->_approvalStatus); // force to be reloaded from DB $approvalStatus=$this->getApprovalStatus(); @@ -3232,6 +3238,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ } $pendingRevision=false; $hasRevision=false; + $needsCorrection=false; unset($this->_revisionStatus); // force to be reloaded from DB $revsisionStatus=$this->getRevisionStatus(); if (is_array($revsisionStatus) && count($revsisionStatus)>0) { @@ -3241,6 +3248,8 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ break; } elseif($a["status"]==1){ $hasRevision=true; + } elseif($a["status"]==-1){ + $needsCorrection=true; } } } @@ -3250,16 +3259,33 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ elseif ($pendingReview) $this->setStatus(S_DRAFT_REV,$msg,$user); elseif ($pendingApproval) $this->setStatus(S_DRAFT_APP,$msg,$user); elseif ($pendingRevision) $this->setStatus(S_IN_REVISION,$msg,$user); - /* Finally decide what to do if either no review, approval, revision was - * 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. + /* This point will only be reached if there is no pending workflow, review, + * approval or revision but the current status is one of S_DRAFT_REV, + * S_DRAFT_APP or S_IN_REVISION. This can happen if formely set reviewers, + * approvers, revisors are completly removed. In case of S_DRAFT_REV and + * S_DRAFT_APP the document will go back into its initial status. If a + * positive review or approval was found the document will be released. + * Be aware that negative reviews or approvals are not taken into account, + * because in that case the document must have been rejected before calling + * this function. FIXME: this is a problem if the parameter $ignorecurrentstatus + * was set, because an already rejected document may be released with just + * one positive review or approval disregarding any negative reviews or + * approvals. + * A document in status S_IN_REVISION will be treated differently. + * It takes negative revisions into account! + * * 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); + if($st["status"]==S_DRAFT_REV || $st["status"]==S_DRAFT_APP) { + if($hasReview || $hasApproval) $this->setStatus(S_RELEASED,$msg,$user); + else $this->setStatus($initialstatus,$msg,$user); + } elseif($st["status"]==S_IN_REVISION) { + if($needsCorrection) $this->setStatus(S_NEEDS_CORRECTION,$msg,$user); + else $this->setStatus(S_RELEASED,$msg,$user); + } } } /* }}} */