move sending mails into NotificationService

This commit is contained in:
Uwe Steinmann 2021-05-15 12:17:07 +02:00
parent 07b8ab9706
commit 7f417157f8
7 changed files with 244 additions and 293 deletions

View File

@ -110,15 +110,12 @@ class SeedDMS_NotificationService {
*/
public function toGroup($sender, $groupRecipient, $subject, $message, $params=array(), $recvtype=0) { /* {{{ */
$error = true;
foreach($this->services as $name => $service) {
$ret = true;
foreach ($groupRecipient->getUsers() as $recipient) {
$ret &= $this->toIndividual($sender, $recipient, $subject, $message, $params, $recvtype);
}
$this->errors[$name] = $ret;
if(!$ret) {
$error = false;
}
$ret = true;
foreach ($groupRecipient->getUsers() as $recipient) {
$ret &= $this->toIndividual($sender, $recipient, $subject, $message, $params, $recvtype);
}
if(!$ret) {
$error = false;
}
return $error;
} /* }}} */
@ -138,15 +135,12 @@ class SeedDMS_NotificationService {
*/
public function toList($sender, $recipients, $subject, $message, $params=array(), $recvtype=0) { /* {{{ */
$error = true;
foreach($this->services as $name => $service) {
$ret = true;
foreach ($recipients as $recipient) {
$ret &= $this->toIndividual($sender, $recipient, $subject, $message, $params, $recvtype);
}
$this->errors[$name] = $ret;
if(!$ret) {
$error = false;
}
$ret = true;
foreach ($recipients as $recipient) {
$ret &= $this->toIndividual($sender, $recipient, $subject, $message, $params, $recvtype);
}
if(!$ret) {
$error = false;
}
return $error;
} /* }}} */
@ -323,6 +317,12 @@ class SeedDMS_NotificationService {
$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);
@ -330,5 +330,209 @@ class SeedDMS_NotificationService {
}
} /* }}} */
public function sendChangedAttributesMail($document, $user, $oldattributes) { /* {{{ */
$folder = $document->getFolder();
$notifyList = $document->getNotifyList();
$newattributes = $document->getAttributes();
if($oldattributes) {
foreach($oldattributes as $attrdefid=>$attribute) {
if(!isset($newattributes[$attrdefid]) || $newattributes[$attrdefid]->getValueAsArray() !== $oldattributes[$attrdefid]->getValueAsArray()) {
$subject = "document_attribute_changed_email_subject";
$message = "document_attribute_changed_email_body";
$params = array();
$params['name'] = $document->getName();
$params['attribute_name'] = $attribute->getAttributeDefinition()->getName();
$params['attribute_old_value'] = $oldattributes[$attrdefid]->getValue();
$params['attribute_new_value'] = isset($newattributes[$attrdefid]) ? $newattributes[$attrdefid]->getValue() : '';
$params['folder_path'] = $folder->getFolderPathPlain();
$params['username'] = $user->getFullName();
$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);
}
}
}
}
/* Check for new attributes which didn't have a value before */
if($newattributes) {
foreach($newattributes as $attrdefid=>$attribute) {
if(!isset($oldattributes[$attrdefid]) && $attribute) {
$subject = "document_attribute_changed_email_subject";
$message = "document_attribute_changed_email_body";
$params = array();
$params['name'] = $document->getName();
$params['attribute_name'] = $dms->getAttributeDefinition($attrdefid)->getName();
$params['attribute_old_value'] = '';
$params['attribute_new_value'] = $attribute->getValue();
$params['folder_path'] = $folder->getFolderPathPlain();
$params['username'] = $user->getFullName();
$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);
}
}
}
}
} /* }}} */
public function sendChangedCommentMail($document, $user, $oldcomment) { /* {{{ */
if($oldcomment != $document->getComment()) {
$notifyList = $document->getNotifyList();
$folder = $document->getFolder();
$subject = "document_comment_changed_email_subject";
$message = "document_comment_changed_email_body";
$params = array();
$params['name'] = $document->getName();
$params['folder_path'] = $folder->getFolderPathPlain();
$params['old_comment'] = $oldcomment;
$params['new_comment'] = $document->getComment();
$params['username'] = $user->getFullName();
$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 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 sendChangedVersionCommentMail($content, $user, $oldcomment) { /* {{{ */
// FIXME: use extra mail template which includes the version
if($oldcomment != $content->getComment()) {
$document = $content->getDocument();
$notifyList = $document->getNotifyList();
$folder = $document->getFolder();
$subject = "document_comment_changed_email_subject";
$message = "document_comment_changed_email_body";
$params = array();
$params['name'] = $document->getName();
$params['folder_path'] = $folder->getFolderPathPlain();
$params['old_comment'] = $oldcomment;
$params['new_comment'] = $content->getComment();
$params['username'] = $user->getFullName();
$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 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 sendChangedNameMail($document, $user, $oldname) { /* {{{ */
if($oldname != $document->getName()) {
$notifyList = $document->getNotifyList();
$folder = $document->getFolder();
$subject = "document_renamed_email_subject";
$message = "document_renamed_email_body";
$params = array();
$params['name'] = $document->getName();
$params['old_name'] = $oldname;
$params['folder_path'] = $folder->getFolderPathPlain();
$params['username'] = $user->getFullName();
$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 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) {
$notifier->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION);
}
}
} /* }}} */
public function sendMovedDocumentMail($document, $user, $oldfolder) { /* {{{ */
$targetfolder = $document->getFolder();
if($targetfolder->getId() == $oldfolder->getId())
return;
$nl1 = $oldfolder->getNotifyList();
$nl2 = $document->getNotifyList();
$nl3 = $targetfolder->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'] = $document->getName();
$params['old_folder_path'] = $oldfolder->getFolderPathPlain();
$params['new_folder_path'] = $targetfolder->getFolderPathPlain();
$params['username'] = $user->getFullName();
$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, $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);
}
// if user is not owner 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);
}
} /* }}} */
public function sendMovedFolderMail($folder, $user, $oldfolder) { /* {{{ */
$targetfolder = $folder->getParent();
if($targetfolder->getId() == $oldfolder->getId())
return;
$nl1 = $oldfolder->getNotifyList();
$nl2 = $folder->getNotifyList();
$nl3 = $targetfolder->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'] = $folder->getName();
$params['old_folder_path'] = $oldfolder->getFolderPathPlain();
$params['new_folder_path'] = $targetfolder->getFolderPathPlain();
$params['username'] = $user->getFullName();
$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);
}
// if user is not owner send notification to owner
if ($user->getID() != $folder->getOwner()->getID() &&
false === SeedDMS_Core_DMS::inList($folder->getOwner(), $notifyList['users'])) {
$this->toIndividual($user, $folder->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER);
}
} /* }}} */
}

