move sending notification mail into Notification service

This commit is contained in:
Uwe Steinmann 2021-05-21 09:14:55 +02:00
parent a9d912bce2
commit b12dbd8e02
2 changed files with 28 additions and 19 deletions

View File

@ -432,6 +432,33 @@ class SeedDMS_NotificationService {
}
} /* }}} */
/**
* This notification is sent when a document content is replaced.
*/
public function sendReplaceContentMail($content, $user) { /* {{{ */
$document = $content->getDocument();
$folder = $document->getFolder();
$notifyList = $document->getNotifyList();
$subject = "replace_content_email_subject";
$message = "replace_content_email_body";
$params = array();
$params['name'] = $document->getName();
$params['folder_name'] = $folder->getName();
$params['folder_path'] = $folder->getFolderPathPlain();
$params['username'] = $user->getFullName();
$params['comment'] = $document->getComment();
$params['version'] = $content->getVersion();
$params['version_comment'] = $content->getComment();
$params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$params['sitename'] = $this->settings->_siteName;
$params['http_root'] = $this->settings->_httpRoot;
$this->toList($user, $notifyList["users"], $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION);
foreach ($notifyList["groups"] as $grp) {
$this->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION);
}
} /* }}} */
/**
* This notification is sent when a new attachment is created.
*/

View File

@ -63,25 +63,7 @@ if($lc->getChecksum() == SeedDMS_Core_File::checksum($tmpfname)) {
} else {
if($document->replaceContent(0, $user, $tmpfname, $lc->getOriginalFileName(), $lc->getFileType(), $lc->getMimeType())) {
if($notifier) {
$notifyList = $folder->getNotifyList();
$subject = "replace_content_email_subject";
$message = "replace_content_email_body";
$params = array();
$params['name'] = $document->getName();
$params['folder_name'] = $folder->getName();
$params['folder_path'] = $folder->getFolderPathPlain();
$params['username'] = $user->getFullName();
$params['comment'] = $document->getComment();
$params['version'] = $lc->getVersion();
$params['version_comment'] = $lc->getComment();
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$notifier->toList($user, $notifyList["users"], $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION);
foreach ($notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION);
}
$notifier->sendReplaceContentMail($lc, $user);
}
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_saved_file')));
} else {