move sending notification mail in class NotificationService

This commit is contained in:
Uwe Steinmann 2021-05-18 16:58:16 +02:00
parent 72dcae36a2
commit 3422e5a906
2 changed files with 23 additions and 19 deletions

View File

@ -655,5 +655,26 @@ class SeedDMS_NotificationService {
$this->toIndividual($user, $folder->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER);
}
} /* }}} */
public function sendTransferDocumentMail($document, $user, $oldowner) { /* {{{ */
$folder = $document->getFolder();
$nl = $document->getNotifyList();
$subject = "document_transfered_email_subject";
$message = "document_transfered_email_body";
$params = array();
$params['name'] = $document->getName();
$params['newuser'] = $document->getOwner()->getFullName();
$params['olduser'] = $oldowner->getFullName();
$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();
$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);
}
} /* }}} */
}

View File

@ -30,10 +30,6 @@ include("../inc/inc.Authentication.php");
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$controller = Controller::factory($tmp[1], array('dms'=>$dms, 'user'=>$user));
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
if (!$accessop->check_controller_access($controller, $_POST)) {
UI::exitError(getMLText("document_title", array("documentname" => "")),getMLText("access_denied"));
}
/* Check if the form data comes from a trusted request */
if(!checkFormKey('transferdocument')) {
@ -61,6 +57,7 @@ if (!is_object($newuser)) {
}
$folder = $document->getFolder();
$oldowner = $document->getOwner();
$controller->setParam('document', $document);
$controller->setParam('newuser', $newuser);
@ -70,21 +67,7 @@ if(!$controller->run()) {
if ($notifier){
/* Get the notify list before removing the document */
$nl = $document->getNotifyList();
$subject = "document_transfered_email_subject";
$message = "document_transfered_email_body";
$params = array();
$params['name'] = $document->getName();
$params['newuser'] = $newuser->getFullName();
$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();
$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->sendTransferDocumentMail($document, $user, $oldowner);
}
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_transfer_document')));