log filtered out notifications

This commit is contained in:
Uwe Steinmann 2021-01-29 10:34:01 +01:00
parent ae2eebd562
commit 3a9bec69af

View File

@ -70,20 +70,29 @@ class SeedDMS_NotificationService {
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
* This is only used for logging
*/
if(is_object($recipient) && $recipient->isType('user') && !$recipient->isDisabled() && $recipient->getEmail()!="") {
$to = $recipient->getEmail();
} elseif(is_string($recipient) && trim($recipient) != "") {
$to = $recipient;
} else {
$to = '';
}
/* Call filter of notification service if set */
if(!is_callable([$service, 'filter']) || $service->filter($sender, $recipient, $subject, $message, $params, $recvtype)) {
if(is_object($recipient) && ($dms = $recipient->getDMS()) && !strcasecmp(get_class($recipient), $dms->getClassname('user')) && !$recipient->isDisabled() && $recipient->getEmail()!="") {
$to = $recipient->getEmail();
} elseif(is_string($recipient) && trim($recipient) != "") {
$to = $recipient;
}
if(!$service->toIndividual($sender, $recipient, $subject, $message, $params)) {
$error = false;
$this->errors[$name] = false;
$this->logger->log('Notification service: '.$name.'. Sending mail \''.$subject.'\' to user \''.$to.'\' failed.', PEAR_LOG_ERR);
$this->logger->log('Notification service \''.$name.'\': Sending mail \''.$subject.'\' to user \''.$to.'\' failed.', PEAR_LOG_ERR);
} else {
$this->logger->log('Notification service: '.$name.'. Sending mail \''.$subject.'\' to user \''.$to.'\' successful.', PEAR_LOG_INFO);
$this->logger->log('Notification service \''.$name.'\': Sending mail \''.$subject.'\' to user \''.$to.'\' successful.', PEAR_LOG_INFO);
$this->errors[$name] = true;
}
} else {
$this->logger->log('Notification service \''.$name.'\': Sending mail \''.$subject.'\' to user \''.$to.'\' filtered out.', PEAR_LOG_INFO);
}
}
return $error;