From 0ac0ca5760bd564cb1ce89c78cd6fa9fe9f176ce Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 30 Aug 2021 16:00:51 +0200 Subject: [PATCH 01/19] remove duplicate of sendRequestWorkflowActionMail() --- inc/inc.ClassNotificationService.php | 33 ---------------------------- 1 file changed, 33 deletions(-) diff --git a/inc/inc.ClassNotificationService.php b/inc/inc.ClassNotificationService.php index a252960ef..0a5fc7740 100644 --- a/inc/inc.ClassNotificationService.php +++ b/inc/inc.ClassNotificationService.php @@ -145,39 +145,6 @@ class SeedDMS_NotificationService { return $error; } /* }}} */ - /** - * This notification is sent when a workflow action is needed. - */ - public function sendRequestWorkflowActionMail($content, $user) { /* {{{ */ - $document = $content->getDocument(); - $folder = $document->getFolder(); - - /* Send mail only if enabled in the configuration */ - if($this->settings->_enableNotificationWorkflow && ($workflow = $content->getWorkflow())) { - $subject = "request_workflow_action_email_subject"; - $message = "request_workflow_action_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['version'] = $content->getVersion(); - $params['workflow'] = $workflow->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['current_state'] = $workflow->getInitState()->getName(); - $params['username'] = $user->getFullName(); - $params['sitename'] = $this->settings->_siteName; - $params['http_root'] = $this->settings->_httpRoot; - $params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); - - foreach($workflow->getNextTransitions($workflow->getInitState()) as $ntransition) { - foreach($ntransition->getUsers() as $tuser) { - $this->toIndividual($user, $tuser->getUser(), $subject, $message, $params, SeedDMS_NotificationService::RECV_WORKFLOW); - } - foreach($ntransition->getGroups() as $tuser) { - $this->toGroup($user, $tuser->getGroup(), $subject, $message, $params, SeedDMS_NotificationService::RECV_WORKFLOW); - } - } - } - } /* }}} */ - /** * This notification is sent when a review or approval is needed. */ From 45b51cb04315569e64d28507140ef0d7ee200092 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 30 Aug 2021 16:01:54 +0200 Subject: [PATCH 02/19] send notification to owner --- inc/inc.ClassNotificationService.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/inc/inc.ClassNotificationService.php b/inc/inc.ClassNotificationService.php index 0a5fc7740..7897cda0d 100644 --- a/inc/inc.ClassNotificationService.php +++ b/inc/inc.ClassNotificationService.php @@ -260,9 +260,9 @@ class SeedDMS_NotificationService { foreach ($notifyList["groups"] as $grp) { $this->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); } -// if user is not owner send notification to owner -// if ($user->getID() != $document->getOwner()->getID()) -// $this->toIndividual($user, $document->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER); + /* if user is not owner send notification to owner */ + if ($user->getID() != $document->getOwner()->getID()) + $this->toIndividual($user, $document->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER); $this->sendRequestWorkflowActionMail($lc, $user); @@ -424,6 +424,11 @@ class SeedDMS_NotificationService { foreach ($notifyList["groups"] as $grp) { $this->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); } + + /* if user is not owner send notification to owner */ + if ($user->getID() != $document->getOwner()->getID()) + $this->toIndividual($user, $document->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER); + } /* }}} */ /** @@ -632,8 +637,8 @@ class SeedDMS_NotificationService { $this->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); } // if user is not owner send notification to owner - // if ($user->getID() != $folder->getOwner()->getID()) - // $notifier->toIndividual($user, $folder->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER); + if ($user->getID() != $folder->getOwner()->getID()) + $this->toIndividual($user, $folder->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER); } } /* }}} */ @@ -714,8 +719,8 @@ class SeedDMS_NotificationService { $this->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); } // if user is not owner send notification to owner - // if ($user->getID() != $folder->getOwner()->getID()) - // $this->toIndividual($user, $folder->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER); + if ($user->getID() != $folder->getOwner()->getID()) + $this->toIndividual($user, $folder->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER); } } /* }}} */ From 33ad98bdfd1e0a9d67b95efb8bd277ad3a9d066e Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 30 Aug 2021 16:02:22 +0200 Subject: [PATCH 03/19] replace $notifier-> by $this-> --- inc/inc.ClassNotificationService.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/inc.ClassNotificationService.php b/inc/inc.ClassNotificationService.php index 7897cda0d..e3dbd8804 100644 --- a/inc/inc.ClassNotificationService.php +++ b/inc/inc.ClassNotificationService.php @@ -833,7 +833,7 @@ class SeedDMS_NotificationService { $this->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); } -// $notifier->toIndividual($user, $content->getUser(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER); +// $this->toIndividual($user, $content->getUser(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER); } /* }}} */ public function sendNewDocumentNotifyMail($document, $user, $obj) { /* {{{ */ @@ -926,7 +926,7 @@ class SeedDMS_NotificationService { foreach ($nl["groups"] as $grp) { $this->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); } -// $notifier->toIndividual($user, $content->getUser(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER); +// $this->toIndividual($user, $content->getUser(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER); } /* }}} */ public function sendSubmittedApprovalMail($content, $user, $approvelog) { /* {{{ */ @@ -972,7 +972,7 @@ class SeedDMS_NotificationService { foreach ($notifyList["groups"] as $grp) { $this->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); } -// $notifier->toIndividual($user, $oldowner, $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER); +// $this->toIndividual($user, $oldowner, $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER); } } /* }}} */ From 96ca0725287ecec200b2b12edd3a3c08c62eeb8c Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 30 Aug 2021 16:03:00 +0200 Subject: [PATCH 04/19] add methods sendRequestWorkflowActionMail and sendTriggerWorkflowTransitionMail --- inc/inc.ClassNotificationService.php | 81 ++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/inc/inc.ClassNotificationService.php b/inc/inc.ClassNotificationService.php index e3dbd8804..55c3c8c1b 100644 --- a/inc/inc.ClassNotificationService.php +++ b/inc/inc.ClassNotificationService.php @@ -1038,5 +1038,86 @@ class SeedDMS_NotificationService { } } /* }}} */ + public function sendTriggerWorkflowTransitionMail($content, $user, $wkflog) { /* {{{ */ + $document = $content->getDocument(); + $workflow = $wkflog->getWorkflow(); + $transition = $wkflog->getTransition(); + $nl = $document->getNotifyList(); + $folder = $document->getFolder(); + $subject = "transition_triggered_email_subject"; + $message = "transition_triggered_email_body"; + $params = array(); + $params['name'] = $document->getName(); + $params['version'] = $content->getVersion(); + $params['workflow'] = $workflow->getName(); + $params['action'] = $transition->getAction()->getName(); + $params['folder_path'] = $folder->getFolderPathPlain(); + $params['comment'] = $wkflog->getComment(); + $params['previous_state'] = $transition->getState()->getName(); + $params['current_state'] = $transition->getNextState()->getName(); + $params['username'] = $user->getFullName(); + $params['sitename'] = $this->settings->_siteName; + $params['http_root'] = $this->settings->_httpRoot; + $params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); + + // Send notification to subscribers. + $this->toList($user, $nl["users"], $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); + foreach ($nl["groups"] as $grp) { + $this->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); + } + } /* }}} */ + + /** + * This notification is sent when a workflow action needed. + * If a transition is passed this must be the translation lately fired, hence + * the state of the workflow is next state of the transition. If no transition + * is passed, the workflow just started and is still in its initial state. + */ + public function sendRequestWorkflowActionMail($content, $user, $transition=null) { /* {{{ */ + $document = $content->getDocument(); + $folder = $document->getFolder(); + if($transition) { + $workflow = $transition->getWorkflow(); + $state = $transition->getNextState(); + } else { + $workflow = $content->getWorkflow(); + $state = $workflow->getInitState(); + } + + if($this->settings->_enableNotificationWorkflow) { + $subject = "request_workflow_action_email_subject"; + $message = "request_workflow_action_email_body"; + $params = array(); + $params['name'] = $document->getName(); + $params['version'] = $content->getVersion(); + $params['workflow'] = $workflow->getName(); + $params['folder_path'] = $folder->getFolderPathPlain(); + if($transition) + $params['current_state'] = $transition->getNextState()->getName(); + else + $params['current_state'] = $workflow->getInitState()->getName(); + $params['username'] = $user->getFullName(); + $params['sitename'] = $this->settings->_siteName; + $params['http_root'] = $this->settings->_httpRoot; + $params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); + + $usersinformed = array(); + $groupsinformed = array(); + foreach($workflow->getNextTransitions($state) as $ntransition) { + foreach($ntransition->getUsers() as $tuser) { + if(!in_array($tuser->getUser()->getID(), $usersinformed)) { + $usersinformed[] = $tuser->getUser()->getID(); + $this->toIndividual($user, $tuser->getUser(), $subject, $message, $params, SeedDMS_NotificationService::RECV_WORKFLOW); + } + } + foreach($ntransition->getGroups() as $tuser) { + if(!in_array($tuser->getGroup()->getID(), $groupsinformed)) { + $groupsinformed[] = $tuser->getGroup()->getID(); + $this->toGroup($user, $tuser->getGroup(), $subject, $message, $params, SeedDMS_NotificationService::RECV_WORKFLOW); + } + } + } + } + } /* }}} */ } From 8018dc1a248f643c87d3b62997305e6ae6568ce7 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 30 Aug 2021 16:03:42 +0200 Subject: [PATCH 05/19] remove old code --- op/op.ReturnFromSubWorkflow.php | 11 ----------- op/op.RewindWorkflow.php | 8 -------- 2 files changed, 19 deletions(-) diff --git a/op/op.ReturnFromSubWorkflow.php b/op/op.ReturnFromSubWorkflow.php index dfcd2a221..23ff85ed0 100644 --- a/op/op.ReturnFromSubWorkflow.php +++ b/op/op.ReturnFromSubWorkflow.php @@ -76,17 +76,6 @@ if($version->returnFromSubWorkflow($user, $transition, $_POST["comment"])) { $nl = $document->getNotifyList(); $folder = $document->getFolder(); -/* - $subject = "###SITENAME###: ".$document->getName()." - ".getMLText("return_from_subworkflow_email"); - $message = getMLText("return_from_subwork_email")."\r\n"; - $message .= - getMLText("document").": ".$document->getName()."\r\n". - getMLText("workflow").": ".$workflow->getName()."\r\n". - getMLText("workflow").": ".$parentworkflow->getName()."\r\n". - getMLText("current_state").": ".$version->getWorkflowState()->getName()."\r\n". - getMLText("user").": ".$user->getFullName()." <". $user->getEmail() ."> "; -*/ - $subject = "return_from_subworkflow_email_subject"; $message = "return_from_subworkflow_email_body"; $params = array(); diff --git a/op/op.RewindWorkflow.php b/op/op.RewindWorkflow.php index d67cdc8f7..b9a67045d 100644 --- a/op/op.RewindWorkflow.php +++ b/op/op.RewindWorkflow.php @@ -65,14 +65,6 @@ if($version->rewindWorkflow()) { $nl = $document->getNotifyList(); $folder = $document->getFolder(); -/* - $subject = "###SITENAME###: ".$document->getName()." - ".getMLText("rewind_workflow_email"); - $message = getMLText("rewind_workflow_email")."\r\n"; - $message .= - getMLText("document").": ".$document->getName()."\r\n". - getMLText("workflow").": ".$workflow->getName()."\r\n". - getMLText("user").": ".$user->getFullName()." <". $user->getEmail() ."> "; -*/ $subject = "rewind_workflow_email_subject"; $message = "rewind_workflow_email_body"; $params = array(); From 42fdeaf915b97c1015c4d8b52d6917e501bd8a74 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 30 Aug 2021 16:04:15 +0200 Subject: [PATCH 06/19] fix type of recipient when send notification, remove old code --- op/op.RunSubWorkflow.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/op/op.RunSubWorkflow.php b/op/op.RunSubWorkflow.php index 69c49456c..3e08f5725 100644 --- a/op/op.RunSubWorkflow.php +++ b/op/op.RunSubWorkflow.php @@ -71,16 +71,6 @@ if($version->runSubWorkflow($subworkflow)) { $nl = $document->getNotifyList(); $folder = $document->getFolder(); -/* - $subject = "###SITENAME###: ".$document->getName()." - ".getMLText("run_subworkflow_email"); - $message = getMLText("run_subwork_email")."\r\n"; - $message .= - getMLText("document").": ".$document->getName()."\r\n". - getMLText("workflow").": ".$subworkflow->getName()."\r\n". - getMLText("current_state").": ".$version->getWorkflowState()->getName()."\r\n". - getMLText("user").": ".$user->getFullName()." <". $user->getEmail() ."> "; -*/ - $subject = "run_subworkflow_email_subject"; $message = "run_subworkflow_email_body"; $params = array(); @@ -96,7 +86,7 @@ if($version->runSubWorkflow($subworkflow)) { // Send notification to subscribers. $notifier->toList($user, $nl["users"], $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); foreach ($nl["groups"] as $grp) { - $notifier->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); + $notifier->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); } } } From 48a0ca8cb93237a54a40336c3ce127f529a569ad Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 30 Aug 2021 16:04:51 +0200 Subject: [PATCH 07/19] use new methods sendTriggerWorkflowTransitionMail and sendRequestWorkflowActionMail --- op/op.TriggerWorkflow.php | 57 +++------------------------------------ 1 file changed, 3 insertions(+), 54 deletions(-) diff --git a/op/op.TriggerWorkflow.php b/op/op.TriggerWorkflow.php index a7bf0b483..ab40ade03 100644 --- a/op/op.TriggerWorkflow.php +++ b/op/op.TriggerWorkflow.php @@ -78,61 +78,10 @@ if(isset($GLOBALS['SEEDDMS_HOOKS']['triggerWorkflowTransition'])) { if($version->triggerWorkflowTransition($user, $transition, $_POST["comment"])) { if ($notifier) { - $nl = $document->getNotifyList(); - $folder = $document->getFolder(); - $subject = "transition_triggered_email_subject"; - $message = "transition_triggered_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['version'] = $version->getVersion(); - $params['workflow'] = $workflow->getName(); - $params['action'] = $transition->getAction()->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['comment'] = $_POST["comment"]; - $params['previous_state'] = $transition->getState()->getName(); - $params['current_state'] = $transition->getNextState()->getName(); - $params['username'] = $user->getFullName(); - $params['sitename'] = $settings->_siteName; - $params['http_root'] = $settings->_httpRoot; - $params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); + $wkflog = $version->getWorkflowLog($transition); + $notifier->sendTriggerWorkflowTransitionMail($version, $user, $wkflog ? $wkflog[0] : false); - // Send notification to subscribers. - $notifier->toList($user, $nl["users"], $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); - foreach ($nl["groups"] as $grp) { - $notifier->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); - } - - if($settings->_enableNotificationWorkflow) { - $subject = "request_workflow_action_email_subject"; - $message = "request_workflow_action_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['version'] = $version->getVersion(); - $params['workflow'] = $workflow->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['current_state'] = $transition->getNextState()->getName(); - $params['username'] = $user->getFullName(); - $params['sitename'] = $settings->_siteName; - $params['http_root'] = $settings->_httpRoot; - $params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); - - $usersinformed = array(); - $groupsinformed = array(); - foreach($workflow->getNextTransitions($transition->getNextState()) as $ntransition) { - foreach($ntransition->getUsers() as $tuser) { - if(!in_array($tuser->getUser()->getID(), $usersinformed)) { - $usersinformed[] = $tuser->getUser()->getID(); - $notifier->toIndividual($user, $tuser->getUser(), $subject, $message, $params, SeedDMS_NotificationService::RECV_WORKFLOW); - } - } - foreach($ntransition->getGroups() as $tuser) { - if(!in_array($tuser->getGroup()->getID(), $groupsinformed)) { - $groupsinformed[] = $tuser->getGroup()->getID(); - $notifier->toGroup($user, $tuser->getGroup(), $subject, $message, $params, SeedDMS_NotificationService::RECV_WORKFLOW); - } - } - } - } + $notifier->sendRequestWorkflowActionMail($version, $user, $transition); } $session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_trigger_workflow'))); From 33c10fc1dba85eb03dd88c2adfc5901810055f38 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 30 Aug 2021 19:34:38 +0200 Subject: [PATCH 08/19] add some documentation in comments --- SeedDMS_Core/Core/inc.ClassDocument.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php index 7e216019c..fd10acde1 100644 --- a/SeedDMS_Core/Core/inc.ClassDocument.php +++ b/SeedDMS_Core/Core/inc.ClassDocument.php @@ -3404,6 +3404,8 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ /** * Return a list of all reviewers separated by individuals and groups + * This list will not take the review log into account. Therefore it + * can contain which has actually been deleted as a reviewer. * * @return array|bool|null */ @@ -3433,7 +3435,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ /** * Get the current review status of the document content - * The review status is a list of reviews and its current status + * The review status is a list of reviewers and its current status * * @param integer $limit the number of recent status changes per reviewer * @return array list of review status @@ -3582,6 +3584,8 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ /** * Return a list of all approvers separated by individuals and groups + * This list will not take the approval log into account. Therefore it + * can contain which has actually been deleted as an approver. * * @return array|bool|null */ @@ -3611,7 +3615,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ /** * Get the current approval status of the document content - * The approval status is a list of approvals and its current status + * The approval status is a list of approvers and its current status * * @param integer $limit the number of recent status changes per approver * @return array list of approval status From 13ad0788a396df55e6888a24b516b73103d63033 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 30 Aug 2021 19:35:08 +0200 Subject: [PATCH 09/19] send notification mail when new attachment was added --- op/op.Ajax.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/op/op.Ajax.php b/op/op.Ajax.php index af947601e..70a75c1f4 100644 --- a/op/op.Ajax.php +++ b/op/op.Ajax.php @@ -896,6 +896,9 @@ switch($command) { header('Content-Type: application/json'); echo json_encode(array('success'=>false, 'message'=>getMLText('error_occured'), 'data'=>'')); } else { + if($notifier) { + $notifier->sendNewFileMail($res, $user); + } header('Content-Type: application/json'); echo json_encode(array('success'=>true, 'message'=>getMLText('splash_document_added'), 'data'=>$document->getID())); add_log_line(); From 3951c3ec38e62a72f12462855c5cae12b351e3aa Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 30 Aug 2021 19:35:47 +0200 Subject: [PATCH 10/19] call sendReviewRequestMail() after review was removed --- op/op.RemoveReviewLog.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/op/op.RemoveReviewLog.php b/op/op.RemoveReviewLog.php index 1ec2b00b3..6c2582ad5 100644 --- a/op/op.RemoveReviewLog.php +++ b/op/op.RemoveReviewLog.php @@ -93,7 +93,13 @@ if($reviewStatus['type'] == 0) { UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("invalid_reviewid")); $comment = $_POST["comment"]; +$overallStatus = $latestContent->getStatus(); if(0 == $latestContent->removeReview($reviewid, $user, $comment)) { $latestContent->verifyStatus(true, $user, $msg); + if($notifier) { + $notifier->sendReviewRequestMail($latestContent, $user); + if($overallStatus['status'] != $latestContent->getStatus()['status']) + $notifier->sendChangedDocumentStatusMail($latestContent, $user, $overallStatus["status"]); + } } header("Location:../out/out.ViewDocument.php?documentid=".$documentid."¤ttab=revapp"); From 6dac961e9cd8bb68428a22d7dae2a24eedfadee1 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 30 Aug 2021 19:36:40 +0200 Subject: [PATCH 11/19] call sendChangedDocumentStatusMail() if status has changed --- op/op.TriggerWorkflow.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/op/op.TriggerWorkflow.php b/op/op.TriggerWorkflow.php index ab40ade03..c78319d77 100644 --- a/op/op.TriggerWorkflow.php +++ b/op/op.TriggerWorkflow.php @@ -76,12 +76,16 @@ if(isset($GLOBALS['SEEDDMS_HOOKS']['triggerWorkflowTransition'])) { } } +$overallStatus = $version->getStatus(); if($version->triggerWorkflowTransition($user, $transition, $_POST["comment"])) { if ($notifier) { $wkflog = $version->getWorkflowLog($transition); $notifier->sendTriggerWorkflowTransitionMail($version, $user, $wkflog ? $wkflog[0] : false); $notifier->sendRequestWorkflowActionMail($version, $user, $transition); + if($overallStatus['status'] != $version->getStatus()['status']) { + $notifier->sendChangedDocumentStatusMail($version, $user, $overallStatus["status"]); + } } $session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_trigger_workflow'))); From a4276a42a96fd1aba9f9f928824c85542abc99c7 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 30 Aug 2021 19:39:29 +0200 Subject: [PATCH 12/19] add and use sendRewindWorkflowMail() --- inc/inc.ClassNotificationService.php | 29 ++++++++++++++++++++++++++++ op/op.RewindWorkflow.php | 20 +------------------ 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/inc/inc.ClassNotificationService.php b/inc/inc.ClassNotificationService.php index 55c3c8c1b..2af75c514 100644 --- a/inc/inc.ClassNotificationService.php +++ b/inc/inc.ClassNotificationService.php @@ -1119,5 +1119,34 @@ class SeedDMS_NotificationService { } } } /* }}} */ + + /** + * This notification is sent when a workflow is rewinded. + */ + public function sendRewindWorkflowMail($content, $user) { /* {{{ */ + $document = $content->getDocument(); + $folder = $document->getFolder(); + $workflow = $content->getWorkflow(); + + $nl = $document->getNotifyList(); + $folder = $document->getFolder(); + + $subject = "rewind_workflow_email_subject"; + $message = "rewind_workflow_email_body"; + $params = array(); + $params['name'] = $document->getName(); + $params['version'] = $content->getVersion(); + $params['workflow'] = $workflow->getName(); + $params['folder_path'] = $folder->getFolderPathPlain(); + $params['username'] = $user->getFullName(); + $params['sitename'] = $this->settings->_siteName; + $params['http_root'] = $this->settings->_httpRoot; + $params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID()."¤ttab=workflow"; + // Send notification to subscribers. + $this->toList($user, $nl["users"], $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); + foreach ($nl["groups"] as $grp) { + $this->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); + } + } /* }}} */ } diff --git a/op/op.RewindWorkflow.php b/op/op.RewindWorkflow.php index b9a67045d..b01b6a278 100644 --- a/op/op.RewindWorkflow.php +++ b/op/op.RewindWorkflow.php @@ -62,25 +62,7 @@ if (!is_object($workflow)) { if($version->rewindWorkflow()) { if ($notifier) { - $nl = $document->getNotifyList(); - $folder = $document->getFolder(); - - $subject = "rewind_workflow_email_subject"; - $message = "rewind_workflow_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['version'] = $version->getVersion(); - $params['workflow'] = $workflow->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['username'] = $user->getFullName(); - $params['sitename'] = $settings->_siteName; - $params['http_root'] = $settings->_httpRoot; - $params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); - // Send notification to subscribers. - $notifier->toList($user, $nl["users"], $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); - foreach ($nl["groups"] as $grp) { - $notifier->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); - } + $notifier->sendRewindWorkflowMail($version, $user); } } From aadcbbd9797a55709774c7ce665143ed80c40b7a Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 30 Aug 2021 19:40:10 +0200 Subject: [PATCH 13/19] check if workflow exists in sendRequestWorkflowActionMail() --- inc/inc.ClassNotificationService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/inc.ClassNotificationService.php b/inc/inc.ClassNotificationService.php index 2af75c514..583a2177a 100644 --- a/inc/inc.ClassNotificationService.php +++ b/inc/inc.ClassNotificationService.php @@ -1076,11 +1076,11 @@ class SeedDMS_NotificationService { public function sendRequestWorkflowActionMail($content, $user, $transition=null) { /* {{{ */ $document = $content->getDocument(); $folder = $document->getFolder(); + if(!($workflow = $content->getWorkflow())) + return; if($transition) { - $workflow = $transition->getWorkflow(); $state = $transition->getNextState(); } else { - $workflow = $content->getWorkflow(); $state = $workflow->getInitState(); } From cd10bcaea3afd8dae3dccf55805e6aa53dcc83d9 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 30 Aug 2021 19:40:43 +0200 Subject: [PATCH 14/19] add sendApprovalRequestMail() and sendReviewRequestMail() --- inc/inc.ClassNotificationService.php | 88 +++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/inc/inc.ClassNotificationService.php b/inc/inc.ClassNotificationService.php index 583a2177a..c6847d2c8 100644 --- a/inc/inc.ClassNotificationService.php +++ b/inc/inc.ClassNotificationService.php @@ -147,8 +147,12 @@ class SeedDMS_NotificationService { /** * This notification is sent when a review or approval is needed. + * The method is only called by sendNewDocumentMail() and sendNewDocumentVersionMail(). + * It does not care about the current status of an approval or review, but + * informs an reviewer and approver. Hence, it should only be called + * right after a new document version was created. */ - public function sendRequestRevAppActionMail($content, $user) { /* {{{ */ + private function sendRequestRevAppActionMail($content, $user) { /* {{{ */ $document = $content->getDocument(); $folder = $document->getFolder(); @@ -200,6 +204,88 @@ class SeedDMS_NotificationService { } } /* }}} */ + /** + * This notification is sent when a review is needed. + * In opposite to sendRequestRevAppActionMail() this method checks review status + * and informs only those reviewers about a required review who have not + * reviewed the document yet. + */ + public function sendReviewRequestMail($content, $user) { /* {{{ */ + $document = $content->getDocument(); + $dms = $document->getDMS(); + $folder = $document->getFolder(); + + if($this->settings->_enableNotificationAppRev) { + $subject = "review_request_email_subject"; + $message = "review_request_email_body"; + $params = array(); + $params['name'] = $document->getName(); + $params['folder_path'] = $folder->getFolderPathPlain(); + $params['version'] = $content->getVersion(); + $params['comment'] = $document->getComment(); + $params['username'] = $user->getFullName(); + $params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID()."¤ttab=revapp"; + $params['sitename'] = $this->settings->_siteName; + $params['http_root'] = $this->settings->_httpRoot; + + $reviewStatus = $content->getReviewStatus(); + foreach($reviewStatus as $dastat) { + if ($dastat["status"] == 0) { + if ($dastat["type"] == 0) { + + $reviewer = $dms->getUser($dastat["required"]); + $this->toIndividual($document->getOwner(), $reviewer, $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); + } elseif ($dastat["type"] == 1) { + + $group = $dms->getGroup($dastat["required"]); + $this->toGroup($document->getOwner(), $group, $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); + } + } + } + } + } /* }}} */ + + /** + * This notification is sent when a review is needed. + * In opposite to sendRequestRevAppActionMail() this method checks the approval status + * and informs only those reviewers about a required approval who have not + * approved the document yet. + */ + public function sendApprovalRequestMail($content, $user) { /* {{{ */ + $document = $content->getDocument(); + $dms = $document->getDMS(); + $folder = $document->getFolder(); + + if($this->settings->_enableNotificationAppRev) { + $subject = "approval_request_email_subject"; + $message = "approval_request_email_body"; + $params = array(); + $params['name'] = $document->getName(); + $params['folder_path'] = $folder->getFolderPathPlain(); + $params['version'] = $content->getVersion(); + $params['comment'] = $document->getComment(); + $params['username'] = $user->getFullName(); + $params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID()."¤ttab=revapp"; + $params['sitename'] = $this->settings->_siteName; + $params['http_root'] = $this->settings->_httpRoot; + + $approvalStatus = $content->getApprovalStatus(); + foreach($approvalStatus as $dastat) { + if ($dastat["status"] == 0) { + if ($dastat["type"] == 0) { + + $approver = $dms->getUser($dastat["required"]); + $this->toIndividual($document->getOwner(), $approver, $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); + } elseif ($dastat["type"] == 1) { + + $group = $dms->getGroup($dastat["required"]); + $this->toGroup($document->getOwner(), $group, $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); + } + } + } + } + } /* }}} */ + /** * This notification is sent when a new document is created. */ From 1d5164c2ab83f1ea1b631f62b3a9df2efdb0d34d Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 30 Aug 2021 19:41:26 +0200 Subject: [PATCH 15/19] use sendChangedDocumentStatusMail() --- op/op.ReviewDocument.php | 76 +++++++--------------------------------- 1 file changed, 12 insertions(+), 64 deletions(-) diff --git a/op/op.ReviewDocument.php b/op/op.ReviewDocument.php index 1547f1541..58576ab6d 100644 --- a/op/op.ReviewDocument.php +++ b/op/op.ReviewDocument.php @@ -130,29 +130,12 @@ else if ($_POST["reviewType"] == "grp") { // updated. // +$overallStatus = $content->getStatus(); if ($_POST["reviewStatus"]==-1){ - if($content->setStatus(S_REJECTED,$comment,$user)) { // Send notification to subscribers. if($notifier) { - $nl=$document->getNotifyList(); - $folder = $document->getFolder(); - $subject = "document_status_changed_email_subject"; - $message = "document_status_changed_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['status'] = getReviewStatusText(S_REJECTED); - $params['new_status_code'] = S_REJECTED; - $params['username'] = $user->getFullName(); - $params['sitename'] = $settings->_siteName; - $params['http_root'] = $settings->_httpRoot; - $params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); - $notifier->toList($user, $nl["users"], $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); - foreach ($nl["groups"] as $grp) { - $notifier->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); - } -// $notifier->toIndividual($user, $content->getUser(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER); + $notifier->sendChangedDocumentStatusMail($content, $user, $overallStatus["status"]); } } @@ -201,54 +184,19 @@ if ($_POST["reviewStatus"]==-1){ if ($content->setStatus($newStatus, getMLText("automatic_status_update"), $user)) { // Send notification to subscribers. if($notifier) { - $nl=$document->getNotifyList(); - $folder = $document->getFolder(); - $subject = "document_status_changed_email_subject"; - $message = "document_status_changed_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['status'] = getReviewStatusText($newStatus); - $params['new_status_code'] = $newStatus; - $params['username'] = $user->getFullName(); - $params['sitename'] = $settings->_siteName; - $params['http_root'] = $settings->_httpRoot; - $notifier->toList($user, $nl["users"], $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); - foreach ($nl["groups"] as $grp) { - $notifier->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); + $notifier->sendChangedDocumentStatusMail($content, $user, $overallStatus["status"]); + + // Notify approvers, if necessary. + if ($newStatus == S_DRAFT_APP) { + $requestUser = $document->getOwner(); + $notifier->sendApprovalRequestMail($content, $user); } } - - // TODO: if user os not owner send notification to owner - // Notify approvers, if necessary. - if ($newStatus == S_DRAFT_APP) { - $requestUser = $document->getOwner(); - - if($notifier) { - $subject = "approval_request_email_subject"; - $message = "approval_request_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $version; - $params['username'] = $user->getFullName(); - $params['sitename'] = $settings->_siteName; - $params['http_root'] = $settings->_httpRoot; - $params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID()."¤ttab=revapp"; - foreach ($docApprovalStatus as $dastat) { - - if ($dastat["status"] == 0) { - if ($dastat["type"] == 0) { - - $approver = $dms->getUser($dastat["required"]); - $notifier->toIndividual($document->getOwner(), $approver, $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); - } elseif ($dastat["type"] == 1) { - - $group = $dms->getGroup($dastat["required"]); - $notifier->toGroup($document->getOwner(), $group, $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); - } - } + if(isset($GLOBALS['SEEDDMS_HOOKS']['reviewDocument'])) { + foreach($GLOBALS['SEEDDMS_HOOKS']['reviewDocument'] as $hookObj) { + if (method_exists($hookObj, 'postReviewDocument')) { + $hookObj->postReviewDocument(null, $content, $newStatus); } } } From df8e0c29e92e6a8d8d251879095419ab4c929483 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 31 Aug 2021 10:26:34 +0200 Subject: [PATCH 16/19] add methods to inform a user/group about adding/deleting as a reviewer/approver --- inc/inc.ClassNotificationService.php | 102 +++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/inc/inc.ClassNotificationService.php b/inc/inc.ClassNotificationService.php index c6847d2c8..8061a27de 100644 --- a/inc/inc.ClassNotificationService.php +++ b/inc/inc.ClassNotificationService.php @@ -1039,6 +1039,108 @@ class SeedDMS_NotificationService { } /* }}} */ + public function sendDeleteApprovalMail($content, $user, $approver) { /* {{{ */ + $document = $content->getDocument(); + $folder = $document->getFolder(); + $subject = "approval_deletion_email_subject"; + $message = "approval_deletion_email_body"; + $params = array(); + $params['name'] = $document->getName(); + $params['folder_path'] = $folder->getFolderPathPlain(); + $params['version'] = $content->getVersion(); + $params['comment'] = $content->getComment(); + $params['username'] = $user->getFullName(); + $params['sitename'] = $this->settings->_siteName; + $params['http_root'] = $this->settings->_httpRoot; + $params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); + + if($approver->isType('user')) + $this->toIndividual($user, $approver, $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); + elseif($approver->isType('group')) + $this->toGroup($user, $approver, $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); + } /* }}} */ + + public function sendDeleteReviewMail($content, $user, $reviewer) { /* {{{ */ + $document = $content->getDocument(); + $folder = $document->getFolder(); + $subject = "review_deletion_email_subject"; + $message = "review_deletion_email_body"; + $params = array(); + $params['name'] = $document->getName(); + $params['folder_path'] = $folder->getFolderPathPlain(); + $params['version'] = $content->getVersion(); + $params['comment'] = $content->getComment(); + $params['username'] = $user->getFullName(); + $params['sitename'] = $this->settings->_siteName; + $params['http_root'] = $this->settings->_httpRoot; + $params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); + + if($reviewer->isType('user')) + $this->toIndividual($user, $reviewer, $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); + elseif($approver->isType('group')) + $this->toGroup($user, $reviewer, $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); + } /* }}} */ + + /** + * This notification is send if a new approver is added. + * + * In most cases all approvers are informed with sendApprovalRequestMail() + * when a new document version is added, + * but this method informs just a single approver (user or group), when the + * approver was added at a later point in time. + */ + public function sendAddApprovalMail($content, $user, $approver) { /* {{{ */ + $document = $content->getDocument(); + $folder = $document->getFolder(); + + $subject = "approval_request_email_subject"; + $message = "approval_request_email_body"; + $params = array(); + $params['name'] = $document->getName(); + $params['folder_path'] = $folder->getFolderPathPlain(); + $params['version'] = $content->getVersion(); + $params['comment'] = $content->getComment(); + $params['username'] = $user->getFullName(); + $params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); + $params['sitename'] = $settings->_siteName; + $params['http_root'] = $settings->_httpRoot; + + if($approver->isType('user')) + $this->toIndividual($user, $approver, $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); + elseif($approver->isType('group')) + $this->toGroup($user, $approver, $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); + } /* }}} */ + + /** + * This notification is send if a new reviewer is added. + * + * In most cases all reviewers are informed with sendReviewRequestMail() + * when a new document version is added, + * but this method informs just a single reviewer (user or group), when the + * reviewer was added at a later point in time. + */ + public function sendAddReviewMail($content, $user, $reviewer) { /* {{{ */ + $document = $content->getDocument(); + $folder = $document->getFolder(); + + $subject = "review_request_email_subject"; + $message = "review_request_email_body"; + $params = array(); + $params['name'] = $document->getName(); + $params['folder_path'] = $folder->getFolderPathPlain(); + $params['version'] = $content->getVersion(); + $params['comment'] = $content->getComment(); + $params['username'] = $user->getFullName(); + $params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); + $params['sitename'] = $settings->_siteName; + $params['http_root'] = $settings->_httpRoot; + + if($reviewer->isType('user')) + $this->toIndividual($user, $reviewer, $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); + elseif($reviewer->isType('group')) + $this->toGroup($user, $reviewer, $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); + } /* }}} */ + public function sendChangedDocumentOwnerMail($document, $user, $oldowner) { /* {{{ */ if($oldowner->getID() != $document->getOwner()->getID()) { $notifyList = $document->getNotifyList(); From 200806effde43a92c69dc7f78f2bef9caa119782 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 31 Aug 2021 10:27:20 +0200 Subject: [PATCH 17/19] use new methods to inform approvers/reviewers about deleting/adding a review/approval --- op/op.SetReviewersApprovers.php | 76 +++++++++++---------------------- 1 file changed, 24 insertions(+), 52 deletions(-) diff --git a/op/op.SetReviewersApprovers.php b/op/op.SetReviewersApprovers.php index 1abc8ed3d..07a1a9536 100644 --- a/op/op.SetReviewersApprovers.php +++ b/op/op.SetReviewersApprovers.php @@ -132,19 +132,7 @@ foreach ($pIndRev as $p) { // Send an email notification to the new reviewer. if($settings->_enableNotificationAppRev) { if ($notifier) { - $subject = "review_request_email_subject"; - $message = "review_request_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $content->getVersion(); - $params['comment'] = $content->getComment(); - $params['username'] = $user->getFullName(); - $params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); - $params['sitename'] = $settings->_siteName; - $params['http_root'] = $settings->_httpRoot; - - $notifier->toIndividual($user, $docAccess["users"][$accessIndex["i"][$p]], $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); + $notifier->sendAddReviewMail($content, $user, $docAccess["users"][$accessIndex["i"][$p]]); } } break; @@ -198,6 +186,8 @@ if (count($reviewIndex["i"]) > 0) { // Send an email notification to the reviewer. if($settings->_enableNotificationAppRev) { if ($notifier) { + $notifier->sendDeleteReviewMail($content, $user, $docAccess["users"][$accessIndex["i"][$rx]]); + /* $subject = "review_deletion_email_subject"; $message = "review_deletion_email_body"; $params = array(); @@ -211,6 +201,7 @@ if (count($reviewIndex["i"]) > 0) { $params['http_root'] = $settings->_httpRoot; $notifier->toIndividual($user, $docAccess["users"][$accessIndex["i"][$rx]], $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); + */ } } break; @@ -244,19 +235,7 @@ foreach ($pGrpRev as $p) { // Send an email notification to the new reviewer. if($settings->_enableNotificationAppRev) { if ($notifier) { - $subject = "review_request_email_subject"; - $message = "review_request_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $content->getVersion(); - $params['comment'] = $content->getComment(); - $params['username'] = $user->getFullName(); - $params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); - $params['sitename'] = $settings->_siteName; - $params['http_root'] = $settings->_httpRoot; - - $notifier->toGroup($user, $docAccess["groups"][$accessIndex["g"][$p]], $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); + $notifier->sendAddReviewMail($content, $user, $docAccess["groups"][$accessIndex["g"][$p]]); } } break; @@ -302,6 +281,8 @@ if (count($reviewIndex["g"]) > 0) { // Send an email notification to the review group. if($settings->_enableNotificationAppRev) { if ($notifier) { + $notifier->sendDeleteReviewMail($content, $user, $docAccess["groups"][$accessIndex["g"][$rx]]); + /* $subject = "review_deletion_email_subject"; $message = "review_deletion_email_body"; $params = array(); @@ -315,6 +296,7 @@ if (count($reviewIndex["g"]) > 0) { $params['http_root'] = $settings->_httpRoot; $notifier->toGroup($user, $docAccess["groups"][$accessIndex["g"][$rx]], $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); + */ } } break; @@ -363,20 +345,12 @@ foreach ($pIndApp as $p) { case 0: // Send an email notification to the new approver. if($settings->_enableNotificationAppRev) { + /* Send notification only if document is currently not in review state, + * because then the approvers will be informed anyway when review state + * is left and approval state is entered. + */ if ($overallStatus["status"]!=0 && $notifier) { - $subject = "approval_request_email_subject"; - $message = "approval_request_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $content->getVersion(); - $params['comment'] = $content->getComment(); - $params['username'] = $user->getFullName(); - $params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); - $params['sitename'] = $settings->_siteName; - $params['http_root'] = $settings->_httpRoot; - - $notifier->toIndividual($user, $docAccess["users"][$accessIndex["i"][$p]], $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); + $notifier->sendAddApprovalMail($content, $user, $docAccess["users"][$accessIndex["i"][$p]]); } } break; @@ -422,6 +396,8 @@ if (count($approvalIndex["i"]) > 0) { // Send an email notification to the approver. if($settings->_enableNotificationAppRev) { if ($notifier) { + $notifier->sendDeleteApprovalMail($content, $user, $docAccess["users"][$accessIndex["i"][$rx]]); + /* $subject = "approval_deletion_email_subject"; $message = "approval_deletion_email_body"; $params = array(); @@ -435,6 +411,7 @@ if (count($approvalIndex["i"]) > 0) { $params['http_root'] = $settings->_httpRoot; $notifier->toIndividual($user, $docAccess["users"][$accessIndex["i"][$rx]], $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); + */ } } break; @@ -467,20 +444,12 @@ foreach ($pGrpApp as $p) { case 0: // Send an email notification to the new approver. if($settings->_enableNotificationAppRev) { + /* Send notification only if document is currently not in review state, + * because then the approvers will be informed anyway when review state + * is left and approval state is entered. + */ if ($overallStatus["status"]!=0 && $notifier) { - $subject = "approval_request_email_subject"; - $message = "approval_request_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $content->getVersion(); - $params['comment'] = $content->getComment(); - $params['username'] = $user->getFullName(); - $params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); - $params['sitename'] = $settings->_siteName; - $params['http_root'] = $settings->_httpRoot; - - $notifier->toGroup($user, $docAccess["groups"][$accessIndex["g"][$p]], $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); + $notifier->sendAddApprovalMail($content, $user, $docAccess["groups"][$accessIndex["g"][$p]]); } } break; @@ -526,6 +495,8 @@ if (count($approvalIndex["g"]) > 0) { // Send an email notification to the approval group. if($settings->_enableNotificationAppRev) { if ($notifier) { + $notifier->sendDeleteApprovalMail($content, $user, $docAccess["groups"][$accessIndex["g"][$rx]]); + /* $subject = "approval_deletion_email_subject"; $message = "approval_deletion_email_body"; $params = array(); @@ -539,6 +510,7 @@ if (count($approvalIndex["g"]) > 0) { $params['http_root'] = $settings->_httpRoot; $notifier->toGroup($user, $docAccess["groups"][$accessIndex["g"][$rx]], $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); + */ } } break; From 67ab9fbf71c187b4a33d84455ac0dbf197b6eb2e Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 31 Aug 2021 10:29:56 +0200 Subject: [PATCH 18/19] remove old code --- op/op.SetReviewersApprovers.php | 60 --------------------------------- 1 file changed, 60 deletions(-) diff --git a/op/op.SetReviewersApprovers.php b/op/op.SetReviewersApprovers.php index 07a1a9536..77cc69875 100644 --- a/op/op.SetReviewersApprovers.php +++ b/op/op.SetReviewersApprovers.php @@ -187,21 +187,6 @@ if (count($reviewIndex["i"]) > 0) { if($settings->_enableNotificationAppRev) { if ($notifier) { $notifier->sendDeleteReviewMail($content, $user, $docAccess["users"][$accessIndex["i"][$rx]]); - /* - $subject = "review_deletion_email_subject"; - $message = "review_deletion_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $content->getVersion(); - $params['comment'] = $content->getComment(); - $params['username'] = $user->getFullName(); - $params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); - $params['sitename'] = $settings->_siteName; - $params['http_root'] = $settings->_httpRoot; - - $notifier->toIndividual($user, $docAccess["users"][$accessIndex["i"][$rx]], $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); - */ } } break; @@ -282,21 +267,6 @@ if (count($reviewIndex["g"]) > 0) { if($settings->_enableNotificationAppRev) { if ($notifier) { $notifier->sendDeleteReviewMail($content, $user, $docAccess["groups"][$accessIndex["g"][$rx]]); - /* - $subject = "review_deletion_email_subject"; - $message = "review_deletion_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $content->getVersion(); - $params['comment'] = $content->getComment(); - $params['username'] = $user->getFullName(); - $params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); - $params['sitename'] = $settings->_siteName; - $params['http_root'] = $settings->_httpRoot; - - $notifier->toGroup($user, $docAccess["groups"][$accessIndex["g"][$rx]], $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); - */ } } break; @@ -397,21 +367,6 @@ if (count($approvalIndex["i"]) > 0) { if($settings->_enableNotificationAppRev) { if ($notifier) { $notifier->sendDeleteApprovalMail($content, $user, $docAccess["users"][$accessIndex["i"][$rx]]); - /* - $subject = "approval_deletion_email_subject"; - $message = "approval_deletion_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $content->getVersion(); - $params['comment'] = $content->getComment(); - $params['username'] = $user->getFullName(); - $params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); - $params['sitename'] = $settings->_siteName; - $params['http_root'] = $settings->_httpRoot; - - $notifier->toIndividual($user, $docAccess["users"][$accessIndex["i"][$rx]], $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); - */ } } break; @@ -496,21 +451,6 @@ if (count($approvalIndex["g"]) > 0) { if($settings->_enableNotificationAppRev) { if ($notifier) { $notifier->sendDeleteApprovalMail($content, $user, $docAccess["groups"][$accessIndex["g"][$rx]]); - /* - $subject = "approval_deletion_email_subject"; - $message = "approval_deletion_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $content->getVersion(); - $params['comment'] = $content->getComment(); - $params['username'] = $user->getFullName(); - $params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); - $params['sitename'] = $settings->_siteName; - $params['http_root'] = $settings->_httpRoot; - - $notifier->toGroup($user, $docAccess["groups"][$accessIndex["g"][$rx]], $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); - */ } } break; From ce621bb6b848965e539c8c58f057ac3f2c1b4201 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Tue, 31 Aug 2021 13:32:36 +0200 Subject: [PATCH 19/19] add entry for 5.1.24 --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index ab5c3f6c4..f4ddada70 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ Changes in version 5.1.24 -------------------------------------------------------------------------------- - fix sending of some notification mails to groups +- major overhaul of notifications - check view access for FolderAccess and DocumentAccess --------------------------------------------------------------------------------