View File

@ -310,7 +310,11 @@ switch($command) {
if ($mfolder->getAccessMode($user, 'moveFolder') >= M_READWRITE) {
if($folder = $dms->getFolder($_REQUEST['targetfolderid'])) {
if($folder->getAccessMode($user, 'moveFolder') >= M_READWRITE) {
$oldFolder = $mfolder->getParent();
if($mfolder->setParent($folder)) {
if($notifier) {
$notifier->sendMovedFolderMail($mfolder, $user, $oldFolder);
}
header('Content-Type: application/json');
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_move_folder'), 'data'=>''));
add_log_line();
@ -349,10 +353,14 @@ switch($command) {
if ($mdocument->getAccessMode($user, 'moveDocument') >= M_READWRITE) {
if($folder = $dms->getFolder($_REQUEST['targetfolderid'])) {
if($folder->getAccessMode($user, 'moveDocument') >= M_READWRITE) {
$oldFolder = $mdocument->getFolder();
if($mdocument->setFolder($folder)) {
if(isset($_REQUEST['sequence'])) {
$mdocument->setSequence((float) $_REQUEST['sequence']);
}
if($notifier) {
$notifier->sendMovedDocumentMail($mdocument, $user, $oldFolder);
}
header('Content-Type: application/json');
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_move_document'), 'data'=>''));
add_log_line();
@ -634,10 +642,14 @@ switch($command) {
$document = $dms->getDocument($_REQUEST['id']);
if($document) {
if ($document->getAccessMode($user) >= M_READWRITE) {
$oldname = $document->getName();
if (!$document->setName($_REQUEST['name'])) {
header('Content-Type: application/json');
echo json_encode(array('success'=>false, 'message'=>'Error setting name', 'data'=>''));
} else {
if($notifier) {
$notifier->sendChangedNameMail($document, $user, $oldname);
}
header('Content-Type: application/json');
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_document_name_changed'), 'data'=>''));
add_log_line();

View File

@ -68,46 +68,7 @@ $comment = $_POST["comment"];
if (($oldcomment = $version->getComment()) != $comment) {
if($version->setComment($comment)) {
if($notifier) {
$notifyList = $document->getNotifyList();
$folder = $document->getFolder();
/*
$subject = "###SITENAME###: ".$document->getName().", v.".$version->_version." - ".getMLText("document_comment_changed_email");
$message = getMLText("document_comment_changed_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("version").": ".$version->_version."\r\n".
getMLText("comment").": ".$comment."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() .">\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."&version=".$version->_version."\r\n";
if(isset($document->_notifyList["users"])) {
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
}
if(isset($document->_notifyList["groups"])) {
foreach ($document->_notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
}
*/
$subject = "document_comment_changed_email_subject";
$message = "document_comment_changed_email_body";
$params = array();
$params['name'] = $document->getName();
$params['version'] = $version->getVersion();
$params['folder_path'] = $folder->getFolderPathPlain();
$params['username'] = $user->getFullName();
$params['new_comment'] = $comment;
$params['old_comment'] = $oldcomment;
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID()."&version=".$version->getVersion();
$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->sendChangedVersionCommentMail($version, $user, $oldcomment);
}
}
else {

View File

@ -148,146 +148,14 @@ if(!$controller->run()) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())), $errmsg);
}
if ($oldname != $name) {
// Send notification to subscribers.
if($notifier) {
$notifyList = $document->getNotifyList();
$folder = $document->getFolder();
$subject = "document_renamed_email_subject";
$message = "document_renamed_email_body";
$params = array();
$params['name'] = $document->getName();
$params['old_name'] = $oldname;
$params['folder_path'] = $folder->getFolderPathPlain();
$params['username'] = $user->getFullName();
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
if($notifier) {
$notifier->sendChangedNameMail($document, $user, $oldname);
// if user is not owner send notification to owner
if ($user->getID() != $document->getOwner()->getID() &&
false === SeedDMS_Core_DMS::inList($document->getOwner(), $notifyList['users'])) {
$notifier->toIndividual($user, $document->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER);
}
$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->sendChangedCommentMail($document, $user, $oldcomment);
if ($oldcomment != $comment) {
// Send notification to subscribers.
if($notifier) {
$notifyList = $document->getNotifyList();
$folder = $document->getFolder();
$subject = "document_comment_changed_email_subject";
$message = "document_comment_changed_email_body";
$params = array();
$params['name'] = $document->getName();
$params['folder_path'] = $folder->getFolderPathPlain();
$params['old_comment'] = $oldcomment;
$params['new_comment'] = $comment;
$params['username'] = $user->getFullName();
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
$notifier->sendChangedExpiryMail($document, $user, $oldexpires);
// if user is not owner send notification to owner
if ($user->getID() != $document->getOwner()->getID() &&
false === SeedDMS_Core_DMS::inList($document->getOwner(), $notifyList['users'])) {
$notifier->toIndividual($user, $document->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER);
}
$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);
}
}
}
if ($expires != $oldexpires) {
if($notifier) {
$notifyList = $document->getNotifyList();
$folder = $document->getFolder();
// Send notification to subscribers.
$subject = "expiry_changed_email_subject";
$message = "expiry_changed_email_body";
$params = array();
$params['name'] = $document->getName();
$params['folder_path'] = $folder->getFolderPathPlain();
$params['username'] = $user->getFullName();
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$params['sitename'] = $settings->_siteName;
$params['http_root'] = $settings->_httpRoot;
// if user is not owner send notification to owner
if ($user->getID() != $document->getOwner()->getID() &&
false === SeedDMS_Core_DMS::inList($document->getOwner(), $notifyList['users'])) {
$notifier->toIndividual($user, $document->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER);
}
$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);
}
}
}
if ($oldkeywords != $keywords) {
}
$newattributes = $document->getAttributes();
if($oldattributes) {
foreach($oldattributes as $attrdefid=>$attribute) {
if(!isset($newattributes[$attrdefid]) || $newattributes[$attrdefid]->getValueAsArray() !== $oldattributes[$attrdefid]->getValueAsArray()) {
if($notifier) {
$notifyList = $document->getNotifyList();
$subject = "document_attribute_changed_email_subject";
$message = "document_attribute_changed_email_body";
$params = array();
$params['name'] = $document->getName();
$params['attribute_name'] = $attribute->getAttributeDefinition()->getName();
$params['attribute_old_value'] = $oldattributes[$attrdefid]->getValue();
$params['attribute_new_value'] = isset($newattributes[$attrdefid]) ? $newattributes[$attrdefid]->getValue() : '';
$params['folder_path'] = $folder->getFolderPathPlain();
$params['username'] = $user->getFullName();
$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);
}
}
}
}
}
/* Check for new attributes which didn't have a value before */
if($newattributes) {
foreach($newattributes as $attrdefid=>$attribute) {
if(!isset($oldattributes[$attrdefid]) && $attribute) {
if($notifier) {
$notifyList = $document->getNotifyList();
$subject = "document_attribute_changed_email_subject";
$message = "document_attribute_changed_email_body";
$params = array();
$params['name'] = $document->getName();
$params['attribute_name'] = $dms->getAttributeDefinition($attrdefid)->getName();
$params['attribute_old_value'] = '';
$params['attribute_new_value'] = $attribute->getValue();
$params['folder_path'] = $folder->getFolderPathPlain();
$params['username'] = $user->getFullName();
$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->sendChangedAttributesMail($document, $user, $oldattributes);
}
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_document_edited')));

View File

@ -56,30 +56,7 @@ foreach($clipboard['docs'] as $documentid) {
if ($document->setFolder($targetFolder)) {
// Send notification to subscribers.
if($notifier) {
$nl1 = $oldFolder->getNotifyList();
$nl2 = $document->getNotifyList();
$nl3 = $targetFolder->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'] = $document->getName();
$params['old_folder_path'] = $oldFolder->getFolderPathPlain();
$params['new_folder_path'] = $targetFolder->getFolderPathPlain();
$params['username'] = $user->getFullName();
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$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);
}
// if user is not owner send notification to owner
// if ($user->getID() != $document->getOwner()->getID())
// $notifier->toIndividual($user, $document->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER);
$notifier->sendMovedDocumentMail($document, $user, $oldFolder);
}
$session->removeFromClipboard($document);
@ -103,31 +80,7 @@ foreach($clipboard['folders'] as $folderid) {
if ($folder->setParent($targetFolder)) {
// Send notification to subscribers.
if($notifier) {
$nl1 = $oldFolder->getNotifyList();
$nl2 = $folder->getNotifyList();
$nl3 = $targetFolder->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'] = $folder->getName();
$params['old_folder_path'] = $oldFolder->getFolderPathPlain();
$params['new_folder_path'] = $targetFolder->getFolderPathPlain();
$params['username'] = $user->getFullName();
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewFolder.php?folderid=".$folder->getID();
$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);
}
// if user is not owner send notification to owner
// if ($user->getID() != $folder->getOwner()->getID())
// $notifier->toIndividual($user, $folder->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER);
$notifier->sendMovedFolderMail($folder, $user, $oldFolder);
}
$session->removeFromClipboard($folder);
} else {

View File

@ -82,30 +82,7 @@ if(!$settings->_enableDuplicateDocNames) {
if ($document->setFolder($targetFolder)) {
// Send notification to subscribers.
if($notifier) {
$nl1 = $oldFolder->getNotifyList();
$nl2 = $document->getNotifyList();
$nl3 = $targetFolder->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'] = $document->getName();
$params['old_folder_path'] = $oldFolder->getFolderPathPlain();
$params['new_folder_path'] = $targetFolder->getFolderPathPlain();
$params['username'] = $user->getFullName();
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID();
$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);
}
// if user is not owner send notification to owner
// if ($user->getID() != $document->getOwner()->getID())
// $notifier->toIndividual($user, $document->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER);
$notifier->sendMovedDocumentMail($document, $user, $oldFolder);
}
} else {

View File

@ -81,31 +81,7 @@ if(!$settings->_enableDuplicateSubFolderNames) {
if ($folder->setParent($targetFolder)) {
// Send notification to subscribers.
if($notifier) {
$nl1 = $oldFolder->getNotifyList();
$nl2 = $folder->getNotifyList();
$nl3 = $targetFolder->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'] = $folder->getName();
$params['old_folder_path'] = $oldFolder->getFolderPathPlain();
$params['new_folder_path'] = $targetFolder->getFolderPathPlain();
$params['username'] = $user->getFullName();
$params['url'] = getBaseUrl().$settings->_httpRoot."out/out.ViewFolder.php?folderid=".$folder->getID();
$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);
}
// if user is not owner send notification to owner
//if ($user->getID() != $folder->getOwner()->getID())
// $notifier->toIndividual($user, $folder->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER);
$notifier->sendMovedFolderMail($folder, $user, $oldFolder);
}
} else {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("error_occured"));