mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 15:14:58 +00:00
move more emails into class NotificationService
This commit is contained in:
parent
7f417157f8
commit
33c6436c16
|
@ -302,6 +302,126 @@ class SeedDMS_NotificationService {
|
||||||
|
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This notification is sent when a document is deleted.
|
||||||
|
* Keep in mind that $document refers to a document which has just been
|
||||||
|
* deleted from the database, but all the data needed is still in the
|
||||||
|
* object.
|
||||||
|
*/
|
||||||
|
public function sendDeleteDocumentMail($document, $user) { /* {{{ */
|
||||||
|
$folder = $document->getFolder();
|
||||||
|
$dnl = $document->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)
|
||||||
|
);
|
||||||
|
$subject = "document_deleted_email_subject";
|
||||||
|
$message = "document_deleted_email_body";
|
||||||
|
$params = array();
|
||||||
|
$params['name'] = $document->getName();
|
||||||
|
$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.ViewFolder.php?folderid=".$folder->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);
|
||||||
|
}
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This notification is sent when a new folder is created.
|
||||||
|
*/
|
||||||
|
public function sendNewFolderMail($folder, $user) { /* {{{ */
|
||||||
|
$parent = $folder->getParent();
|
||||||
|
$fnl = $parent->getNotifyList();
|
||||||
|
$snl = $folder->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'] = $folder->getName();
|
||||||
|
$params['folder_name'] = $parent->getName();
|
||||||
|
$params['folder_path'] = $parent->getFolderPathPlain();
|
||||||
|
$params['username'] = $user->getFullName();
|
||||||
|
$params['comment'] = $folder->getComment();
|
||||||
|
$params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewFolder.php?folderid=".$folder->getID();
|
||||||
|
$params['sitename'] = $this->settings->_siteName;
|
||||||
|
$params['http_root'] = $this->settings->_httpRoot;
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This notification is sent when a folder is deleted.
|
||||||
|
* Keep in mind that $folder refers to a folder which has just been
|
||||||
|
* deleted from the database, but all the data needed is still in the
|
||||||
|
* object.
|
||||||
|
*/
|
||||||
|
public function sendDeleteFolderMail($folder, $user) { /* {{{ */
|
||||||
|
$parent = $folder->getParent();
|
||||||
|
$fnl = $folder->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)
|
||||||
|
);
|
||||||
|
|
||||||
|
$subject = "folder_deleted_email_subject";
|
||||||
|
$message = "folder_deleted_email_body";
|
||||||
|
$params = array();
|
||||||
|
$params['name'] = $folder->getName();
|
||||||
|
$params['folder_path'] = $parent->getFolderPathPlain();
|
||||||
|
$params['username'] = $user->getFullName();
|
||||||
|
$params['sitename'] = $this->settings->_siteName;
|
||||||
|
$params['http_root'] = $this->settings->_httpRoot;
|
||||||
|
$params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewFolder.php?folderid=".$parent->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);
|
||||||
|
}
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This notification is sent when a new attachment is created.
|
||||||
|
*/
|
||||||
|
public function sendNewFileMail($file, $user) { /* {{{ */
|
||||||
|
$document = $file->getDocument();
|
||||||
|
$folder = $document->getFolder();
|
||||||
|
$notifyList = $document->getNotifyList();
|
||||||
|
|
||||||
|
$subject = "new_file_email_subject";
|
||||||
|
$message = "new_file_email_body";
|
||||||
|
$params = array();
|
||||||
|
$params['name'] = $file->getName();
|
||||||
|
$params['document'] = $document->getName();
|
||||||
|
$params['folder_name'] = $folder->getName();
|
||||||
|
$params['folder_path'] = $folder->getFolderPathPlain();
|
||||||
|
$params['username'] = $user->getFullName();
|
||||||
|
$params['comment'] = $file->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;
|
||||||
|
// if user is not owner and owner not already in list of notifiers, then
|
||||||
|
// send notification to owner
|
||||||
|
if ($user->getID() != $document->getOwner()->getID() &&
|
||||||
|
false === SeedDMS_Core_DMS::inList($document->getOwner(), $notifyList['users'])) {
|
||||||
|
$this->toIndividual($user, $document->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER);
|
||||||
|
}
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
public function sendChangedExpiryMail($document, $user, $oldexpires) { /* {{{ */
|
public function sendChangedExpiryMail($document, $user, $oldexpires) { /* {{{ */
|
||||||
$folder = $document->getFolder();
|
$folder = $document->getFolder();
|
||||||
$notifyList = $document->getNotifyList();
|
$notifyList = $document->getNotifyList();
|
||||||
|
|
|
@ -111,22 +111,7 @@ for ($file_num=0;$file_num<count($_FILES["userfile"]["tmp_name"]);$file_num++){
|
||||||
} else {
|
} else {
|
||||||
// Send notification to subscribers.
|
// Send notification to subscribers.
|
||||||
if($notifier) {
|
if($notifier) {
|
||||||
$notifyList = $document->getNotifyList();
|
$notifier->sendNewFileMail($res, $user);
|
||||||
|
|
||||||
$subject = "new_file_email_subject";
|
|
||||||
$message = "new_file_email_body";
|
|
||||||
$params = array();
|
|
||||||
$params['name'] = $name;
|
|
||||||
$params['document'] = $document->getName();
|
|
||||||
$params['username'] = $user->getFullName();
|
|
||||||
$params['comment'] = $comment;
|
|
||||||
$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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,5 +120,4 @@ add_log_line("?name=".$name."&documentid=".$documentid);
|
||||||
|
|
||||||
header("Location:../out/out.ViewDocument.php?documentid=".$documentid."¤ttab=attachments");
|
header("Location:../out/out.ViewDocument.php?documentid=".$documentid."¤ttab=attachments");
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -121,6 +121,8 @@ if(!$subFolder = $controller->run()) {
|
||||||
} else {
|
} else {
|
||||||
// Send notification to subscribers.
|
// Send notification to subscribers.
|
||||||
if($notifier) {
|
if($notifier) {
|
||||||
|
$notifier->sendNewFolderMail($subFolder, $user);
|
||||||
|
/*
|
||||||
$fnl = $folder->getNotifyList();
|
$fnl = $folder->getNotifyList();
|
||||||
$snl = $subFolder->getNotifyList();
|
$snl = $subFolder->getNotifyList();
|
||||||
$nl = array(
|
$nl = array(
|
||||||
|
@ -143,6 +145,7 @@ if(!$subFolder = $controller->run()) {
|
||||||
foreach ($nl["groups"] as $grp) {
|
foreach ($nl["groups"] as $grp) {
|
||||||
$notifier->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION);
|
$notifier->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ if (isset($_COOKIE["mydms_session"])) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if($settings->_enableEmail) {
|
if($settings->_enableEmail) {
|
||||||
$notifier->addService(new SeedDMS_EmailNotify($dms, $settings->_smtpSendFrom, $settings->_smtpServer, $settings->_smtpPort, $settings->_smtpUser, $settings->_smtpPassword));
|
$notifier->addService(new SeedDMS_EmailNotify($dms, $settings->_smtpSendFrom, $settings->_smtpServer, $settings->_smtpPort, $settings->_smtpUser, $settings->_smtpPassword), 'email');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($GLOBALS['SEEDDMS_HOOKS']['notification'])) {
|
if(isset($GLOBALS['SEEDDMS_HOOKS']['notification'])) {
|
||||||
|
@ -507,19 +507,7 @@ switch($command) {
|
||||||
|
|
||||||
if($folder->remove()) {
|
if($folder->remove()) {
|
||||||
if ($notifier) {
|
if ($notifier) {
|
||||||
$subject = "folder_deleted_email_subject";
|
$notifier->sendDeleteFolderMail($folder, $user);
|
||||||
$message = "folder_deleted_email_body";
|
|
||||||
$params = array();
|
|
||||||
$params['name'] = $foldername;
|
|
||||||
$params['folder_path'] = $parent->getFolderPathPlain();
|
|
||||||
$params['username'] = $user->getFullName();
|
|
||||||
$params['sitename'] = $settings->_siteName;
|
|
||||||
$params['http_root'] = $settings->_httpRoot;
|
|
||||||
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewFolder.php?folderid=".$parent->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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo json_encode(array('success'=>true, 'message'=>'', 'data'=>''));
|
echo json_encode(array('success'=>true, 'message'=>'', 'data'=>''));
|
||||||
|
@ -553,10 +541,6 @@ switch($command) {
|
||||||
/* Get the notify list before removing the document */
|
/* Get the notify list before removing the document */
|
||||||
$dnl = $document->getNotifyList();
|
$dnl = $document->getNotifyList();
|
||||||
$fnl = $folder->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 = $document->getName();
|
$docname = $document->getName();
|
||||||
|
|
||||||
$controller = Controller::factory('RemoveDocument', array('dms'=>$dms, 'user'=>$user));
|
$controller = Controller::factory('RemoveDocument', array('dms'=>$dms, 'user'=>$user));
|
||||||
|
@ -564,18 +548,10 @@ switch($command) {
|
||||||
$controller->setParam('fulltextservice', $fulltextservice);
|
$controller->setParam('fulltextservice', $fulltextservice);
|
||||||
if($controller->run()) {
|
if($controller->run()) {
|
||||||
if ($notifier){
|
if ($notifier){
|
||||||
$subject = "document_deleted_email_subject";
|
/* $document still has the data from the just deleted document,
|
||||||
$message = "document_deleted_email_body";
|
* which is just enough to send the email.
|
||||||
$params = array();
|
*/
|
||||||
$params['name'] = $docname;
|
$notifier->sendDeleteDocumentMail($document, $user);
|
||||||
$params['folder_path'] = $folder->getFolderPathPlain();
|
|
||||||
$params['username'] = $user->getFullName();
|
|
||||||
$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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
@ -844,7 +820,7 @@ switch($command) {
|
||||||
}
|
}
|
||||||
break; /* }}} */
|
break; /* }}} */
|
||||||
|
|
||||||
case 'indexdocument': /* {{{ */
|
case 'indexdocument':
|
||||||
case 'indexfolder': /* {{{ */
|
case 'indexfolder': /* {{{ */
|
||||||
if($user && $user->isAdmin()) {
|
if($user && $user->isAdmin()) {
|
||||||
if($fulltextservice) {
|
if($fulltextservice) {
|
||||||
|
|
|
@ -69,13 +69,11 @@ $previewer->deleteDocumentPreviews($document);
|
||||||
|
|
||||||
/* Get the notify list before removing the document
|
/* Get the notify list before removing the document
|
||||||
* Also inform the users/groups of the parent folder
|
* Also inform the users/groups of the parent folder
|
||||||
|
* Getting the list now will keep them in the document object
|
||||||
|
* even after the document has been deleted.
|
||||||
*/
|
*/
|
||||||
$dnl = $document->getNotifyList();
|
$dnl = $document->getNotifyList();
|
||||||
$fnl = $folder->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 = $document->getName();
|
$docname = $document->getName();
|
||||||
|
|
||||||
$controller->setParam('document', $document);
|
$controller->setParam('document', $document);
|
||||||
|
@ -89,19 +87,10 @@ if(!$controller->run()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($notifier){
|
if ($notifier){
|
||||||
$subject = "document_deleted_email_subject";
|
/* $document still has the data from the just deleted document,
|
||||||
$message = "document_deleted_email_body";
|
* which is just enough to send the email.
|
||||||
$params = array();
|
*/
|
||||||
$params['name'] = $docname;
|
$notifier->sendDeleteDocumentMail($document, $user);
|
||||||
$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.ViewFolder.php?folderid=".$folder->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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_rm_document')));
|
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_rm_document')));
|
||||||
|
|
|
@ -85,6 +85,8 @@ if(!$controller->run()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($notifier) {
|
if ($notifier) {
|
||||||
|
$notifier->sendDeleteFolderMail($folder, $user);
|
||||||
|
/*
|
||||||
$subject = "folder_deleted_email_subject";
|
$subject = "folder_deleted_email_subject";
|
||||||
$message = "folder_deleted_email_body";
|
$message = "folder_deleted_email_body";
|
||||||
$params = array();
|
$params = array();
|
||||||
|
@ -98,6 +100,7 @@ if ($notifier) {
|
||||||
foreach ($nl["groups"] as $grp) {
|
foreach ($nl["groups"] as $grp) {
|
||||||
$notifier->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION);
|
$notifier->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
add_log_line("?folderid=".$folderid."&name=".$foldername);
|
add_log_line("?folderid=".$folderid."&name=".$foldername);
|
||||||
|
|
|
@ -72,32 +72,7 @@ if (!$version->setWorkflow($workflow, $user)){
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($notifier) {
|
if ($notifier) {
|
||||||
$nl = $document->getNotifyList();
|
$notifier->sendRequestWorkflowActionMail($version, $user);
|
||||||
$folder = $document->getFolder();
|
|
||||||
|
|
||||||
if($settings->_enableNotificationWorkflow) {
|
|
||||||
$subject = "request_workflow_action_email_subject";
|
|
||||||
$message = "request_workflow_action_email_body";
|
|
||||||
$params = array();
|
|
||||||
$params['name'] = $document->getName();
|
|
||||||
$params['version'] = $version->getVersion();
|
|
||||||
$params['workflow'] = $workflow->getName();
|
|
||||||
$params['folder_path'] = $folder->getFolderPathPlain();
|
|
||||||
$params['current_state'] = $workflow->getInitState()->getName();
|
|
||||||
$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();
|
|
||||||
|
|
||||||
foreach($workflow->getNextTransitions($workflow->getInitState()) as $ntransition) {
|
|
||||||
foreach($ntransition->getUsers() as $tuser) {
|
|
||||||
$notifier->toIndividual($user, $tuser->getUser(), $subject, $message, $params, SeedDMS_NotificationService::RECV_WORKFLOW);
|
|
||||||
}
|
|
||||||
foreach($ntransition->getGroups() as $tuser) {
|
|
||||||
$notifier->toGroup($user, $tuser->getGroup(), $subject, $message, $params, SeedDMS_NotificationService::RECV_WORKFLOW);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
add_log_line("?documentid=".$documentid);
|
add_log_line("?documentid=".$documentid);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user