Merge branch 'seeddms-5.1.x' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2021-01-29 10:35:45 +01:00
commit 768345a2ef
5 changed files with 38 additions and 9 deletions

View File

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

View File

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

View File

@ -24,7 +24,7 @@
</stability>
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
???
- no changes, just keep same version as seeddms application
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">
@ -1876,6 +1876,8 @@ add method SeedDMS_Core_DatabaseAccess::setLogFp()
<license uri="http://opensource.org/licenses/gpl-license">GPL License</license>
<notes>
- 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()
</notes>
</release>
<release>

View File

@ -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) != "") {

View File

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