From 7ade6b4f553c9394e7b6ef56dc4576d1112e5149 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 4 Sep 2012 12:10:37 +0000 Subject: [PATCH] * Calendar: popup notifications now include a link again --- calendar/inc/class.calendar_boupdate.inc.php | 8 +-- notifications/inc/class.notifications.inc.php | 50 +++++++++++++++++-- 2 files changed, 51 insertions(+), 7 deletions(-) diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index a75f16e53a..ae28154ced 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -907,12 +907,14 @@ class calendar_boupdate extends calendar_bo } else { - // set message (without separator) for popup notifications - $notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body); - // iCal: description need to be separated from body by fancy separator $notification->set_message($notify_body."\n\n".$details_body."\n*~*~*~*~*~*~*~*~*~*\n\n".$details['description']); } + // popup notifiactions: set subject, different message (without separator) and (always) links + $notification->set_popupsubject($subject); + $notification->set_popupmessage($notify_body."\n\n".$details['description']."\n\n".$details_body); + $notification->set_popuplinks(array($details['link_arr'])); + if(is_array($attachment)) { $notification->set_attachments(array($attachment)); } $notification->send(); } diff --git a/notifications/inc/class.notifications.inc.php b/notifications/inc/class.notifications.inc.php index 7fb0d24f85..518ea4ffa9 100644 --- a/notifications/inc/class.notifications.inc.php +++ b/notifications/inc/class.notifications.inc.php @@ -150,6 +150,12 @@ final class notifications { */ private $links = array(); + /** + * array with objects of links + * @var array + */ + private $popup_links = array(); + /** * array with objects of attachments * @var array @@ -298,8 +304,8 @@ final class notifications { /** * sets the notification links * - * @param array $_links link array (like defined in $this->add_link) - */ + * @param array $_links link array (like defined in $this->add_link) + */ public function set_links(array $_links) { $this->links = array(); // clear array if set foreach($_links as $link) { @@ -310,6 +316,21 @@ final class notifications { return true; } + /** + * sets the notification links for popups + * + * @param array $_links link array (like defined in $this->add_link) + */ + public function set_popuplinks(array $_links) { + $this->popup_links = array(); // clear array if set + foreach($_links as $link) { + if(is_array($link)) { + $this->add_popuplink($link['text'], $link['view'], $link['popup']); + } + } + return true; + } + /** * adds a notification link * @@ -326,6 +347,22 @@ final class notifications { return true; } + /** + * adds a notification link for popups + * + * @param string $_text a descriptive text for the link + * @param array $_view all params needed to view the link (name => value pairs) + * @param string $_popup if link can be viewed in a popup something like '300x200' otherwise false + */ + public function add_popuplink($_text, $_view, $_popup = false) { + if(!$_view || !$_text) { return false; } + $this->popup_links[] = (object)array( 'text' => $_text, + 'view' => $_view, + 'popup' => $_popup, + ); + return true; + } + /** * sets the notification attachments * @@ -466,8 +503,13 @@ final class notifications { throw new Exception($notification_backend. ' is no implementation of notifications_iface'); } $lsubject = $this->subject; - if ($backend=='popup' && isset($this->popupsubject) && !empty($this->popupsubject)) $lsubject = $this->popupsubject; - $obj->send($this->prepend_message($messages, $prepend_message), $lsubject, $this->links, $this->attachments); + $llinks = $this->links; + if ($backend == 'popup') + { + if (!empty($this->popupsubject)) $lsubject = $this->popupsubject; + if ($this->popup_links) $llinks = $this->popup_links; + } + $obj->send($this->prepend_message($messages, $prepend_message), $lsubject, $llinks, $this->attachments); } catch (Exception $exception) { $backend_errors[] = $notification_backend.' failed: '.$exception->getMessage();