From db25d1430b15495445dc45cc5125cb25f649a794 Mon Sep 17 00:00:00 2001 From: icewing Date: Wed, 4 Jun 2008 11:21:27 +0000 Subject: Marcus Povey * Supports multiple delivery methods as an array git-svn-id: https://code.elgg.org/elgg/trunk@791 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/notification.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'engine/lib/notification.php') 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; } -- cgit v1.2.3