diff --git a/inc/inc.Authentication.php b/inc/inc.Authentication.php index 6896d83ac..1a7b77314 100644 --- a/inc/inc.Authentication.php +++ b/inc/inc.Authentication.php @@ -13,6 +13,7 @@ */ require_once("inc.Utils.php"); +require_once("inc.ClassNotificationService.php"); require_once("inc.ClassEmailNotify.php"); require_once("inc.ClassSession.php"); @@ -90,11 +91,9 @@ $theme = $resArr["theme"]; $lang = $resArr["language"]; $dms->setUser($user); +$notifier = new SeedDMS_NotificationService(); if($settings->_enableEmail) { - $notifier = new SeedDMS_EmailNotify($settings->_smtpSendFrom, $settings->_smtpServer, $settings->_smtpPort, $settings->_smtpUser, $settings->_smtpPassword); - $notifier->setSender($user); -} else { - $notifier = null; + $notifier->addService(new SeedDMS_EmailNotify($dms, $settings->_smtpSendFrom, $settings->_smtpServer, $settings->_smtpPort, $settings->_smtpUser, $settings->_smtpPassword)); } /* Include the language file as specified in the session. If that is not diff --git a/inc/inc.ClassEmailNotify.php b/inc/inc.ClassEmailNotify.php index 9423dbc94..b8e350f60 100644 --- a/inc/inc.ClassEmailNotify.php +++ b/inc/inc.ClassEmailNotify.php @@ -31,14 +31,13 @@ require_once("Mail.php"); * @version Release: @package_version@ */ class SeedDMS_EmailNotify extends SeedDMS_Notify { - /* User sending the notification - * Will only be used if the sender of one of the notify methods - * is not set + /** + * Instanz of DMS */ - protected $sender; + protected $_dms; - function setSender($user) { - $this->sender = $user; + function __construct($dms) { + $this->_dms = $dms; } var $smtp_server; diff --git a/inc/inc.ClassNotificationService.php b/inc/inc.ClassNotificationService.php new file mode 100644 index 000000000..e168bab08 --- /dev/null +++ b/inc/inc.ClassNotificationService.php @@ -0,0 +1,56 @@ + + * @copyright Copyright (C) 2016 Uwe Steinmann + * @version Release: @package_version@ + */ + +/** + * Implementation of notification service + * + * @category DMS + * @package SeedDMS + * @author Uwe Steinmann + * @copyright Copyright (C) 2016 Uwe Steinmann + * @version Release: @package_version@ + */ +class SeedDMS_NotificationService { + /** + * List of services for sending notification + */ + protected $services; + + public function __construct() { + $this->services = array(); + } + + public function addService($service) { + $this->services[] = $service; + } + + public function toIndividual($sender, $recipient, $subject, $message, $params=array()) { + foreach($this->services as $service) { + $service->toIndividual($sender, $recipient, $subject, $message, $params); + } + } + + public function toGroup($sender, $groupRecipient, $subject, $message, $params=array()) { + foreach($this->services as $service) { + $service->toGroup($sender, $groupRecipient, $subject, $message, $params); + } + } + + public function toList($sender, $recipients, $subject, $message, $params=array()) { + foreach($this->services as $service) { + $service->toList($sender, $recipients, $subject, $message, $params); + } + } + +} + diff --git a/op/op.Ajax.php b/op/op.Ajax.php index be2cee241..0a9dda36c 100644 --- a/op/op.Ajax.php +++ b/op/op.Ajax.php @@ -24,6 +24,7 @@ include("../inc/inc.Init.php"); include("../inc/inc.Extension.php"); include("../inc/inc.Init.php"); include("../inc/inc.DBInit.php"); +include("../inc/inc.ClassNotificationService.php"); include("../inc/inc.ClassEmailNotify.php"); include("../inc/inc.ClassUI.php"); @@ -55,11 +56,9 @@ if (isset($_COOKIE["mydms_session"])) { $user = $dms->getUser($resArr["su"]); } } + $notifier = new SeedDMS_NotificationService(); if($settings->_enableEmail) { - $notifier = new SeedDMS_EmailNotify(); - $notifier->setSender($user); - } else { - $notifier = null; + $notifier->addService(new SeedDMS_EmailNotify($dms)); } include $settings->_rootDir . "languages/" . $resArr["language"] . "/lang.inc"; } else { diff --git a/op/op.EditOnline.php b/op/op.EditOnline.php index 2c6b1f208..008353fb2 100644 --- a/op/op.EditOnline.php +++ b/op/op.EditOnline.php @@ -59,6 +59,27 @@ if($lc->getChecksum() == SeedDMS_Core_File::checksum($tmpfname)) { echo json_encode(array('success'=>false, 'message'=>getMLText('identical_version'))); } else { if($document->replaceContent(0, $user, $tmpfname, $lc->getOriginalFileName(), $lc->getFileType(), $lc->getMimeType())) { + if($notifier) { + $notifyList = $folder->getNotifyList(); + + $subject = "replace_content_email_subject"; + $message = "replace_content_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'] = $lc->getVersion(); + $params['version_comment'] = $lc->getComment(); + $params['url'] = "http".((isset($_SERVER['HTTPS']) && (strcmp($_SERVER['HTTPS'],'off')!=0)) ? "s" : "")."://".$_SERVER['HTTP_HOST'].$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); + foreach ($notifyList["groups"] as $grp) { + $notifier->toGroup($user, $grp, $subject, $message, $params); + } + } echo json_encode(array('success'=>true, 'message'=>getMLText('splash_saved_file'))); } else { echo json_encode(array('success'=>false, 'message'=>getMLText('splash_error_saving_file'))); diff --git a/op/op.PasswordForgotten.php b/op/op.PasswordForgotten.php index 13a8c1c39..66255311d 100644 --- a/op/op.PasswordForgotten.php +++ b/op/op.PasswordForgotten.php @@ -55,7 +55,7 @@ if (empty($email) || empty($login)) { $user = $dms->getUserByLogin($login, $email); if($user) { if($hash = $dms->createPasswordRequest($user)) { - $emailobj = new SeedDMS_EmailNotify($settings->_smtpSendFrom, $settings->_smtpServer, $settings->_smtpPort, $settings->_smtpUser, $settings->_smtpPassword); + $emailobj = new SeedDMS_EmailNotify($dms, $settings->_smtpSendFrom, $settings->_smtpServer, $settings->_smtpPort, $settings->_smtpUser, $settings->_smtpPassword); $subject = "password_forgotten_email_subject"; $message = "password_forgotten_email_body"; $params = array();