From 735bf7c3e1c02086aa2fa6a07e124090d7c90926 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Tue, 07 Feb 2012 04:42:51 -0500
Subject: [PATCH] - Backported r5859 fix

---
 plugins/newmail_notifier/newmail_notifier.php |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

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 <alec@alec.pl>
  *
  *
@@ -132,10 +132,31 @@
      */
     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

--
Gitblit v1.9.1