use methods in inc/inc.ClassNotificationService.php it send notifications

This commit is contained in:
Uwe Steinmann 2022-11-06 16:09:27 +01:00
parent 57b298c489
commit fbe6e492c8

View File

@ -767,24 +767,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
if($this->notifier) {
if($this->logger)
$this->logger->log('PUT: Sending Notifications', PEAR_LOG_INFO);
$notifyList = $document->getNotifyList();
$folder = $document->getFolder();
$subject = "document_updated_email_subject";
$message = "document_updated_email_body";
$params = array();
$params['name'] = $document->getName();
$params['folder_path'] = $folder->getFolderPathPlain();
$params['username'] = $this->user->getFullName();
$params['comment'] = $document->getComment();
$params['version_comment'] = $content->getComment();
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$this->notifier->toList($this->user, $notifyList["users"], $subject, $message, $params);
foreach ($notifyList["groups"] as $grp) {
$this->notifier->toGroup($this->user, $grp, $subject, $message, $params);
}
$this->notifier->sendNewDocumentVersionMail($document, $this->user);
}
}
}
@ -863,29 +846,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
if($this->notifier) {
if($this->logger)
$this->logger->log('PUT: Sending Notifications', PEAR_LOG_INFO);
$fnl = $folder->getNotifyList();
$dnl = $document->getNotifyList();
$nl = array(
'users'=>array_unique(array_merge($dnl['users'], $fnl['users']), SORT_REGULAR),
'groups'=>array_unique(array_merge($dnl['groups'], $fnl['groups']), SORT_REGULAR)
);
$subject = "new_document_email_subject";
$message = "new_document_email_body";
$params = array();
$params['name'] = $name;
$params['folder_name'] = $folder->getName();
$params['folder_path'] = $folder->getFolderPathPlain();
$params['username'] = $this->user->getFullName();
$params['comment'] = '';
$params['version_comment'] = '';
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$this->notifier->toList($this->user, $nl["users"], $subject, $message, $params);
foreach ($nl["groups"] as $grp) {
$this->notifier->toGroup($this->user, $grp, $subject, $message, $params);
}
$this->notifier->sendNewDocumentMail($document, $this->user);
}
}
@ -967,28 +928,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
if($this->notifier) {
if($this->logger)
$this->logger->log('MKCOL: Sending Notifications', PEAR_LOG_INFO);
$fnl = $folder->getNotifyList();
$snl = $subFolder->getNotifyList();
$nl = array(
'users'=>array_unique(array_merge($snl['users'], $fnl['users']), SORT_REGULAR),
'groups'=>array_unique(array_merge($snl['groups'], $fnl['groups']), SORT_REGULAR)
);
$subject = "new_subfolder_email_subject";
$message = "new_subfolder_email_body";
$params = array();
$params['name'] = $subFolder->getName();
$params['folder_name'] = $folder->getName();
$params['folder_path'] = $folder->getFolderPathPlain();
$params['username'] = $this->user->getFullName();
$params['comment'] = '';
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewFolder.php?folderid=".$subFolder->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$this->notifier->toList($this->user, $nl["users"], $subject, $message, $params);
foreach ($nl["groups"] as $grp) {
$this->notifier->toGroup($this->user, $grp, $subject, $message, $params);
}
$this->notifier->sendNewFolderMail($subFolder, $this->user);
}
return ("201 Created");
@ -1030,79 +970,37 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
return "409 Conflict";
}
$parent = $obj->getParent();
$fnl = $obj->getNotifyList();
$pnl = $parent->getNotifyList();
$nl = array(
'users'=>array_unique(array_merge($fnl['users'], $pnl['users']), SORT_REGULAR),
'groups'=>array_unique(array_merge($fnl['groups'], $pnl['groups']), SORT_REGULAR)
);
$foldername = $obj->getName();
$controller = Controller::factory('RemoveFolder');
$controller->setParam('dms', $this->dms);
$controller->setParam('user', $this->user);
$controller->setParam('folder', $obj);
$controller->setParam('fulltextservice', $fulltextservice);
if(!$controller->run()) {
if(!$controller()) {
return "409 Conflict ".$controller->getErrorMsg();
}
if($this->notifier) {
if($this->logger)
$this->logger->log('DELETE: Sending Notifications', PEAR_LOG_INFO);
$subject = "folder_deleted_email_subject";
$message = "folder_deleted_email_body";
$params = array();
$params['name'] = $foldername;
$params['folder_path'] = $parent->getFolderPathPlain();
$params['username'] = $this->user->getFullName();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewFolder.php?folderid=".$parent->getID();
$this->notifier->toList($this->user, $nl["users"], $subject, $message, $params);
foreach ($nl["groups"] as $grp) {
$this->notifier->toGroup($this->user, $grp, $subject, $message, $params);
}
$this->notifier->sendDeleteFolderMail($obj, $this->user);
}
} else {
/* Get the notify list before removing the document
* Also inform the users/groups of the parent folder
*/
$folder = $obj->getFolder();
$dnl = $obj->getNotifyList();
$fnl = $folder->getNotifyList();
$nl = array(
'users'=>array_unique(array_merge($dnl['users'], $fnl['users']), SORT_REGULAR),
'groups'=>array_unique(array_merge($dnl['groups'], $fnl['groups']), SORT_REGULAR)
);
$docname = $obj->getName();
$controller = Controller::factory('RemoveDocument');
$controller->setParam('dms', $this->dms);
$controller->setParam('user', $this->user);
$controller->setParam('document', $obj);
$controller->setParam('fulltextservice', $fulltextservice);
if(!$controller->run()) {
if(!$controller()) {
return "409 Conflict ".$controller->getErrorMsg();
}
if($this->notifier){
if($this->logger)
$this->logger->log('DELETE: Sending Notifications', PEAR_LOG_INFO);
$subject = "document_deleted_email_subject";
$message = "document_deleted_email_body";
$params = array();
$params['name'] = $docname;
$params['folder_path'] = $folder->getFolderPathPlain();
$params['username'] = $this->user->getFullName();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewFolder.php?folderid=".$folder->getID();
$this->notifier->toList($this->user, $nl["users"], $subject, $message, $params);
foreach ($nl["groups"] as $grp) {
$this->notifier->toGroup($this->user, $grp, $subject, $message, $params);
}
/* $obj still has the data from the just deleted document,
* which is just enough to send the email.
*/
$this->notifier->sendDeleteDocumentMail($obj, $this->user);
}
}
@ -1211,27 +1109,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
if($this->notifier) {
if($this->logger)
$this->logger->log('MOVE: Sending Notifications', PEAR_LOG_INFO);
$nl1 = $oldFolder->getNotifyList();
$nl2 = $objsource->getNotifyList();
$nl3 = $objdest->getNotifyList();
$nl = array(
'users'=>array_unique(array_merge($nl1['users'], $nl2['users'], $nl3['users']), SORT_REGULAR),
'groups'=>array_unique(array_merge($nl1['groups'], $nl2['groups'], $nl3['groups']), SORT_REGULAR)
);
$subject = "document_moved_email_subject";
$message = "document_moved_email_body";
$params = array();
$params['name'] = $objsource->getName();
$params['old_folder_path'] = $oldFolder->getFolderPathPlain();
$params['new_folder_path'] = $objdest->getFolderPathPlain();
$params['username'] = $this->user->getFullName();
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$objsource->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$this->notifier->toList($this->user, $nl["users"], $subject, $message, $params);
foreach ($nl["groups"] as $grp) {
$this->notifier->toGroup($this->user, $grp, $subject, $message, $params);
}
$this->notifier->sendMovedDocumentMail($objsource, $this->user, $oldFolder);
}
} else {
return "500 Internal server error";
@ -1254,27 +1132,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
if($this->notifier) {
if($this->logger)
$this->logger->log('MOVE: Sending Notifications', PEAR_LOG_INFO);
$nl1 = $oldFolder->getNotifyList();
$nl2 = $objsource->getNotifyList();
$nl3 = $objdest->getNotifyList();
$nl = array(
'users'=>array_unique(array_merge($nl1['users'], $nl2['users'], $nl3['users']), SORT_REGULAR),
'groups'=>array_unique(array_merge($nl1['groups'], $nl2['groups'], $nl3['groups']), SORT_REGULAR)
);
$subject = "folder_moved_email_subject";
$message = "folder_moved_email_body";
$params = array();
$params['name'] = $objsource->getName();
$params['old_folder_path'] = $oldFolder->getFolderPathPlain();
$params['new_folder_path'] = $objdest->getFolderPathPlain();
$params['username'] = $this->user->getFullName();
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewFolder.php?folderid=".$objsource->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$this->notifier->toList($this->user, $nl["users"], $subject, $message, $params);
foreach ($nl["groups"] as $grp) {
$this->notifier->toGroup($this->user, $grp, $subject, $message, $params);
}
$this->notifier->sendMovedFolderMail($objsource, $this->user, $oldFolder);
}
} else {
return "500 Internal server error";
@ -1461,29 +1319,7 @@ class HTTP_WebDAV_Server_SeedDMS extends HTTP_WebDAV_Server
if($this->notifier) {
if($this->logger)
$this->logger->log('COPY: Sending Notifications', PEAR_LOG_INFO);
$fnl = $objdest->getNotifyList();
$dnl = $document->getNotifyList();
$nl = array(
'users'=>array_unique(array_merge($dnl['users'], $fnl['users']), SORT_REGULAR),
'groups'=>array_unique(array_merge($dnl['groups'], $fnl['groups']), SORT_REGULAR)
);
$subject = "new_document_email_subject";
$message = "new_document_email_body";
$params = array();
$params['name'] = $newdocname;
$params['folder_name'] = $objdest->getName();
$params['folder_path'] = $objdest->getFolderPathPlain();
$params['username'] = $this->user->getFullName();
$params['comment'] = '';
$params['version_comment'] = '';
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$this->notifier->toList($this->user, $nl["users"], $subject, $message, $params);
foreach ($nl["groups"] as $grp) {
$this->notifier->toGroup($this->user, $grp, $subject, $message, $params);
}
$this->notifier->sendNewDocumentMail($document, $this->user);
}
return "201 Created";
}