From 5246c3a329aee4589bc0eb3fc80b503777037d41 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 1 Jun 2015 07:21:16 +0200 Subject: [PATCH] place code for updating document content into controller --- controllers/class.ApproveDocument.php | 40 ++++++++++++++++++++++++++- op/op.ApproveDocument.php | 36 ------------------------ 2 files changed, 39 insertions(+), 37 deletions(-) diff --git a/controllers/class.ApproveDocument.php b/controllers/class.ApproveDocument.php index 7e7410521..c101ba9c6 100644 --- a/controllers/class.ApproveDocument.php +++ b/controllers/class.ApproveDocument.php @@ -55,10 +55,48 @@ class SeedDMS_Controller_ApproveDocument extends SeedDMS_Controller_Common { return false; } } - if(!$this->callHook('postApproveDocument', $document)) { + } + + /* Check to see if the overall status for the document version needs to be + * updated. + */ + $result = $this->callHook('approveUpdateDocumentStatus', $document); + if($result === null) { + /* If document was rejected, set the document status to S_REJECTED right away */ + if ($approvalstatus == -1){ + if($content->setStatus(S_REJECTED,$comment,$user)) { + } + } else { + $docApprovalStatus = $content->getApprovalStatus(); + if (is_bool($docApprovalStatus) && !$docApprovalStatus) { + $this->error = 1; + $this->errormsg = "cannot_retrieve_approval_snapshot"; + return false; + } + $approvalCT = 0; + $approvalTotal = 0; + foreach ($docApprovalStatus as $drstat) { + if ($drstat["status"] == 1) { + $approvalCT++; + } + if ($drstat["status"] != -2) { + $approvalTotal++; + } + } + // If all approvals have been received and there are no rejections, retrieve a + // count of the approvals required for this document. + if ($approvalCT == $approvalTotal) { + // Change the status to released. + $newStatus=S_RELEASED; + if($content->setStatus($newStatus, getMLText("automatic_status_update"), $user)) { + } + } } } + if(!$this->callHook('postApproveDocument', $document)) { + } + return true; } } diff --git a/op/op.ApproveDocument.php b/op/op.ApproveDocument.php index fcf60f0c2..c77da0389 100644 --- a/op/op.ApproveDocument.php +++ b/op/op.ApproveDocument.php @@ -51,7 +51,6 @@ if (!is_object($document)) { } $folder = $document->getFolder(); -$docPathHTML = getFolderPathHTML($folder, true). " / ".$document->getName().""; if ($document->getAccessMode($user) < M_READ) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied")); @@ -85,7 +84,6 @@ if (!isset($_POST["approvalStatus"]) || !is_numeric($_POST["approvalStatus"]) || UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_approval_status")); } - $controller->setParam('document', $document); $controller->setParam('content', $latestContent); $controller->setParam('approvalstatus', $_POST["approvalStatus"]); @@ -101,40 +99,6 @@ if(!$controller->run()) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText($controller->getErrorMsg())); } -// -// Check to see if the overall status for the document version needs to be -// updated. -// - -/* If document was rejected, set the document status to S_REJECTED right away */ -if ($_POST["approvalStatus"]==-1){ - if($content->setStatus(S_REJECTED,$comment,$user)) { - } -} else { - $docApprovalStatus = $content->getApprovalStatus(); - if (is_bool($docApprovalStatus) && !$docApprovalStatus) { - UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("cannot_retrieve_approval_snapshot")); - } - $approvalCT = 0; - $approvalTotal = 0; - foreach ($docApprovalStatus as $drstat) { - if ($drstat["status"] == 1) { - $approvalCT++; - } - if ($drstat["status"] != -2) { - $approvalTotal++; - } - } - // If all approvals have been received and there are no rejections, retrieve a - // count of the approvals required for this document. - if ($approvalCT == $approvalTotal) { - // Change the status to released. - $newStatus=S_RELEASED; - if($content->setStatus($newStatus, getMLText("automatic_status_update"), $user)) { - } - } -} - if ($_POST["approvalType"] == "ind" || $_POST["approvalType"] == "grp") { // Send an email notification to the document updater. if($notifier) {