Remove IMP_Folder#flist()
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 25 Aug 2010 20:46:16 +0000 (14:46 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 25 Aug 2010 21:42:49 +0000 (15:42 -0600)
imp/lib/Api.php
imp/lib/Folder.php
imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php
imp/lib/Search.php
imp/lib/Views/Compose.php

index c90a9aa..dd29038 100644 (file)
@@ -73,7 +73,7 @@ class IMP_Api extends Horde_Registry_Api
      */
     public function folderlist()
     {
-        return $GLOBALS['injector']->getInstance('IMP_Folder')->flist();
+        return iterator_to_array(array_keys($GLOBALS['injector']->getInstance('IMP_IMAP_Tree')));
     }
 
     /**
index 5e4d525..fddf925 100644 (file)
@@ -32,67 +32,6 @@ class IMP_Folder
     );
 
     /**
-     * Lists folders.
-     *
-     * @param array $filter  An list of mailboxes that should be left out of
-     *                       the list (UTF7-IMAP).
-     * @param boolean $sub   Should we list only subscribed folders?
-     *
-     * @return array  An array of folders, where each array element is an
-     *                associative array containing three values:
-     * <pre>
-     * 'val' - (string)  Folder name (UTF7-IMAP)
-     * 'label' - (string) Full-length folder name (system charset)
-     * 'abbrev' - (string) Short (26 char) label (system charset)
-     * </pre>
-     */
-    public function flist($filter = array(), $sub = null)
-    {
-        $inbox_entry = array(
-            'INBOX' => array(
-                'val' => 'INBOX',
-                'label' => _("Inbox"),
-                'abbrev' => _("Inbox")
-            )
-        );
-
-        if ($_SESSION['imp']['protocol'] == 'pop') {
-            return $inbox_entry;
-        }
-
-        if (is_null($sub)) {
-            $sub = $GLOBALS['prefs']->getValue('subscribe');
-        }
-
-        $imaptree = $GLOBALS['injector']->getInstance('IMP_Imap_Tree');
-        $list_mask = IMP_Imap_Tree::FLIST_CONTAINER;
-        if (!$sub) {
-            $list_mask |= IMP_Imap_Tree::FLIST_UNSUB;
-        }
-        $imaptree->setIteratorFilter($list_mask);
-
-        foreach ($imaptree as $ob) {
-            if (in_array($ob->value, $filter)) {
-                continue;
-            }
-
-            $label = str_repeat(' ', 2 * $ob->level) . $ob->label;
-            $list[$ob->value] = array(
-                'abbrev' => Horde_String::abbreviate($label, 30),
-                'label' => $label,
-                'val' => $ob->container ? '' : $ob->value
-            );
-        }
-
-        /* Add the INBOX on top of list if not in the filter list. */
-        if (!in_array('INBOX', $filter)) {
-            $list = $inbox_entry + $list;
-        }
-
-        return $list;
-    }
-
-    /**
      * Deletes one or more folders.
      *
      * @param array $folders  Folders to be deleted (UTF7-IMAP).
index aa66df6..67f8bd1 100644 (file)
@@ -38,12 +38,12 @@ class IMP_LoginTasks_Task_DeleteSentmailMonthly extends Horde_LoginTasks_Task
            the date. */
         $identity = $GLOBALS['injector']->getInstance('IMP_Identity');
         $imp_folder = $GLOBALS['injector']->getInstance('IMP_Folder');
+        $imaptree = $GLOBALS['injector']->getInstance('IMP_Imap_Tree');
         $sent_mail_folders = $identity->getAllSentmailFolders();
 
         $folder_array = array();
-        $old_folders = $imp_folder->flist();
 
-        foreach (array_keys($old_folders) as $k) {
+        foreach ($imaptree as $k => $v) {
             foreach ($sent_mail_folders as $folder) {
                 if (preg_match('/^' . str_replace('/', '\/', $folder) . '-([^-]+)-([0-9]{4})$/i', $k, $regs)) {
                     $folder_array[$k] = Horde_String::convertCharset((is_numeric($regs[1])) ? mktime(0, 0, 0, $regs[1], 1, $regs[2]) : strtotime("$regs[1] 1, $regs[2]"), $GLOBALS['registry']->getCharset(), 'UTF7-IMAP');
index e5dabe4..53e8709 100644 (file)
@@ -525,13 +525,7 @@ class IMP_Search
         }
 
         /* Create Virtual Trash with new folder list. */
-        $fl = $GLOBALS['injector']->getInstance('IMP_Folder')->flist();
-        $flist = array('INBOX');
-        foreach ($fl as $mbox) {
-            if (!empty($mbox['val'])) {
-                $flist[] = $mbox['val'];
-            }
-        }
+        $flist = array_keys(iterator_to_array($GLOBALS['injector']->getInstance('IMP_Imap_Tree')));
 
         $query = new Horde_Imap_Client_Search_Query();
         $query->flag('\\deleted', true);
index 6b174fa..71eda38 100644 (file)
@@ -96,12 +96,18 @@ class IMP_Views_Compose
                     }
                 }
 
+                $imaptree = $GLOBALS['injector']->getInstance('IMP_Imap_Tree');
+                $imaptree->setIteratorFilter(IMP_Imap_Tree::FLIST_CONTAINER);
+
                 $flist = array();
-                foreach ($imp_folder->flist() as $val) {
-                    $tmp = array('l' => $val['abbrev'], 'v' => $val['val']);
-                    $tmp2 = IMP::displayFolder($val['val']);
-                    if ($val['val'] != $tmp2) {
-                        $tmp['f'] = $tmp2;
+                foreach ($imaptree as $val) {
+                    $tmp = array(
+                        'f' => $val->display,
+                        'l' => Horde_String::abbreviate(str_repeat(' ', 2 * $val->level) . $val->label, 30),
+                        'v' => $val->container ? '' : $val->value
+                    );
+                    if ($tmp['f'] == $tmp['v']) {
+                        unset($tmp['f']);
                     }
                     $flist[] = $tmp;
                 }