Skip to content

Commit

Permalink
Correctly alphabetize folder list
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Feb 27, 2014
1 parent 635ea19 commit 6bf7b53
Showing 1 changed file with 39 additions and 35 deletions.
74 changes: 39 additions & 35 deletions imp/lib/Ajax/Application/Handler/Dynamic.php
Expand Up @@ -299,45 +299,12 @@ public function listMailboxes()
$this->_base->queue->setMailboxOpt('all', 1);
$iterator->append($filter);
} elseif ($this->vars->initial || $this->vars->reload) {
$no_mbox = false;

switch ($prefs->getValue('nav_expanded')) {
case IMP_Ftree_Prefs_Expanded::NO:
$filter->add($filter::CHILDREN);
break;

case IMP_Ftree_Prefs_Expanded::YES:
$this->_base->queue->setMailboxOpt('expand', 1);
$no_mbox = true;
break;

case IMP_Ftree_Prefs_Expanded::LAST:
$filter->add($filter::EXPANDED);
$this->_base->queue->setMailboxOpt('expand', 1);
break;
}

$iterator->append($filter);

if (!$no_mbox) {
$mboxes = IMP_Mailbox::formFrom(json_decode($this->vars->mboxes));
foreach ($mboxes as $val) {
if (!$val->inbox) {
$ancestors = new IMP_Ftree_IteratorFilter(
new IMP_Ftree_Iterator_Ancestors($val->tree_elt)
);
if ($this->vars->unsub) {
$ancestors->remove($ancestors::UNSUB);
}
$iterator->append($ancestors);
}
}
}
$special = new ArrayIterator();
$special->append($ftree['INBOX']);

/* Add special mailboxes explicitly to the initial folder list,
* since they are ALWAYS displayed, may appear outside of the
* folder slice requested, and need to be sorted logically. */
$special = new ArrayIterator();
$s_elts = array();
foreach (IMP_Mailbox::getSpecialMailboxesSort() as $val) {
if (isset($ftree[$val])) {
Expand Down Expand Up @@ -373,6 +340,43 @@ public function listMailboxes()
}
};
}

/* Add regular mailboxes. */
$no_mbox = false;

switch ($prefs->getValue('nav_expanded')) {
case IMP_Ftree_Prefs_Expanded::NO:
$filter->add($filter::CHILDREN);
break;

case IMP_Ftree_Prefs_Expanded::YES:
$this->_base->queue->setMailboxOpt('expand', 1);
$no_mbox = true;
break;

case IMP_Ftree_Prefs_Expanded::LAST:
$filter->add($filter::EXPANDED);
$this->_base->queue->setMailboxOpt('expand', 1);
break;
}

$filter->mboxes = array('INBOX');
$iterator->append($filter);

if (!$no_mbox) {
$mboxes = IMP_Mailbox::formFrom(json_decode($this->vars->mboxes));
foreach ($mboxes as $val) {
if (!$val->inbox) {
$ancestors = new IMP_Ftree_IteratorFilter(
new IMP_Ftree_Iterator_Ancestors($val->tree_elt)
);
if ($this->vars->unsub) {
$ancestors->remove($ancestors::UNSUB);
}
$iterator->append($ancestors);
}
}
}
} else {
$this->_base->queue->setMailboxOpt('expand', 1);
$filter->add($filter::EXPANDED);
Expand Down

0 comments on commit 6bf7b53

Please sign in to comment.