-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f11258d
Showing
11 changed files
with
376 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
HTML5_Notifier is a Roundcube plugin. | ||
|
||
It displays Desktop Notifications like the ones you might know from Google Mail. Just keep Roundcube opened in a (minimized) tab and enjoy getting notifications every time a new mail arrives. | ||
|
||
It just works in modern browsers like Google Chrome, SRWare Iron or Firefox, because "Desktop Notification" is a new feature in HTML5. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
0.2 | ||
- added Listbox to select showing duration | ||
- added color to browser-conf-button | ||
|
||
0.3 | ||
- updated to work with roundcube 0.8 and 0.9 | ||
- added display of mailbox | ||
|
||
0.4 | ||
- updated to work with Firefox and the new Notification API | ||
- fixed UTF-8 issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
/* defaults */ | ||
$rcmail_config['html5_notifier_duration'] = '3'; //Display duration of Desktop Notifications (0 = disabled) | ||
$rcmail_config['html5_notifier_smbox'] = '1'; //Lenght of displayed mailboxname 2=max 1=short 0=do not show | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
/** | ||
* html5_notifier | ||
* Shows a desktop notification every time a new (recent) mail comes in | ||
* | ||
* @version 0.4 - 01.12.2013 | ||
* @author Tilman Stremlau <tilman@stremlau.net> | ||
* @website stremlau.net/html5_notifier | ||
* @licence GNU GPL | ||
* | ||
**/ | ||
|
||
function rcmail_show_notification(message) | ||
{ | ||
if (use_notifications) | ||
{ | ||
if ("Notification" in window) { | ||
var notification = new Notification(rcmail.gettext('notification_title', 'html5_notifier').replace('[from]', message.from), { | ||
icon: './plugins/html5_notifier/images/new_mail.png', | ||
body: message.subject | ||
}); | ||
notification.onclick = function() { | ||
window.open('?_task=mail&_action=show&_uid='+message.uid); | ||
} | ||
if (parseInt(message.duration) > 0) | ||
{ | ||
setTimeout(function(){ notification.close(); }, (parseInt(message.duration)*1000)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
function rcmail_browser_notifications() | ||
{ | ||
if ("Notification" in window && Notification.permission) { | ||
if (Notification.permission === "granted") { | ||
rcmail.display_message(rcmail.gettext('ok_notifications', 'html5_notifier'), 'notice'); | ||
} | ||
else { | ||
Notification.requestPermission(rcmail_check_notifications); | ||
} | ||
} | ||
else if (window.webkitNotifications) { | ||
if (window.webkitNotifications.checkPermission() == 0) | ||
{ | ||
rcmail.display_message(rcmail.gettext('ok_notifications', 'html5_notifier'), 'notice'); | ||
} | ||
else | ||
{ | ||
window.webkitNotifications.requestPermission(rcmail_check_notifications); | ||
} | ||
} | ||
else | ||
{ | ||
rcmail.display_message(rcmail.gettext('no_notifications', 'html5_notifier'), 'error'); | ||
} | ||
} | ||
|
||
function rcmail_browser_notifications_test() { | ||
if (use_notifications) | ||
{ | ||
rcmail.display_message(rcmail.gettext('check_ok', 'html5_notifier'), 'notice'); | ||
|
||
var message = new Object(); | ||
message.duration = 8; | ||
message.uid = 0; | ||
message.subject = 'It Works!'; | ||
message.from = 'TESTMAN'; | ||
rcmail_show_notification(message); | ||
} | ||
else | ||
{ | ||
if ("Notification" in window && Notification.permission) { | ||
if (Notification.permission == 'denied') { | ||
rcmail.display_message(rcmail.gettext('check_fail_blocked', 'html5_notifier'), 'error'); | ||
return false; | ||
} | ||
} | ||
else if (window.webkitNotifications) | ||
{ | ||
if (window.webkitNotifications.checkPermission() == 2) | ||
{ | ||
rcmail.display_message(rcmail.gettext('check_fail_blocked', 'html5_notifier'), 'error'); | ||
return false; | ||
} | ||
} | ||
rcmail.display_message(rcmail.gettext('check_fail', 'html5_notifier'), 'error'); | ||
} | ||
} | ||
|
||
function rcmail_browser_notifications_colorate() { | ||
if ("Notification" in window && Notification.permission) { | ||
var broco = $('#rcmfd_html5_notifier_browser_conf'); | ||
if (broco) | ||
{ | ||
switch (Notification.permission) | ||
{ | ||
case 'granted': broco.css('color', 'green'); break; | ||
case 'default': broco.css('color', 'orange'); break; | ||
case 'denied': broco.css('color', 'red'); break; | ||
} | ||
} | ||
} | ||
else if (window.webkitNotifications) | ||
{ | ||
var broco = $('#rcmfd_html5_notifier_browser_conf'); | ||
if (broco) | ||
{ | ||
switch (window.webkitNotifications.checkPermission()) | ||
{ | ||
case 0: broco.css('color', 'green'); break; | ||
case 1: broco.css('color', 'orange'); break; | ||
case 2: broco.css('color', 'red'); break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
var use_notifications = false; | ||
|
||
var rcmail_check_notifications = function(e) | ||
{ | ||
if ("Notification" in window && Notification.permission) { | ||
if (Notification.permission === "granted") { | ||
use_notifications = true; | ||
} | ||
} | ||
else if (window.webkitNotifications) | ||
{ | ||
if (window.webkitNotifications.checkPermission() == 0) { | ||
use_notifications = true; | ||
} | ||
} | ||
rcmail_browser_notifications_colorate(); | ||
} | ||
|
||
if (window.rcmail) | ||
{ | ||
rcmail.addEventListener('plugin.showNotification', rcmail_show_notification); | ||
rcmail.addEventListener('init', rcmail_check_notifications); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?php | ||
/** | ||
* html5_notifier | ||
* Shows a desktop notification every time a new (recent) mail comes in | ||
* | ||
* @version 0.4 - 01.12.2013 | ||
* @author Tilman Stremlau <tilman@stremlau.net> | ||
* @website stremlau.net/html5_notifier | ||
* @licence GNU GPL | ||
* | ||
**/ | ||
|
||
class html5_notifier extends rcube_plugin | ||
{ | ||
public $task = '?(?!login|logout).*'; | ||
|
||
function init() | ||
{ | ||
$RCMAIL = rcmail::get_instance(); | ||
|
||
if(file_exists("./plugins/html5_notifier/config/config.inc.php")) | ||
{ | ||
$this->load_config('config/config.inc.php'); | ||
} | ||
|
||
$this->add_hook('preferences_list', array($this, 'prefs_list')); | ||
$this->add_hook('preferences_save', array($this, 'prefs_save')); | ||
|
||
if ($RCMAIL->config->get('html5_notifier_duration').'' != '0') | ||
{ | ||
$this->add_hook('new_messages', array($this, 'show_notification')); | ||
$this->include_script("html5_notifier.js"); | ||
if ($RCMAIL->action != 'check-recent') | ||
{ | ||
$this->add_texts('localization', array('notification_title', 'ok_notifications', 'no_notifications', 'check_ok', 'check_fail', 'check_fail_blocked')); //PRÄZESIEREN | ||
} | ||
} | ||
} | ||
|
||
function show_notification($args) | ||
{ | ||
$RCMAIL = rcmail::get_instance(); | ||
|
||
$RCMAIL->storage->set_mailbox($args['mailbox']); | ||
$RCMAIL->storage->search($args['mailbox'], "RECENT", null); | ||
$msgs = (array) $RCMAIL->storage->list_headers($args['mailbox']); | ||
|
||
foreach ($msgs as $msg) { | ||
$from = $msg->get('from'); | ||
$mbox = ''; | ||
switch ($RCMAIL->config->get('html5_notifier_smbox')) { | ||
case 1: $mbox = array_pop(explode('.', str_replace('INBOX.', '', $args['mailbox']))); break; | ||
case 2: $mbox = str_replace('.', '/', str_replace('INBOX.', '', $args['mailbox'])); break; | ||
} | ||
$subject = ((!empty($mbox)) ? $mbox.': ' : '').$msg->get('subject'); | ||
|
||
if(strtolower($_SESSION['username']) == strtolower($RCMAIL->user->data['username'])) | ||
{ | ||
$RCMAIL->output->command("plugin.showNotification", array( | ||
'duration' => $RCMAIL->config->get('html5_notifier_duration'), | ||
'subject' => $subject, | ||
'from' => $from, | ||
'uid' => $msg->uid.'&_mbox='.$args['mailbox'], | ||
)); | ||
} | ||
} | ||
$RCMAIL->storage->search($args['mailbox'], "ALL", null); | ||
} | ||
|
||
function prefs_list($args) | ||
{ | ||
if($args['section'] == 'mailbox') | ||
{ | ||
$RCMAIL = rcmail::get_instance(); | ||
|
||
$field_id = 'rcmfd_html5_notifier'; | ||
|
||
$select_duration = new html_select(array('name' => '_html5_notifier_duration', 'id' => $field_id)); | ||
$select_duration->add($this->gettext('off'), '0'); | ||
$times = array('3', '5', '8', '10', '12', '15', '20', '25', '30'); | ||
foreach ($times as $time) | ||
$select_duration->add($time.' '.$this->gettext('seconds'), $time); | ||
$select_duration->add($this->gettext('durable'), -1); | ||
|
||
$select_smbox = new html_select(array('name' => '_html5_notifier_smbox', 'id' => $field_id)); | ||
$select_smbox->add($this->gettext('no_mailbox'), '0'); | ||
$select_smbox->add($this->gettext('short_mailbox'), '1'); | ||
$select_smbox->add($this->gettext('full_mailbox'), '2'); | ||
|
||
$content = $select_duration->show($RCMAIL->config->get('html5_notifier_duration').''); | ||
$content .= $select_smbox->show($RCMAIL->config->get('html5_notifier_smbox').''); | ||
$content .= html::a(array('href' => '#', 'id' => 'rcmfd_html5_notifier_browser_conf', 'onclick' => 'rcmail_browser_notifications(); return false;'), $this->gettext('conf_browser')).' '; | ||
$content .= html::a(array('href' => '#', 'onclick' => 'rcmail_browser_notifications_test(); return false;'), $this->gettext('test_browser')); | ||
$args['blocks']['new_message']['options']['html5_notifier'] = array( | ||
'title' => html::label($field_id, Q($this->gettext('shownotifies'))), | ||
'content' => $content, | ||
); | ||
|
||
$RCMAIL->output->add_script("$(document).ready(function(){ rcmail_browser_notifications_colorate(); });"); | ||
} | ||
return $args; | ||
} | ||
|
||
function prefs_save($args) | ||
{ | ||
if($args['section'] == 'mailbox') | ||
{ | ||
$args['prefs']['html5_notifier_duration'] = get_input_value('_html5_notifier_duration', RCUBE_INPUT_POST); | ||
$args['prefs']['html5_notifier_smbox'] = get_input_value('_html5_notifier_smbox', RCUBE_INPUT_POST); | ||
return $args; | ||
} | ||
} | ||
} | ||
?> |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
$labels = array(); | ||
$labels['shownotifies'] = 'Desktop Benachrichtigungen'; | ||
$labels['conf_browser'] = 'Browser einrichten'; | ||
$labels['test_browser'] = 'Testen'; | ||
$labels['check_ok'] = 'Ihre Browsereinstellungen sind korrekt.'; | ||
$labels['check_fail'] = 'Es konnte keine Benachrichtigung angezeigt werden, bitte klicken Sie auf "Browser einrichten"!'; | ||
$labels['check_fail_blocked'] = 'Ihr Browser hat die Benachrichtigung blockert, bitte erlauben Sie diese in den Einstellungen Ihres Browsers!'; | ||
$labels['no_notifications'] = 'Ihr Browser unterstützt noch keine Desktop Benachrichtigungen!'; | ||
$labels['ok_notifications'] = 'Die Website hat die Erlaubnis bereits erhalten. Desktop Benachrichtgungen sollten funktionieren.'; | ||
$labels['notification_title'] = 'Neue E-Mail von [from]'; | ||
|
||
$labels['seconds'] = 'Sekunden'; | ||
$labels['off'] = 'Aus'; | ||
$labels['durable'] = 'dauerhaft'; | ||
|
||
$labels['no_mailbox'] = 'Ordnernamen nicht anzeigen'; | ||
$labels['short_mailbox'] = 'kurzen Ordnernamen anzeigen'; | ||
$labels['full_mailbox'] = 'ganzen Ordnernamen anzeigen'; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
$labels = array(); | ||
$labels['shownotifies'] = 'Desktop Notifications'; | ||
$labels['conf_browser'] = 'Configure browser'; | ||
$labels['test_browser'] = 'Test'; | ||
$labels['check_ok'] = 'Your browser settings are correct.'; | ||
$labels['check_fail'] = 'It was not possible to show a notification, please click "Configure browser"!'; | ||
$labels['check_fail_blocked'] = 'Your browser blocked the notification, please set the permission in the browser settings!'; | ||
$labels['no_notifications'] = 'Your browser does not support Desktop Notifications!'; | ||
$labels['ok_notifications'] = 'The website already got the permission. Desktop Notifications should work.'; | ||
$labels['notification_title'] = 'New E-Mail from [from]'; | ||
|
||
$labels['seconds'] = 'seconds'; | ||
$labels['off'] = 'off'; | ||
$labels['durable'] = 'durable'; | ||
|
||
$labels['no_mailbox'] = 'don\'t show mailbox'; | ||
$labels['short_mailbox'] = 'show short mailbox'; | ||
$labels['full_mailbox'] = 'show full mailbox'; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
//Thanks to David Perez www.closemarketing.es | ||
$labels = array(); | ||
$labels['shownotifies'] = 'Notificaciones Escritorio'; | ||
$labels['conf_browser'] = 'Configurar Navegador'; | ||
$labels['test_browser'] = 'Test'; | ||
$labels['check_ok'] = 'La configuración de tu Navegador es correcta.'; | ||
$labels['check_fail'] = 'No fue posible mostrar la notificación, por favor haz clic en "Configurar Navegador"!'; | ||
$labels['check_fail_blocked'] = 'Your browser blocked the notification, please set the permission in the browser settings!'; | ||
$labels['no_notifications'] = 'Su Navegador no permite nofitificaciones!'; | ||
$labels['ok_notifications'] = 'Esta web ya tiene permiso. Las notificaciones por Escritorio deberían de estar funcionando.'; | ||
$labels['notification_title'] = 'Nuevo Email de [from]'; | ||
|
||
$labels['seconds'] = 'segundos'; | ||
$labels['off'] = 'desactivado'; | ||
$labels['durable'] = 'durable'; | ||
|
||
$labels['no_mailbox'] = 'no mostrar bandeja'; | ||
$labels['short_mailbox'] = 'mostrar un extracto de bandeja'; | ||
$labels['full_mailbox'] = 'mostrar toda la bandeja'; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
$labels = array(); | ||
$labels['shownotifies'] = 'Notifications de bureau'; | ||
$labels['conf_browser'] = 'Configurer votre navigateur'; | ||
$labels['test_browser'] = 'Test'; | ||
$labels['check_ok'] = 'Les paramètres de votre navigateur sont corrects.'; | ||
$labels['check_fail'] = 'Il n\'était pas possible d\'afficher les notifications, s\'il vous plaît cliquez sur "Configurer votre navigateur"!'; | ||
$labels['check_fail_blocked'] = 'Votre navigateur a bloqué la notification, s\'il vous plaît autorisez-les dans les paramètres du navigateur!'; | ||
$labels['no_notifications'] = 'Votre navigateur ne supporte pas les notifications de bureau!'; | ||
$labels['ok_notifications'] = 'Le site web déjà obtenu les permissions. La notifications de bureau devrait fonctionner.'; | ||
$labels['notification_title'] = 'Nouvel E-Mail de [from]'; | ||
|
||
$labels['seconds'] = 'secondes'; | ||
$labels['off'] = 'désactivées'; | ||
$labels['durable'] = 'permanantes'; | ||
|
||
$labels['no_mailbox'] = 'ne pas montrer le message'; | ||
$labels['short_mailbox'] = 'montrer un apperçu du message'; | ||
$labels['full_mailbox'] = 'montrer tout le message'; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
$labels = array(); | ||
$labels['shownotifies'] = 'Upozornenia na pracovnej ploche'; | ||
$labels['conf_browser'] = 'Nakonfigurovať prehliadač'; | ||
$labels['test_browser'] = 'Test'; | ||
$labels['check_ok'] = 'Nastavenia tvojho prehliadača sú správne.'; | ||
$labels['check_fail'] = 'Nebolo možné zobraziť upozornenie, kliknite na "Nakonfigurovať prehliadač"!'; | ||
$labels['check_fail_blocked'] = 'Tvoj prehliadač blokoval upozornenie, prosím, nastav právomoci v prehliadači!'; | ||
$labels['no_notifications'] = 'Tvoj prehliadač nepodporuje upozornenia na pracovnej ploche!'; | ||
$labels['ok_notifications'] = 'Stránka má už povolené upozornenia. Upozornenia na pracovnej ploche by mali fungovať.'; | ||
$labels['notification_title'] = 'Nový E-Mail od [from]'; | ||
|
||
$labels['seconds'] = 'sekúnd'; | ||
$labels['off'] = 'vypnuté'; | ||
$labels['durable'] = 'permanentne'; | ||
|
||
$labels['no_mailbox'] = 'nezobrazovať priečinok pošty'; | ||
$labels['short_mailbox'] = 'zobraziť skrátený priečinok pošty'; | ||
$labels['full_mailbox'] = 'zobraziť plnohodnotný priečinok pošty'; | ||
?> |