mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-09-06 10:00:58 +00:00
move sending notification into sendChangedVersionAttributesMail()
This commit is contained in:
parent
f969669356
commit
30880c0539
|
@ -683,6 +683,64 @@ class SeedDMS_NotificationService {
|
|||
}
|
||||
} /* }}} */
|
||||
|
||||
public function sendChangedVersionAttributesMail($version, $user, $oldattributes) { /* {{{ */
|
||||
$document = $version->getDocument();
|
||||
$dms = $document->getDMS();
|
||||
$folder = $document->getFolder();
|
||||
$notifyList = $document->getNotifyList();
|
||||
|
||||
$newattributes = $version->getAttributes();
|
||||
if($oldattributes) {
|
||||
foreach($oldattributes as $attrdefid=>$attribute) {
|
||||
if(!isset($newattributes[$attrdefid]) || $newattributes[$attrdefid]->getValueAsArray() !== $oldattributes[$attrdefid]->getValueAsArray()) {
|
||||
$subject = "attribute_changed_email_subject";
|
||||
$message = "attribute_changed_email_body";
|
||||
$params = array();
|
||||
$params['name'] = $document->getName();
|
||||
$params['version'] = $version->getVersion();
|
||||
$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 = "attribute_changed_email_subject";
|
||||
$message = "attribute_changed_email_body";
|
||||
$params = array();
|
||||
$params['name'] = $document->getName();
|
||||
$params['version'] = $version->getVersion();
|
||||
$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 sendChangedFolderAttributesMail($folder, $user, $oldattributes) { /* {{{ */
|
||||
$dms = $folder->getDMS();
|
||||
$notifyList = $folder->getNotifyList();
|
||||
|
|
|
@ -123,61 +123,8 @@ if($attributes) {
|
|||
}
|
||||
}
|
||||
|
||||
$newattributes = $version->getAttributes();
|
||||
if($oldattributes) {
|
||||
foreach($oldattributes as $attrdefid=>$attribute) {
|
||||
if(!isset($newattributes[$attrdefid]) || $newattributes[$attrdefid]->getValueAsArray() !== $oldattributes[$attrdefid]->getValueAsArray()) {
|
||||
if($notifier) {
|
||||
$notifyList = $document->getNotifyList();
|
||||
$subject = "attribute_changed_email_subject";
|
||||
$message = "attribute_changed_email_body";
|
||||
$params = array();
|
||||
$params['name'] = $document->getName();
|
||||
$params['version'] = $version->getVersion();
|
||||
$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 = "attribute_changed_email_subject";
|
||||
$message = "attribute_changed_email_body";
|
||||
$params = array();
|
||||
$params['name'] = $document->getName();
|
||||
$params['version'] = '';
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($notifier) {
|
||||
$notifier->sendChangedVersionAttributesMail($version, $user, $oldattributes);
|
||||
}
|
||||
|
||||
add_log_line("?documentid=".$documentid);
|
||||
|
|
Loading…
Reference in New Issue
Block a user