Move update poll preference code to a single location
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 13 Sep 2010 04:14:00 +0000 (22:14 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 13 Sep 2010 05:50:30 +0000 (23:50 -0600)
imp/lib/Imap/Tree.php

index 2d6da34..28f6419 100644 (file)
@@ -1029,9 +1029,7 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable
         }
 
         if ($changed) {
-            $GLOBALS['prefs']->setValue('nav_poll', serialize($this->_cache['poll']));
-            $GLOBALS['injector']->getInstance('IMP_Search')->createVINBOXFolder();
-            $this->changed = true;
+            $this->_updatePollList();
         }
     }
 
@@ -1065,13 +1063,21 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable
         }
 
         if ($removed) {
-            $GLOBALS['prefs']->setValue('nav_poll', serialize($this->_cache['poll']));
-            $GLOBALS['injector']->getInstance('IMP_Search')->createVINBOXFolder();
-            $this->changed = true;
+            $this->_updatePollList();
         }
     }
 
     /**
+     * Update the nav_poll preference.
+     */
+    protected function _updatePollList()
+    {
+        $GLOBALS['prefs']->setValue('nav_poll', serialize($this->_cache['poll']));
+        $GLOBALS['injector']->getInstance('IMP_Search')->createVInbox();
+        $this->changed = true;
+    }
+
+    /**
      * Does the user want to poll this mailbox for new/unseen messages?
      *
      * @param array $elt  A tree element.