diff --git a/op/op.ReceiptDocument.php b/op/op.ReceiptDocument.php index e90181ce5..3b7fbf0f1 100644 --- a/op/op.ReceiptDocument.php +++ b/op/op.ReceiptDocument.php @@ -95,28 +95,8 @@ if(!$controller->run()) { if ($_POST["receiptType"] == "ind" || $_POST["receiptType"] == "grp") { if($notifier) { - $nl=$document->getNotifyList(); - $subject = "receipt_submit_email_subject"; - $message = "receipt_submit_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['version'] = $version; - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['status'] = getReceiptStatusText($_POST["receiptStatus"]); - $params['comment'] = strip_tags($_POST['comment']); - $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->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); - } - /* Send mail to owner only if the currently logged in user is not the - * owner and the owner is not already in the list of notifiers. - */ -// if($user->getID() != $document->getOwner()->getID() && false === SeedDMS_Core_DMS::inList($document->getOwner(), $nl['users'])) -// $notifier->toIndividual($user, $content->getUser(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER); + $receiptlog = $latestContent->getReceiptLog(); + $notifier->sendSubmittedReceiptMail($latestContent, $user, $receiptlog ? $receiptlog[0] : false); } } diff --git a/op/op.ReviseDocument.php b/op/op.ReviseDocument.php index 6f2d0de22..d73ee2387 100644 --- a/op/op.ReviseDocument.php +++ b/op/op.ReviseDocument.php @@ -93,64 +93,26 @@ $controller->setParam('group', $group); $controller->setParam('comment', $_POST["comment"]); $controller->setParam('onevotereject', $settings->_enableRevisionOneVoteReject); if(!$controller->run()) { - UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText($controller->getErrorMsg())); + $err = $controller->getErrorMsg(); + if(is_string($err)) + $errmsg = getMLText($err); + elseif(is_array($err)) { + $errmsg = getMLText($err[0], $err[1]); + } else { + $errmsg = $err; + } + UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText($errmsg)); } -if ($_POST["revisionType"] == "ind" || $_POST["revisionType"] == "grp") { - if($notifier) { - $nl=$document->getNotifyList(); - $subject = "revision_submit_email_subject"; - $message = "revision_submit_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['version'] = $version; - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['status'] = getRevisionStatusText($_POST["revisionStatus"]); - $params['comment'] = strip_tags($_POST['comment']); - $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->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); - } - /* Send mail to owner only if the currently logged in user is not the - * owner and the owner is not already in the list of notifiers. - */ -// if($user->getID() != $document->getOwner()->getID() && false === SeedDMS_Core_DMS::inList($document->getOwner(), $nl['users'])) -// $notifier->toIndividual($user, $content->getUser(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER); +if($notifier) { + if ($_POST["revisionType"] == "ind" || $_POST["revisionType"] == "grp") { + $revisionlog = $latestContent->getRevisionLog(); + $notifier->sendSubmittedRevisionMail($latestContent, $user, $revisionlog ? $revisionlog[0] : false); } -} -/* Send notification about status change only if status has actually changed */ -$newdocstatus = $content->getStatus(); -if($olddocstatus['status'] != $newdocstatus['status']) { - // Send notification to subscribers. - if($notifier) { - $nl=$document->getNotifyList(); - $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'] = getOverallStatusText($olddocstatus['status']).' → '.getOverallStatusText($newdocstatus['status']); - $params['new_status_code'] = $newdocstatus['status']; - $params['old_status_code'] = $olddocstatus['status']; - $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->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); - } - /* Send mail to owner only if the currently logged in user is not the - * owner and the owner is not already in the list of notifiers. - */ -// if($user->getID() != $document->getOwner()->getID() && false === SeedDMS_Core_DMS::inList($document->getOwner(), $nl['users'])) -// $notifier->toIndividual($user, $content->getUser(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER); - } + /* Send notification about status change only if status has actually changed */ + if($controller->oldstatus != $controller->newstatus) + $notifier->sendChangedDocumentStatusMail($latestContent, $user, $controller->oldstatus); } header("Location:../out/out.ViewDocument.php?documentid=".$documentid."¤ttab=revision"); diff --git a/op/op.SetRecipients.php b/op/op.SetRecipients.php index 492c8b5a7..2806e73af 100644 --- a/op/op.SetRecipients.php +++ b/op/op.SetRecipients.php @@ -140,20 +140,7 @@ foreach ($pIndRev as $p) { // Send an email notification to the new recipient. if($settings->_enableNotificationAppRev) { if ($notifier) { - $subject = "receipt_request_email_subject"; - $message = "receipt_request_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $content->getVersion(); - $params['comment'] = $content->getComment(); - $params['recipient'] = $accessIndex["i"][$p]->getFullName(); - $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, $accessIndex["i"][$p], $subject, $message, $params, SeedDMS_NotificationService::RECV_RECIPIENT); + $notifier->sendAddReceiptMail($content, $user, $accessIndex["i"][$p]); } } break; @@ -187,20 +174,7 @@ if (count($receiptIndex["i"]) > 0) { // Send an email notification to the recipients. if($settings->_enableNotificationAppRev) { if ($notifier) { - $subject = "receipt_deletion_email_subject"; - $message = "receipt_deletion_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $content->getVersion(); - $params['comment'] = $content->getComment(); - $params['recipient'] = $accessIndex["i"][$rx]->getFullName(); - $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, $accessIndex["i"][$rx], $subject, $message, $params, SeedDMS_NotificationService::RECV_RECIPIENT); + $notifier->sendDeleteReceiptMail($content, $user, $accessIndex["i"][$rx]); } } break; @@ -247,20 +221,7 @@ foreach ($pGrpRev as $p) { // Send an email notification to the new recipient. if($settings->_enableNotificationAppRev) { if ($notifier) { - $subject = "receipt_request_email_subject"; - $message = "receipt_request_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $content->getVersion(); - $params['comment'] = $content->getComment(); - $params['recipient'] = $accessIndex["g"][$p]->getName(); - $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, $accessIndex["g"][$p], $subject, $message, $params, SeedDMS_NotificationService::RECV_RECIPIENT); + $notifier->sendAddReceiptMail($content, $user, $accessIndex["g"][$p]); } } break; @@ -290,20 +251,7 @@ if (count($receiptIndex["g"]) > 0) { // Send an email notification to the recipients group. if($settings->_enableNotificationAppRev) { if ($notifier) { - $subject = "receipt_deletion_email_subject"; - $message = "receipt_deletion_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $content->getVersion(); - $params['comment'] = $content->getComment(); - $params['recipient'] = $accessIndex["g"][$rx]->getName(); - $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, $accessIndex["g"][$rx], $subject, $message, $params, SeedDMS_NotificationService::RECV_RECIPIENT); + $notifier->sendDeleteReceiptMail($content, $user, $accessIndex["g"][$rx]); } } break; diff --git a/op/op.SetRevisors.php b/op/op.SetRevisors.php index 294ba0619..672cd6677 100644 --- a/op/op.SetRevisors.php +++ b/op/op.SetRevisors.php @@ -127,20 +127,7 @@ foreach ($pIndRev as $p) { // Send an email notification to the new recipient. if($settings->_enableNotificationAppRev) { if ($notifier) { - $subject = "revision_request_email_subject"; - $message = "revision_request_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $content->getVersion(); - $params['comment'] = $content->getComment(); - $params['revisor'] = $accessIndex["i"][$p]->getFullName(); - $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, $accessIndex["i"][$p], $subject, $message, $params, SeedDMS_NotificationService::RECV_REVISOR); + $notifier->sendAddRevisionMail($content, $user, $accessIndex["i"][$p]); } } break; @@ -186,20 +173,7 @@ if (count($revisionIndex["i"]) > 0) { // Send an email notification to the recipients. if($settings->_enableNotificationAppRev) { if ($notifier) { - $subject = "revision_deletion_email_subject"; - $message = "revision_deletion_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $content->getVersion(); - $params['comment'] = $content->getComment(); - $params['revisor'] = $accessIndex["i"][$rx]->getFullName(); - $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, $accessIndex["i"][$rx], $subject, $message, $params, SeedDMS_NotificationService::RECV_REVISOR); + $notifier->sendDeleteRevisionMail($content, $user, $accessIndex["i"][$rx]); } } break; @@ -234,20 +208,7 @@ foreach ($pGrpRev as $p) { // Send an email notification to the new recipient. if($settings->_enableNotificationAppRev) { if ($notifier) { - $subject = "revision_request_email_subject"; - $message = "revision_request_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $content->getVersion(); - $params['comment'] = $content->getComment(); - $params['revisor'] = $accessIndex["g"][$p]->getName(); - $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, $accessIndex["g"][$p], $subject, $message, $params, SeedDMS_NotificationService::RECV_REVISOR); + $notifier->sendAddRevisionMail($content, $user, $accessIndex["g"][$p]); } } break; @@ -289,20 +250,7 @@ if (count($revisionIndex["g"]) > 0) { // Send an email notification to the recipients group. if($settings->_enableNotificationAppRev) { if ($notifier) { - $subject = "revision_deletion_email_subject"; - $message = "revision_deletion_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $content->getVersion(); - $params['comment'] = $content->getComment(); - $params['revisor'] = $accessIndex["g"][$rx]->getName(); - $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, $accessIndex["g"][$rx], $subject, $message, $params, SeedDMS_NotificationService::RECV_REVISOR); + $notifier->sendDeleteRevisionMail($content, $user, $accessIndex["g"][$rx]); } } break;