From 3a9bec69afb25fbc8a0f5e96398fcbe49bfacc84 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 29 Jan 2021 10:34:01 +0100 Subject: [PATCH] log filtered out notifications --- inc/inc.ClassNotificationService.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/inc/inc.ClassNotificationService.php b/inc/inc.ClassNotificationService.php index e4d04b4e4..55de56eff 100644 --- a/inc/inc.ClassNotificationService.php +++ b/inc/inc.ClassNotificationService.php @@ -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;