*/
public function folderlist()
{
- return $GLOBALS['injector']->getInstance('IMP_Folder')->flist();
+ return iterator_to_array(array_keys($GLOBALS['injector']->getInstance('IMP_IMAP_Tree')));
}
/**
);
/**
- * 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).
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');
}
/* 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);
}
}
+ $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;
}