* Calendar: popup notifications now include a link again

This commit is contained in:
Ralf Becker 2012-09-04 12:10:37 +00:00
parent 6b8a937977
commit 7ade6b4f55
2 changed files with 51 additions and 7 deletions

View File

@ -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();
}

View File

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