Show the normal in-browser notification popup when using browser notifications

This commit is contained in:
Nathan Gray 2011-11-24 16:22:34 +00:00
parent f99e4f276a
commit b023204b1d
2 changed files with 16 additions and 16 deletions

View File

@ -262,22 +262,22 @@ class notifications_ajax {
__LINE__,__FILE__,false,'',self::_appname);
if ($rs->NumRows() > 0) {
foreach ($rs as $notification) {
if($browserNotify)
$message = null;
if($browserNotify && $this->preferences[self::_appname]['egwpopup_verbosity'] != 'low')
{
// Check for a link - doesn't work in notification
if(strpos($notification['notify_message'], lang('Linked entries:')))
{
$notification['notify_message'] = substr_replace($notification['notify_message'], '', strpos($notification['notify_message'], lang('Linked entries:')));
}
$notification['notify_message'] = preg_replace('#</?a[^>]*>#is','',$notification['notify_message']);
$notification['notify_message'] = 'data:text/html;base64,'.base64_encode($notification['notify_message']);
}
$this->response->addScriptCall('append_notification_message',$notification['notify_id'],$notification['notify_message']);
}
$message = $notification['notify_message'];
// Skip in-page popup
if($browserNotify) return true;
// Check for a link - doesn't work in notification
if(strpos($message, lang('Linked entries:')))
{
$message = substr_replace($message, '', strpos($message, lang('Linked entries:')));
}
$message = preg_replace('#</?a[^>]*>#is','',$message);
$message = 'data:text/html;base64,'.base64_encode($message);
}
$this->response->addScriptCall('append_notification_message',$notification['notify_id'],$notification['notify_message'],$message);
}
switch($this->preferences[self::_appname]['egwpopup_verbosity']) {
case 'low':

View File

@ -116,7 +116,7 @@ function egwpopup_button_close() {
notificationbell_switch("inactive");
}
function append_notification_message(_id, _message) {
function append_notification_message(_id, _message, _browser_notify) {
if(!check_browser_notify() || typeof notifymessages[_id] != 'undefined')
{
@ -127,7 +127,7 @@ function append_notification_message(_id, _message) {
notifymessages[_id] = _message;
// Notification API
var notice = webkitNotifications.createHTMLNotification(_message);
var notice = webkitNotifications.createHTMLNotification(_browser_notify);
notice.ondisplay = function() {
// Confirm when user gets to see it - no close needed
// Wait a bit to let it load first, or it might not be there when requested.