From 8f617d1720ee010be80997e72b8dc624b21ff0ec Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Sat, 21 Sep 2013 23:39:07 -0600 Subject: [PATCH] Corectly expand remote account when authenticating --- imp/lib/Ajax/Application/Handler/Remote.php | 28 ++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/imp/lib/Ajax/Application/Handler/Remote.php b/imp/lib/Ajax/Application/Handler/Remote.php index afcd1e20569..45f845c0912 100644 --- a/imp/lib/Ajax/Application/Handler/Remote.php +++ b/imp/lib/Ajax/Application/Handler/Remote.php @@ -35,7 +35,7 @@ class IMP_Ajax_Application_Handler_Remote extends Horde_Core_Ajax_Application_Ha */ public function remoteLogin() { - global $injector, $notification; + global $injector, $notification, $prefs; $remote = $injector->getInstance('IMP_Remote'); $remoteid = IMP_Mailbox::formFrom($this->vars->remoteid); @@ -62,8 +62,34 @@ public function remoteLogin() $notification->push(sprintf(_("Successfully authenticated to %s."), $remote_ob->label), 'horde.success'); $ftree = $injector->getInstance('IMP_Ftree'); + + $ftree->eltdiff->track = false; $ftree->delete($remote_ob); $ftree->insert($remote_ob); + $ftree->eltdiff->track = true; + + $ftree[$remote_ob]->open = true; + $this->_base->queue->setMailboxOpt('expand', 1); + + switch ($prefs->getValue('nav_expanded')) { + case IMP_Ftree_Prefs_Expanded::NO: + $mask = IMP_Ftree_IteratorFilter::NO_CHILDREN; + break; + + case IMP_Ftree_Prefs_Expanded::YES: + $mask = 0; + break; + + case IMP_Ftree_Prefs_Expanded::LAST: + $mask = IMP_Ftree_IteratorFilter::NO_UNEXPANDED; + break; + } + + $iterator = IMP_Ftree_IteratorFilter::create($mask); + array_map( + array($ftree->eltdiff, 'add'), + array_unique(iterator_to_array($iterator, false)) + ); } catch (Exception $e) { $notification->push(sprintf(_("Could not authenticate to %s."), $remote_ob->label), 'horde.error'); }