diff options
author | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-04 11:21:27 +0000 |
---|---|---|
committer | icewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-06-04 11:21:27 +0000 |
commit | db25d1430b15495445dc45cc5125cb25f649a794 (patch) | |
tree | 5de1f6f74e01c4e7e4f7b2597cd627ffe880be57 | |
parent | bf5019635d558e6b27fec88b2b6d842cecd101ad (diff) | |
download | elgg-db25d1430b15495445dc45cc5125cb25f649a794.tar.gz elgg-db25d1430b15495445dc45cc5125cb25f649a794.tar.bz2 |
Marcus Povey <marcus@dushka.co.uk>
* Supports multiple delivery methods as an array
git-svn-id: https://code.elgg.org/elgg/trunk@791 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/notification.php | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/engine/lib/notification.php b/engine/lib/notification.php index fd4f3a9d0..f8b41cdd1 100644 --- a/engine/lib/notification.php +++ b/engine/lib/notification.php @@ -47,7 +47,7 @@ /** * Send a notification message using a pre-registered method. * - * @param string $method The method used + * @param mixed $method The method used as a string, or an array if multiple methods should be used. * @param mixed $to Either a guid or an array of guid's to notify * @param string $message A message * @param array $params Optional method specific parameters as an associative array, for example "subject", "from" @@ -62,18 +62,24 @@ if (!is_array($to)) $to = (int)$to; - if ($method=="") + if (!$method) throw new NotificationException("No notification method specified."); + if (!is_array($method)) + $method = array($method); + if ((!array_key_exists($method, $NOTIFICATION_HANDLERS)) || (!is_callable($NOTIFICATION_HANDLERS[$method]))) throw new NotificationExceptions("No handler found for '$method' or it was not callable."); if (!is_array($to)) $to = array($to); - foreach ($to as $guid) - if (!$NOTIFICATION_HANDLERS[$method]($guid, sanitise_string($method), $params)) + foreach ($to as $guid) + { + foreach ($method as $m) + if (!$NOTIFICATION_HANDLERS[$m]($guid, sanitise_string($m), $params)) throw new NotificationException("There was an error while notifying $guid"); + } return true; } |