move notification mail into class NotificationService

This commit is contained in:
Uwe Steinmann 2021-05-18 17:07:14 +02:00
parent 3422e5a906
commit 040793034b
2 changed files with 27 additions and 20 deletions

View File

@ -676,5 +676,31 @@ class SeedDMS_NotificationService {
}
} /* }}} */
public function sendChangedDocumentStatusMail($document, $user, $oldstatus) { /* {{{ */
$content = $document->getLatestContent();
$overallStatus = $content->getStatus();
$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'] = getOverallStatusText($overallStatus["status"]);
$params['old_status'] = getOverallStatusText($oldstatus);
$params['new_status_code'] = $overallStatus["status"];
$params['old_status_code'] = $oldstatus;
$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);
}
// $notifier->toIndividual($user, $content->getUser(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER);
} /* }}} */
}

View File

@ -80,26 +80,7 @@ if ($overrideStatus != $overallStatus["status"]) {
} else {
// 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'] = getOverallStatusText($overrideStatus);
$params['new_status_code'] = $overrideStatus;
$params['old_status_code'] = $overallStatus["status"];
$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($document, $user, $overallStatus["status"]);
}
}
}