Do virtual folder rebuilding in add/remove poll functions
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 4 Dec 2009 08:18:36 +0000 (01:18 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 4 Dec 2009 08:18:36 +0000 (01:18 -0700)
imp/folders.php
imp/lib/Imap/Tree.php

index 9209a06..65f9b1e 100644 (file)
@@ -214,10 +214,14 @@ case 'toggle_subscribed_view':
     break;
 
 case 'poll_folder':
+    if (!empty($folder_list)) {
+        $imaptree->addPollList($folder_list);
+    }
+    break;
+
 case 'nopoll_folder':
     if (!empty($folder_list)) {
-        ($actionID == 'poll_folder') ? $imaptree->addPollList($folder_list) : $imaptree->removePollList($folder_list);
-        $imp_search->createVINBOXFolder();
+        $imaptree->removePollList($folder_list);
     }
     break;
 
index ceed6b5..7a6b39d 100644 (file)
@@ -1201,17 +1201,26 @@ class IMP_Imap_Tree
             return;
         }
 
+        $changed = false;
+
         $imp_folder = IMP_Folder::singleton();
         $this->getPollList();
         foreach ($id as $val) {
             if (!$this->isSubscribed($this->_tree[$val])) {
                 $imp_folder->subscribe(array($val));
             }
-            $this->_poll[$val] = true;
             $this->_setPolled($this->_tree[$val], true);
+            if (empty($this->_poll[$val])) {
+                $this->_poll[$val] = true;
+                $changed = true;
+            }
+        }
+
+        if ($changed) {
+            $GLOBALS['prefs']->setValue('nav_poll', serialize($this->_poll));
+            $GLOBALS['imp_search']->createVINBOXFolder();
+            $this->_changed = true;
         }
-        $GLOBALS['prefs']->setValue('nav_poll', serialize($this->_poll));
-        $this->_changed = true;
     }
 
     /**
@@ -1245,6 +1254,7 @@ class IMP_Imap_Tree
 
         if ($removed) {
             $GLOBALS['prefs']->setValue('nav_poll', serialize($this->_poll));
+            $GLOBALS['imp_search']->createVINBOXFolder();
             $this->_changed = true;
         }
     }