Merge branch 'seeddms-4.3.x' into seeddms-5.0.x

This commit is contained in:
Uwe Steinmann 2016-03-09 18:03:34 +01:00
commit a5d766543e
6 changed files with 89 additions and 15 deletions

View File

@ -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

View File

@ -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;

View File

@ -0,0 +1,56 @@
<?php
/**
* Implementation of notification service
*
* @category DMS
* @package SeedDMS
* @license GPL 2
* @version @version@
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2016 Uwe Steinmann
* @version Release: @package_version@
*/
/**
* Implementation of notification service
*
* @category DMS
* @package SeedDMS
* @author Uwe Steinmann <uwe@steinmann.cx>
* @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);
}
}
}

View File

@ -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 {

View File

@ -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')));

View File

@ -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();