diff --git a/SeedDMS_Core/Core/inc.ClassGroup.php b/SeedDMS_Core/Core/inc.ClassGroup.php
index de78c727a..2e1bda76c 100644
--- a/SeedDMS_Core/Core/inc.ClassGroup.php
+++ b/SeedDMS_Core/Core/inc.ClassGroup.php
@@ -124,6 +124,15 @@ class SeedDMS_Core_Group { /* {{{ */
return $groups;
} /* }}} */
+ /**
+ * Check if this object is of type 'group'.
+ *
+ * @param string $type type of object
+ */
+ public function isType($type) { /* {{{ */
+ return $type == 'group';
+ } /* }}} */
+
/**
* @param SeedDMS_Core_DMS $dms
*/
diff --git a/SeedDMS_Core/Core/inc.ClassUser.php b/SeedDMS_Core/Core/inc.ClassUser.php
index a6318c29f..e689d54b8 100644
--- a/SeedDMS_Core/Core/inc.ClassUser.php
+++ b/SeedDMS_Core/Core/inc.ClassUser.php
@@ -497,6 +497,15 @@ class SeedDMS_Core_User { /* {{{ */
return $users;
} /* }}} */
+ /**
+ * Check if this object is of type 'user'.
+ *
+ * @param string $type type of object
+ */
+ public function isType($type) { /* {{{ */
+ return $type == 'user';
+ } /* }}} */
+
/**
* @param SeedDMS_Core_DMS $dms
*/
diff --git a/SeedDMS_Core/package.xml b/SeedDMS_Core/package.xml
index 419096a7e..91c7d489c 100644
--- a/SeedDMS_Core/package.xml
+++ b/SeedDMS_Core/package.xml
@@ -24,7 +24,7 @@
GPL License
-???
+- no changes, just keep same version as seeddms application
@@ -1876,6 +1876,8 @@ add method SeedDMS_Core_DatabaseAccess::setLogFp()
GPL License
- add SeedDMS_Core_DatabaseAccess::hasTable()
+- add SeedDMS_Core_User->isType() and SeedDMS_Core_Group->isType()
+- add SeedDMS_Core_User->getDMS() and SeedDMS_Core_Group->getDMS()
diff --git a/inc/inc.ClassEmailNotify.php b/inc/inc.ClassEmailNotify.php
index 630697969..20fffcfce 100644
--- a/inc/inc.ClassEmailNotify.php
+++ b/inc/inc.ClassEmailNotify.php
@@ -84,7 +84,7 @@ class SeedDMS_EmailNotify extends SeedDMS_Notify {
* @return false or -1 in case of error, otherwise true
*/
function toIndividual($sender, $recipient, $subject, $messagekey, $params=array(), $attachments=array()) { /* {{{ */
- if(is_object($recipient) && !strcasecmp(get_class($recipient), $this->_dms->getClassname('user')) && !$recipient->isDisabled() && $recipient->getEmail()!="") {
+ if(is_object($recipient) && $recipient->isType('user') && !$recipient->isDisabled() && $recipient->getEmail()!="") {
$to = $recipient->getEmail();
$lang = $recipient->getLanguage();
} elseif(is_string($recipient) && trim($recipient) != "") {
diff --git a/inc/inc.ClassNotificationService.php b/inc/inc.ClassNotificationService.php
index 7008acafb..902cb0f82 100644
--- a/inc/inc.ClassNotificationService.php
+++ b/inc/inc.ClassNotificationService.php
@@ -72,20 +72,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;