X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=plugins%2Fnewmail_notifier%2Fnewmail_notifier.php;fp=plugins%2Fnewmail_notifier%2Fnewmail_notifier.php;h=f9af72d2f0fbc3d6949e603c20d1bf7b633f990b;hb=b06ca1de90262dfb6d8eabe9a4037a8e36e930cc;hp=01e25984d5dee7620eb779449770fbd889d5dbf1;hpb=5058e04171cbe6d82a65fc9d869ddef90e829e36;p=roundcube.git diff --git a/plugins/newmail_notifier/newmail_notifier.php b/plugins/newmail_notifier/newmail_notifier.php index 01e2598..f9af72d 100644 --- a/plugins/newmail_notifier/newmail_notifier.php +++ b/plugins/newmail_notifier/newmail_notifier.php @@ -3,13 +3,13 @@ /** * New Mail Notifier plugin * - * Supports two methods of notification: + * Supports three methods of notification: * 1. Basic - focus browser window and change favicon * 2. Sound - play wav file * 3. Desktop - display desktop notification (using webkitNotifications feature, * supported by Chrome and Firefox with 'HTML5 Notifications' plugin) * - * @version 0.3 + * @version 0.4 * @author Aleksander Machniak * * @@ -132,10 +132,31 @@ class newmail_notifier extends rcube_plugin */ function notify($args) { + // Already notified or non-automatic check if ($this->notified || !empty($_GET['_refresh'])) { return $args; } + // Get folders to skip checking for + if (empty($this->exceptions)) { + $this->delimiter = $this->rc->imap->get_hierarchy_delimiter(); + foreach (array('drafts_mbox', 'sent_mbox') as $folder) { + $folder = $this->rc->config->get($folder); + if (strlen($folder) && $folder != 'INBOX') { + $this->exceptions[] = $folder; + } + } + } + + $mbox = $args['mailbox']; + + // Skip exception (sent/drafts) folders (and their subfolders) + foreach ($this->exceptions as $folder) { + if (strpos($mbox.$this->delimiter, $folder.$this->delimiter) === 0) { + return $args; + } + } + $this->notified = true; // Load configuration