Add Horde_Imap_Tree::getSpecialMailboxes()
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 7 Dec 2009 22:43:45 +0000 (15:43 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 8 Dec 2009 02:07:31 +0000 (19:07 -0700)
imp/lib/Imap/Tree.php

index 659cffe..e0945f9 100644 (file)
@@ -1807,19 +1807,27 @@ class IMP_Imap_Tree
      */
     protected function _initElement()
     {
-        if (isset($this->_eltCache)) {
-            return;
+        if (!isset($this->_eltCache)) {
+            $this->_eltCache = $this->getSpecialMailboxes();
+            $this->_eltCache['image_dir'] = $GLOBALS['registry']->getImageDir();
         }
+    }
 
-        /* Initialize the user's identities. */
+    /**
+     * Return the list of 'special' mailboxes.
+     *
+     * @return array  A list of folders, with keys of 'draft', 'sent', 'spam',
+     *                and 'trash' and values containing the mailbox names
+     *                ('sent' contains a list of mailbox names).
+     */
+    public function getSpecialMailboxes()
+    {
         $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp'));
-
-        $this->_eltCache = array(
-            'trash' => IMP::folderPref($GLOBALS['prefs']->getValue('trash_folder'), true),
+        return array(
             'draft' => IMP::folderPref($GLOBALS['prefs']->getValue('drafts_folder'), true),
-            'spam' => IMP::folderPref($GLOBALS['prefs']->getValue('spam_folder'), true),
             'sent' => $identity->getAllSentmailFolders(),
-            'image_dir' => $GLOBALS['registry']->getImageDir(),
+            'spam' => IMP::folderPref($GLOBALS['prefs']->getValue('spam_folder'), true),
+            'trash' => IMP::folderPref($GLOBALS['prefs']->getValue('trash_folder'), true)
         );
     }