From ec6c4855fcd1ef28557516639a8dfb02ac5f7561 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Sat, 25 Jan 2025 12:42:08 +0100 Subject: [PATCH] send request receipt notification only if document is released --- op/op.AddDocument.php | 13 ++++++++++++- op/op.ApproveDocument.php | 7 +++++++ op/op.OverrideContentStatus.php | 11 +++++++++-- op/op.SetRecipients.php | 24 ++++++++++++++++-------- op/op.UpdateDocument.php | 9 +++++++++ 5 files changed, 53 insertions(+), 11 deletions(-) diff --git a/op/op.AddDocument.php b/op/op.AddDocument.php index 0d5790dff..03f47c1fa 100644 --- a/op/op.AddDocument.php +++ b/op/op.AddDocument.php @@ -498,9 +498,20 @@ foreach($file_ary as $file) { if($controller->hasHook('cleanUpDocument')) { $controller->callHook('cleanUpDocument', $document, $file); } - // Send notification to subscribers of folder. if($notifier) { + // Send notification to subscribers of folder. $notifier->sendNewDocumentMail($document, $user); + + // Send notifcation to recipients of document + $content = $document->getLatestContent(); + $status = $content->getStatus(); + if ($status["status"] == S_RELEASED) { + if ($settings->_enableNotificationAppRev) { + if ($notifier) { + $notifier->sendToAllReceiptMail($content, $user); + } + } + } } if($settings->_removeFromDropFolder) { if(file_exists($userfiletmp)) { diff --git a/op/op.ApproveDocument.php b/op/op.ApproveDocument.php index 617b9da4b..6572e794d 100644 --- a/op/op.ApproveDocument.php +++ b/op/op.ApproveDocument.php @@ -111,6 +111,13 @@ if(!$controller()) { $notifier->sendSubmittedApprovalMail($latestContent, $user, $approvelog ? $approvelog[0] : false); if($controller->oldstatus != $controller->newstatus) $notifier->sendChangedDocumentStatusMail($latestContent, $user, $controller->oldstatus); + if ($controller->newstatus == S_RELEASED) { + if ($settings->_enableNotificationAppRev) { + if ($notifier) { + $notifier->sendToAllReceiptMail($content, $user); + } + } + } } } diff --git a/op/op.OverrideContentStatus.php b/op/op.OverrideContentStatus.php index 253926e56..dd5a74f42 100644 --- a/op/op.OverrideContentStatus.php +++ b/op/op.OverrideContentStatus.php @@ -85,9 +85,16 @@ if ($overrideStatus != $overallStatus["status"]) { if (!$content->setStatus($overrideStatus, $comment, $user)) { UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured")); } else { - // Send notification to subscribers. - if($notifier) { + if ($notifier) { + // Send notification to subscribers. $notifier->sendChangedDocumentStatusMail($content, $user, $overallStatus["status"]); + + // Send request for receipt notification + if ($overrideStatus == S_RELEASED) { + if ($settings->_enableNotificationAppRev) { + $notifier->sendToAllReceiptMail($content, $user); + } + } } } } diff --git a/op/op.SetRecipients.php b/op/op.SetRecipients.php index 2806e73af..778d8d3e0 100644 --- a/op/op.SetRecipients.php +++ b/op/op.SetRecipients.php @@ -69,6 +69,8 @@ foreach ($docAccess["groups"] as $i=>$da) { $accessIndex["g"][$da->getID()] = $da; } +$status = $content->getStatus(); + // Retrieve list of currently assigned recipients, along with // their latest status. $receiptStatus = $content->getReceiptStatus(); @@ -137,10 +139,13 @@ foreach ($pIndRev as $p) { // email error break; default: - // Send an email notification to the new recipient. - if($settings->_enableNotificationAppRev) { - if ($notifier) { - $notifier->sendAddReceiptMail($content, $user, $accessIndex["i"][$p]); + // Send an email notification to the new recipient only if the document + // is already released + if ($status["status"] == S_RELEASED) { + if($settings->_enableNotificationAppRev) { + if ($notifier) { + $notifier->sendAddReceiptMail($content, $user, $accessIndex["i"][$p]); + } } } break; @@ -218,10 +223,13 @@ foreach ($pGrpRev as $p) { // email error break; default: - // Send an email notification to the new recipient. - if($settings->_enableNotificationAppRev) { - if ($notifier) { - $notifier->sendAddReceiptMail($content, $user, $accessIndex["g"][$p]); + // Send an email notification to the new recipient only if the document + // is already released + if ($status["status"] == S_RELEASED) { + if($settings->_enableNotificationAppRev) { + if ($notifier) { + $notifier->sendAddReceiptMail($content, $user, $accessIndex["g"][$p]); + } } } break; diff --git a/op/op.UpdateDocument.php b/op/op.UpdateDocument.php index a1a798f38..19b32b145 100644 --- a/op/op.UpdateDocument.php +++ b/op/op.UpdateDocument.php @@ -403,6 +403,15 @@ default: $notifier->sendNewDocumentVersionMail($document, $user); $notifier->sendChangedExpiryMail($document, $user, $oldexpires); + + $status = $content->getStatus(); + if ($status["status"] == S_RELEASED) { + if ($settings->_enableNotificationAppRev) { + if ($notifier) { + $notifier->sendToAllReceiptMail($content, $user); + } + } + } } if($settings->_removeFromDropFolder) {