diff --git a/SeedDMS_Core/Core/inc.ClassDocument.php b/SeedDMS_Core/Core/inc.ClassDocument.php index 72a9bb9a7..ffc181968 100644 --- a/SeedDMS_Core/Core/inc.ClassDocument.php +++ b/SeedDMS_Core/Core/inc.ClassDocument.php @@ -3944,6 +3944,35 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ return M_NONE; } /* }}} */ + /** + * Return a list of all reviewers separated by individuals and groups + * + * @return array|bool|null + */ + function getReviewers() { /* {{{ */ + $dms = $this->_document->getDMS(); + $db = $dms->getDB(); + + $queryStr= + "SELECT * FROM `tblDocumentReviewers` WHERE `version`='".$this->_version + ."' AND `documentID` = '". $this->_document->getID() ."' "; + + $recs = $db->getResultArray($queryStr); + if (is_bool($recs)) + return false; + $reviewers = array('i'=>array(), 'g'=>array()); + foreach($recs as $rec) { + if($rec['type'] == 0) { + if($u = $dms->getUser($rec['required'])) + $reviewers['i'][] = $u; + } elseif($rec['type'] == 1) { + if($g = $dms->getGroup($rec['required'])) + $reviewers['g'][] = $g; + } + } + return $reviewers; + } /* }}} */ + /** * Get the current review status of the document content * The review status is a list of reviews and its current status @@ -4072,6 +4101,35 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */ return true; } /* }}} */ + /** + * Return a list of all approvers separated by individuals and groups + * + * @return array|bool|null + */ + function getApprovers() { /* {{{ */ + $dms = $this->_document->getDMS(); + $db = $dms->getDB(); + + $queryStr= + "SELECT * FROM `tblDocumentApprovers` WHERE `version`='".$this->_version + ."' AND `documentID` = '". $this->_document->getID() ."' "; + + $recs = $db->getResultArray($queryStr); + if (is_bool($recs)) + return false; + $approvers = array('i'=>array(), 'g'=>array()); + foreach($recs as $rec) { + if($rec['type'] == 0) { + if($u = $dms->getUser($rec['required'])) + $approvers['i'][] = $u; + } elseif($rec['type'] == 1) { + if($g = $dms->getGroup($rec['required'])) + $approvers['g'][] = $g; + } + } + return $approvers; + } /* }}} */ + /** * Get the current approval status of the document content * The approval status is a list of approvals and its current status diff --git a/SeedDMS_Core/package.xml b/SeedDMS_Core/package.xml index 3c65c7dde..053b1c7db 100644 --- a/SeedDMS_Core/package.xml +++ b/SeedDMS_Core/package.xml @@ -1902,6 +1902,7 @@ add method SeedDMS_Core_DatabaseAccess::setLogFp() GPL License - SeedDMS_Core_DMS::getTimeline() uses status log instead of document content +- add methods SeedDMS_Core_DocumentContent::getReviewers() and SeedDMS_Core_DocumentContent::getApprovers() diff --git a/inc/inc.ClassNotificationService.php b/inc/inc.ClassNotificationService.php index 971c32419..a6d495fe9 100644 --- a/inc/inc.ClassNotificationService.php +++ b/inc/inc.ClassNotificationService.php @@ -36,6 +36,11 @@ class SeedDMS_NotificationService { */ protected $logger; + /* + * Configuration + */ + protected $settings; + /* * Possible types of receivers */ @@ -48,28 +53,29 @@ class SeedDMS_NotificationService { const RECV_REVISOR = 6; const RECV_RECIPIENT = 7; - public function __construct($logger = null) { + public function __construct($logger = null, $settings = null) { /* {{{ */ $this->services = array(); $this->errors = array(); $this->logger = $logger; - } + $this->settings = $settings; + } /* }}} */ - public function addService($service, $name='') { + public function addService($service, $name='') { /* {{{ */ if(!$name) $name = md5(uniqid()); $this->services[$name] = $service; $this->errors[$name] = true; - } + } /* }}} */ - public function getServices() { + public function getServices() { /* {{{ */ return $this->services; - } + } /* }}} */ - public function getErrors() { + public function getErrors() { /* {{{ */ return $this->errors; - } + } /* }}} */ - public function toIndividual($sender, $recipient, $subject, $message, $params=array(), $recvtype=0) { + public function toIndividual($sender, $recipient, $subject, $message, $params=array(), $recvtype=0) { /* {{{ */ $error = true; foreach($this->services as $name => $service) { /* Set $to to email address of user or the string passed in $recipient @@ -98,26 +104,23 @@ class SeedDMS_NotificationService { } } return $error; - } + } /* }}} */ /** * Send a notification to each user of a group * */ - public function toGroup($sender, $groupRecipient, $subject, $message, $params=array(), $recvtype=0) { + 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; - } + } /* }}} */ /** * Send a notification to a list of recipients @@ -132,20 +135,526 @@ class SeedDMS_NotificationService { * @param int $recvtype type of receiver * @return boolean true on success, otherwise false */ - public function toList($sender, $recipients, $subject, $message, $params=array(), $recvtype=0) { + 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; - } + } /* }}} */ + /** + * This notification is sent when a workflow action is needed. + */ + public function sendRequestWorkflowActionMail($content, $user) { /* {{{ */ + $document = $content->getDocument(); + $folder = $document->getFolder(); + + /* Send mail only if enabled in the configuration */ + if($this->settings->_enableNotificationWorkflow && ($workflow = $content->getWorkflow())) { + $subject = "request_workflow_action_email_subject"; + $message = "request_workflow_action_email_body"; + $params = array(); + $params['name'] = $document->getName(); + $params['version'] = $content->getVersion(); + $params['workflow'] = $workflow->getName(); + $params['folder_path'] = $folder->getFolderPathPlain(); + $params['current_state'] = $workflow->getInitState()->getName(); + $params['username'] = $user->getFullName(); + $params['sitename'] = $this->settings->_siteName; + $params['http_root'] = $this->settings->_httpRoot; + $params['url'] = getBaseUrl().$this->settings->_httpRoot."out/out.ViewDocument.php?documentid=".$document->getID(); + + foreach($workflow->getNextTransitions($workflow->getInitState()) as $ntransition) { + foreach($ntransition->getUsers() as $tuser) { + $this->toIndividual($user, $tuser->getUser(), $subject, $message, $params, SeedDMS_NotificationService::RECV_WORKFLOW); + } + foreach($ntransition->getGroups() as $tuser) { + $this->toGroup($user, $tuser->getGroup(), $subject, $message, $params, SeedDMS_NotificationService::RECV_WORKFLOW); + } + } + } + } /* }}} */ + + /** + * This notification is sent when a review or approval is needed. + */ + public function sendRequestRevAppActionMail($content, $user) { /* {{{ */ + $document = $content->getDocument(); + $folder = $document->getFolder(); + + if($this->settings->_enableNotificationAppRev) { + /* Reviewers and approvers will be informed about the new document */ + $reviewers = $content->getReviewers(); //$controller->getParam('reviewers'); + $approvers = $content->getApprovers(); //$controller->getParam('approvers'); + if($reviewers['i'] || $reviewers['g']) { + $subject = "review_request_email_subject"; + $message = "review_request_email_body"; + $params = array(); + $params['name'] = $document->getName(); + $params['folder_path'] = $folder->getFolderPathPlain(); + $params['version'] = $content->getVersion(); + $params['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; + + foreach($reviewers['i'] as $reviewer) { + $this->toIndividual($user, $reviewer, $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); + } + foreach($reviewers['g'] as $reviewergrp) { + $this->toGroup($user, $reviewergrp, $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); + } + } + + elseif($approvers['i'] || $approvers['g']) { + $subject = "approval_request_email_subject"; + $message = "approval_request_email_body"; + $params = array(); + $params['name'] = $document->getName(); + $params['folder_path'] = $folder->getFolderPathPlain(); + $params['version'] = $content->getVersion(); + $params['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; + + foreach($approvers['i'] as $approver) { + $this->toIndividual($user, $approver, $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); + } + foreach($approvers['g'] as $approvergrp) { + $this->toGroup($user, $approvergrp, $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); + } + } + } + } /* }}} */ + + /** + * This notification is sent when a new document is created. + */ + public function sendNewDocumentMail($document, $user) { /* {{{ */ + $folder = $document->getFolder(); + $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) + ); + + $lc = $document->getLatestContent(); + $subject = "new_document_email_subject"; + $message = "new_document_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_comment'] = $lc->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, $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->sendRequestWorkflowActionMail($lc, $user); + + $this->sendRequestRevAppActionMail($lc, $user); + + } /* }}} */ + + /** + * This notification is sent when a new document version is created. + */ + public function sendNewDocumentVersionMail($document, $user) { /* {{{ */ + $lc = $document->getLatestContent(); + $folder = $document->getFolder(); + $notifyList = $document->getNotifyList(); + + $subject = "document_updated_email_subject"; + $message = "document_updated_email_body"; + $params = array(); + $params['name'] = $document->getName(); + $params['folder_path'] = $folder->getFolderPathPlain(); + $params['username'] = $user->getFullName(); + $params['comment'] = $document->getComment(); + $params['version_comment'] = $lc->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); + } +// if user is not owner send notification to owner +// if ($user->getID() != $document->getOwner()->getID()) +// $this->toIndividual($user, $document->getOwner(), $subject, $message, $params, SeedDMS_NotificationService::RECV_OWNER); + + $this->sendRequestWorkflowActionMail($lc, $user); + + $this->sendRequestRevAppActionMail($lc, $user); + + } /* }}} */ + + /** + * 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) { /* {{{ */ + $folder = $document->getFolder(); + $notifyList = $document->getNotifyList(); + + if($oldexpires != $document->getExpires()) { + // 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().$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 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); + } + } /* }}} */ } diff --git a/inc/inc.Language.php b/inc/inc.Language.php index 5cf34a82d..78cfb3397 100644 --- a/inc/inc.Language.php +++ b/inc/inc.Language.php @@ -344,7 +344,7 @@ function getAttributeValidationError($error, $attrname='', $attrvalue='', $regex case 10: return array("attr_not_in_valueset", array('attrname'=>$attrname, 'value'=>$attrvalue)); break; - case 8: + case 9: return array("attr_malformed_date", array('attrname'=>$attrname, 'value'=>$attrvalue)); break; case 8: diff --git a/inc/inc.Notification.php b/inc/inc.Notification.php index cfc3ab615..e02404a13 100644 --- a/inc/inc.Notification.php +++ b/inc/inc.Notification.php @@ -13,7 +13,7 @@ */ global $logger; -$notifier = new SeedDMS_NotificationService($logger); +$notifier = new SeedDMS_NotificationService($logger, $settings); if(isset($GLOBALS['SEEDDMS_HOOKS']['notification'])) { foreach($GLOBALS['SEEDDMS_HOOKS']['notification'] as $notificationObj) { diff --git a/op/op.AddDocument.php b/op/op.AddDocument.php index d509ede4c..96182d67f 100644 --- a/op/op.AddDocument.php +++ b/op/op.AddDocument.php @@ -455,105 +455,7 @@ for ($file_num=0;$file_numgetNotifyList(); - $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'] = $user->getFullName(); - $params['comment'] = $comment; - $params['version_comment'] = $version_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, $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); - } - - /* Get workflow from controller in case it was modified in a hook */ - $workflow = $controller->getParam('workflow'); - if($workflow && $settings->_enableNotificationWorkflow) { - $subject = "request_workflow_action_email_subject"; - $message = "request_workflow_action_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['version'] = $reqversion; - $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); - } - } - } - - if($settings->_enableNotificationAppRev) { - /* Reviewers and approvers will be informed about the new document */ - /* Get reviewers and approvers from controller in case it was - * modified in a hook - */ - $reviewers = $controller->getParam('reviewers'); - $approvers = $controller->getParam('approvers'); - if($reviewers['i'] || $reviewers['g']) { - $subject = "review_request_email_subject"; - $message = "review_request_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $reqversion; - $params['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; - - foreach($reviewers['i'] as $reviewerid) { - $notifier->toIndividual($user, $dms->getUser($reviewerid), $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); - } - foreach($reviewers['g'] as $reviewergrpid) { - $notifier->toGroup($user, $dms->getGroup($reviewergrpid), $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); - } - } - - elseif($approvers['i'] || $approvers['g']) { - $subject = "approval_request_email_subject"; - $message = "approval_request_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $reqversion; - $params['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; - - foreach($approvers['i'] as $approverid) { - $notifier->toIndividual($user, $dms->getUser($approverid), $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); - } - foreach($approvers['g'] as $approvergrpid) { - $notifier->toGroup($user, $dms->getGroup($approvergrpid), $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); - } - } - } + $notifier->sendNewDocumentMail($document, $user); } if($settings->_removeFromDropFolder) { if(file_exists($userfiletmp)) { diff --git a/op/op.AddFile.php b/op/op.AddFile.php index 5f970afdd..305972af5 100644 --- a/op/op.AddFile.php +++ b/op/op.AddFile.php @@ -111,22 +111,7 @@ for ($file_num=0;$file_numgetNotifyList(); - - $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); - } + $notifier->sendNewFileMail($res, $user); } } } @@ -135,5 +120,4 @@ add_log_line("?name=".$name."&documentid=".$documentid); header("Location:../out/out.ViewDocument.php?documentid=".$documentid."¤ttab=attachments"); - ?> diff --git a/op/op.AddSubFolder.php b/op/op.AddSubFolder.php index a98c9d7ac..efac68b40 100644 --- a/op/op.AddSubFolder.php +++ b/op/op.AddSubFolder.php @@ -121,6 +121,8 @@ if(!$subFolder = $controller->run()) { } else { // Send notification to subscribers. if($notifier) { + $notifier->sendNewFolderMail($subFolder, $user); + /* $fnl = $folder->getNotifyList(); $snl = $subFolder->getNotifyList(); $nl = array( @@ -143,6 +145,7 @@ if(!$subFolder = $controller->run()) { foreach ($nl["groups"] as $grp) { $notifier->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); } + */ } } diff --git a/op/op.Ajax.php b/op/op.Ajax.php index f68bddfba..7a05bbd02 100644 --- a/op/op.Ajax.php +++ b/op/op.Ajax.php @@ -69,7 +69,7 @@ if (isset($_COOKIE["mydms_session"])) { $dms->noReadForStatus = $role->getNoAccess(); global $logger; - $notifier = new SeedDMS_NotificationService($logger); + $notifier = new SeedDMS_NotificationService($logger, $settings); if(isset($GLOBALS['SEEDDMS_HOOKS']['notification'])) { foreach($GLOBALS['SEEDDMS_HOOKS']['notification'] as $notificationObj) { if(method_exists($notificationObj, 'preAddService')) { @@ -79,7 +79,7 @@ if (isset($_COOKIE["mydms_session"])) { } 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'])) { @@ -322,7 +322,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(); @@ -361,10 +365,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(); @@ -511,19 +519,7 @@ switch($command) { if($folder->remove()) { if ($notifier) { - $subject = "folder_deleted_email_subject"; - $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); - } + $notifier->sendDeleteFolderMail($folder, $user); } header('Content-Type: application/json'); echo json_encode(array('success'=>true, 'message'=>'', 'data'=>'')); @@ -557,10 +553,6 @@ switch($command) { /* Get the notify list before removing the document */ $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) - ); $docname = $document->getName(); $controller = Controller::factory('RemoveDocument', array('dms'=>$dms, 'user'=>$user)); @@ -568,18 +560,10 @@ switch($command) { $controller->setParam('fulltextservice', $fulltextservice); if($controller->run()) { if ($notifier){ - $subject = "document_deleted_email_subject"; - $message = "document_deleted_email_body"; - $params = array(); - $params['name'] = $docname; - $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); - } + /* $document still has the data from the just deleted document, + * which is just enough to send the email. + */ + $notifier->sendDeleteDocumentMail($document, $user); } header('Content-Type: application/json'); @@ -646,10 +630,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(); @@ -831,106 +819,7 @@ switch($command) { } else { // Send notification to subscribers of folder. if($notifier) { - $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'] = $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; - $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); - } - - /* Get workflow from controller in case it was modified in a hook */ - $workflow = $controller->getParam('workflow'); - if($workflow && $settings->_enableNotificationWorkflow) { - $subject = "request_workflow_action_email_subject"; - $message = "request_workflow_action_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['version'] = 1; - $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); - } - } - } - - if($settings->_enableNotificationAppRev) { - /* Reviewers and approvers will be informed about the new document */ - /* Get reviewers and approvers from controller in case it was - * modified in a hook - */ - $reviewers = $controller->getParam('reviewers'); - $approvers = $controller->getParam('approvers'); - if($reviewers['i'] || $reviewers['g']) { - $subject = "review_request_email_subject"; - $message = "review_request_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = 1; - $params['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; - - foreach($reviewers['i'] as $reviewerid) { - $notifier->toIndividual($user, $dms->getUser($reviewerid), $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); - } - foreach($reviewers['g'] as $reviewergrpid) { - $notifier->toGroup($user, $dms->getGroup($reviewergrpid), $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); - } - } - - elseif($approvers['i'] || $approvers['g']) { - $subject = "approval_request_email_subject"; - $message = "approval_request_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = 1; - $params['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; - - foreach($approvers['i'] as $approverid) { - $notifier->toIndividual($user, $dms->getUser($approverid), $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); - } - foreach($approvers['g'] as $approvergrpid) { - $notifier->toGroup($user, $dms->getGroup($approvergrpid), $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); - } - } - } - + $notifier->sendNewDocumentMail($document, $user); } } header('Content-Type: application/json'); diff --git a/op/op.EditComment.php b/op/op.EditComment.php index 9ed6ae091..381e1d97d 100644 --- a/op/op.EditComment.php +++ b/op/op.EditComment.php @@ -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->getVersion()." - ".getMLText("document_comment_changed_email"); - $message = getMLText("document_comment_changed_email")."\r\n"; - $message .= - getMLText("document").": ".$document->getName()."\r\n". - getMLText("version").": ".$version->getVersion()."\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->getVersion()."\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 { diff --git a/op/op.EditDocument.php b/op/op.EditDocument.php index 538d3a050..8e9f21518 100644 --- a/op/op.EditDocument.php +++ b/op/op.EditDocument.php @@ -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'))); diff --git a/op/op.MoveClipboard.php b/op/op.MoveClipboard.php index 2e77ffca4..bff27c200 100644 --- a/op/op.MoveClipboard.php +++ b/op/op.MoveClipboard.php @@ -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 { diff --git a/op/op.MoveDocument.php b/op/op.MoveDocument.php index 56c7a2515..e1ebc227a 100644 --- a/op/op.MoveDocument.php +++ b/op/op.MoveDocument.php @@ -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 { diff --git a/op/op.MoveFolder.php b/op/op.MoveFolder.php index dbdad0f88..d0fc96886 100644 --- a/op/op.MoveFolder.php +++ b/op/op.MoveFolder.php @@ -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")); diff --git a/op/op.RemoveDocument.php b/op/op.RemoveDocument.php index 9d554b335..f700b96ac 100644 --- a/op/op.RemoveDocument.php +++ b/op/op.RemoveDocument.php @@ -69,13 +69,11 @@ $previewer->deleteDocumentPreviews($document); /* Get the notify list before removing the document * 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(); $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(); $controller->setParam('document', $document); @@ -89,19 +87,10 @@ if(!$controller->run()) { } if ($notifier){ - $subject = "document_deleted_email_subject"; - $message = "document_deleted_email_body"; - $params = array(); - $params['name'] = $docname; - $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); - } + /* $document still has the data from the just deleted document, + * which is just enough to send the email. + */ + $notifier->sendDeleteDocumentMail($document, $user); } $session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_rm_document'))); diff --git a/op/op.RemoveFolder.php b/op/op.RemoveFolder.php index 0d0c948e3..a2a25da55 100644 --- a/op/op.RemoveFolder.php +++ b/op/op.RemoveFolder.php @@ -85,6 +85,8 @@ if(!$controller->run()) { } if ($notifier) { + $notifier->sendDeleteFolderMail($folder, $user); + /* $subject = "folder_deleted_email_subject"; $message = "folder_deleted_email_body"; $params = array(); @@ -98,6 +100,7 @@ if ($notifier) { foreach ($nl["groups"] as $grp) { $notifier->toGroup($user, $grp, $subject, $message, $params, SeedDMS_NotificationService::RECV_NOTIFICATION); } + */ } add_log_line("?folderid=".$folderid."&name=".$foldername); diff --git a/op/op.RemoveVersion.php b/op/op.RemoveVersion.php index 764d44827..4857f3955 100644 --- a/op/op.RemoveVersion.php +++ b/op/op.RemoveVersion.php @@ -110,19 +110,19 @@ else { $emailGroupListA = array(); $status = $version->getReviewStatus(); foreach ($status as $st) { - if ($st["status"]==0 && !in_array($st["required"], $emailUserList)) { - if($st['type'] == 0) + if ($st["status"]==0) { + if($st['type'] == 0 && !in_array($st["required"], $emailUserListR)) $emailUserListR[] = $st["required"]; - else + elseif(!in_array($st["required"], $emailGroupListR)) $emailGroupListR[] = $st["required"]; } } $status = $version->getApprovalStatus(); foreach ($status as $st) { - if ($st["status"]==0 && !in_array($st["required"], $emailUserList)) { - if($st['type'] == 0) + if ($st["status"]==0) { + if($st['type'] == 0 && !in_array($st["required"], $emailUserListA)) $emailUserListA[] = $st["required"]; - else + elseif(!in_array($st["required"], $emailGroupListA)) $emailGroupListA[] = $st["required"]; } } diff --git a/op/op.SetWorkflow.php b/op/op.SetWorkflow.php index b679ab885..13a961c00 100644 --- a/op/op.SetWorkflow.php +++ b/op/op.SetWorkflow.php @@ -72,32 +72,7 @@ if (!$version->setWorkflow($workflow, $user)){ } if ($notifier) { - $nl = $document->getNotifyList(); - $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); - } - } - } + $notifier->sendRequestWorkflowActionMail($version, $user); } add_log_line("?documentid=".$documentid); diff --git a/op/op.UpdateDocument.php b/op/op.UpdateDocument.php index 945f6530b..58cd26991 100644 --- a/op/op.UpdateDocument.php +++ b/op/op.UpdateDocument.php @@ -341,121 +341,10 @@ default: UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText($controller->getErrorMsg())); } else { // Send notification to subscribers. - if ($notifier){ - $notifyList = $document->getNotifyList(); - $folder = $document->getFolder(); + if($notifier) { + $notifier->sendNewDocumentVersionMail($document, $user); - $subject = "document_updated_email_subject"; - $message = "document_updated_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['username'] = $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; - $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 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); - - /* Get workflow from controller in case it was modified in a hook */ - $workflow = $controller->getParam('workflow'); - if($workflow && $settings->_enableNotificationWorkflow) { - $subject = "request_workflow_action_email_subject"; - $message = "request_workflow_action_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['version'] = $content->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); - } - } - } - - if($settings->_enableNotificationAppRev) { - /* Reviewers and approvers will be informed about the new document */ - /* Get reviewers and approvers from controller in case it was - * modified in a hook - */ - $reviewers = $controller->getParam('reviewers'); - $approvers = $controller->getParam('approvers'); - if($reviewers['i'] || $reviewers['g']) { - $subject = "review_request_email_subject"; - $message = "review_request_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $content->getVersion(); - $params['comment'] = $content->getComment(); - $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; - - foreach($reviewers['i'] as $reviewerid) { - $notifier->toIndividual($user, $dms->getUser($reviewerid), $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); - } - foreach($reviewers['g'] as $reviewergrpid) { - $notifier->toGroup($user, $dms->getGroup($reviewergrpid), $subject, $message, $params, SeedDMS_NotificationService::RECV_REVIEWER); - } - } - - elseif($approvers['i'] || $approvers['g']) { - $subject = "approval_request_email_subject"; - $message = "approval_request_email_body"; - $params = array(); - $params['name'] = $document->getName(); - $params['folder_path'] = $folder->getFolderPathPlain(); - $params['version'] = $content->getVersion(); - $params['comment'] = $content->getComment(); - $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; - - foreach($approvers['i'] as $approverid) { - $notifier->toIndividual($user, $dms->getUser($approverid), $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); - } - foreach($approvers['g'] as $approvergrpid) { - $notifier->toGroup($user, $dms->getGroup($approvergrpid), $subject, $message, $params, SeedDMS_NotificationService::RECV_APPROVER); - } - } - } - - if($oldexpires != $document->getExpires()) { - // 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; - $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->sendChangedExpiryMail($document, $user, $oldexpires); } if($settings->_removeFromDropFolder) { diff --git a/views/bootstrap/class.Bootstrap.php b/views/bootstrap/class.Bootstrap.php index adaa9e3c0..03c46f58c 100644 --- a/views/bootstrap/class.Bootstrap.php +++ b/views/bootstrap/class.Bootstrap.php @@ -2870,8 +2870,12 @@ $(document).ready( function() { ?> /* catch click on a document row in the list folders and documents */ $('body').on('click', '[id^=\"table-row-document\"] td:nth-child(2)', function(ev) { - attr_id = $(ev.currentTarget).parent().attr('id').split('-')[3]; - window.location = '../out/out.ViewDocument.php?documentid=' + attr_id; + if(ev.shiftKey) { + $(ev.currentTarget).parent().toggleClass('selected'); + } else { + attr_id = $(ev.currentTarget).parent().attr('id').split('-')[3]; + window.location = '../out/out.ViewDocument.php?documentid=' + attr_id; + } }); /* catch click on a document row in the list folders and documents */ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev) { - attr_id = $(ev.currentTarget).parent().data('target-id'); - if(typeof attr_id == 'undefined') - attr_id = $(ev.currentTarget).parent().attr('id').split('-')[3]; - window.location = '../out/out.ViewFolder.php?folderid=' + attr_id; + if(ev.shiftKey) { + $(ev.currentTarget).parent().toggleClass('selected'); + } else { + attr_id = $(ev.currentTarget).parent().data('target-id'); + if(typeof attr_id == 'undefined') + attr_id = $(ev.currentTarget).parent().attr('id').split('-')[3]; + window.location = '../out/out.ViewFolder.php?folderid=' + attr_id; + } }); printClickDocumentJs(); diff --git a/views/bootstrap4/class.Bootstrap4.php b/views/bootstrap4/class.Bootstrap4.php index 621051e70..4eb199eca 100644 --- a/views/bootstrap4/class.Bootstrap4.php +++ b/views/bootstrap4/class.Bootstrap4.php @@ -2841,8 +2841,12 @@ $(document).ready( function() { ?> /* catch click on a document row in the list folders and documents */ $('body').on('click', '[id^=\"table-row-document\"] td:nth-child(2)', function(ev) { - attr_id = $(ev.currentTarget).parent().attr('id').split('-')[3]; - window.location = '../out/out.ViewDocument.php?documentid=' + attr_id; + if(ev.shiftKey) { + $(ev.currentTarget).parent().toggleClass('selected'); + } else { + attr_id = $(ev.currentTarget).parent().attr('id').split('-')[3]; + window.location = '../out/out.ViewDocument.php?documentid=' + attr_id; + } }); /* catch click on a document row in the list folders and documents */ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev) { - attr_id = $(ev.currentTarget).parent().data('target-id'); - if(typeof attr_id == 'undefined') - attr_id = $(ev.currentTarget).parent().attr('id').split('-')[3]; - window.location = '../out/out.ViewFolder.php?folderid=' + attr_id; + if(ev.shiftKey) { + $(ev.currentTarget).parent().toggleClass('selected'); + } else { + attr_id = $(ev.currentTarget).parent().data('target-id'); + if(typeof attr_id == 'undefined') + attr_id = $(ev.currentTarget).parent().attr('id').split('-')[3]; + window.location = '../out/out.ViewFolder.php?folderid=' + attr_id; + } }); getID(); return "getName(), ENT_QUOTES)."\">"; } /* }}} */ diff --git a/webdav/index.php b/webdav/index.php index d035c2d42..89d89245d 100644 --- a/webdav/index.php +++ b/webdav/index.php @@ -28,7 +28,7 @@ require_once("../inc/inc.ClassEmailNotify.php"); require_once("../inc/inc.Notification.php"); require_once("../inc/inc.ClassController.php"); -$notifier = new SeedDMS_NotificationService($logger); +$notifier = new SeedDMS_NotificationService($logger, $settings); if(isset($GLOBALS['SEEDDMS_HOOKS']['notification'])) { foreach($GLOBALS['SEEDDMS_HOOKS']['notification'] as $notificationObj) {