mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 15:32:13 +00:00
call each notification service
This commit is contained in:
parent
9e239a3c65
commit
405f1796e4
|
@ -25,6 +25,7 @@
|
|||
- add support for indexing folders in fulltext search
|
||||
- add support for start folder in fulltext search
|
||||
- always call hook postAddSubFolder and postEditDocument
|
||||
- call each notification service even if one of them fails
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Changes in version 5.1.20
|
||||
|
|
|
@ -26,40 +26,74 @@ class SeedDMS_NotificationService {
|
|||
*/
|
||||
protected $services;
|
||||
|
||||
/*
|
||||
* List of servives with errors
|
||||
*/
|
||||
protected $errors;
|
||||
|
||||
public function __construct() {
|
||||
$this->services = array();
|
||||
$this->errors = array();
|
||||
}
|
||||
|
||||
public function addService($service, $name='') {
|
||||
$this->services[$name ? $name : md5(uniqid())] = $service;
|
||||
if(!$name)
|
||||
$name = md5(uniqid());
|
||||
$this->services[$name] = $service;
|
||||
$this->errors[$name] = true;
|
||||
}
|
||||
|
||||
public function getServices() {
|
||||
return $this->services;
|
||||
}
|
||||
|
||||
public function getErrors() {
|
||||
return $this->errors;
|
||||
}
|
||||
|
||||
public function toIndividual($sender, $recipient, $subject, $message, $params=array()) {
|
||||
$error = true;
|
||||
foreach($this->services as $name => $service) {
|
||||
if(!is_callable([$service, 'filter']) || $service->filter($sender, $recipient, $subject, $message, $params)) {
|
||||
return $service->toIndividual($sender, $recipient, $subject, $message, $params);
|
||||
if(!$service->toIndividual($sender, $recipient, $subject, $message, $params)) {
|
||||
$error = false;
|
||||
$this->errors[$name] = false;
|
||||
} else {
|
||||
$this->errors[$name] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $error;
|
||||
}
|
||||
|
||||
public function toGroup($sender, $groupRecipient, $subject, $message, $params=array()) {
|
||||
$error = true;
|
||||
foreach($this->services as $name => $service) {
|
||||
if(!is_callable([$service, 'filter']) || $service->filter($sender, $groupRecipient, $subject, $message, $params)) {
|
||||
return $service->toGroup($sender, $groupRecipient, $subject, $message, $params);
|
||||
if(!$service->toGroup($sender, $groupRecipient, $subject, $message, $params)) {
|
||||
$error = false;
|
||||
$this->errors[$name] = false;
|
||||
} else {
|
||||
$this->errors[$name] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $error;
|
||||
}
|
||||
|
||||
public function toList($sender, $recipients, $subject, $message, $params=array()) {
|
||||
$error = true;
|
||||
foreach($this->services as $name => $service) {
|
||||
if(!is_callable([$service, 'filter']) || $service->filter($sender, $recipients, $subject, $message, $params)) {
|
||||
return $service->toList($sender, $recipients, $subject, $message, $params);
|
||||
if(!$service->toList($sender, $recipients, $subject, $message, $params)) {
|
||||
$error = false;
|
||||
$this->errors[$name] = false;
|
||||
} else {
|
||||
$this->errors[$name] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $error;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user