From 68f5b20a4093da319113c1eef6cb44b0ed1dbf44 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 30 Nov 2009 15:51:43 -0700 Subject: [PATCH] Make sure we rebuild mailbox caches when adding new account --- imp/lib/Application.php | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/imp/lib/Application.php b/imp/lib/Application.php index 76950840d..ee602d4a6 100644 --- a/imp/lib/Application.php +++ b/imp/lib/Application.php @@ -682,10 +682,7 @@ class IMP_Application extends Horde_Registry_Application } if ($prefs->isDirty('subscribe') || $prefs->isDirty('tree_view')) { - $imp_folder = IMP_Folder::singleton(); - $imp_folder->clearFlistCache(); - $imaptree = IMP_Imap_Tree::singleton(); - $imaptree->init(); + $this->_mailboxesChanged(); } if ($prefs->isDirty('mail_domain')) { @@ -915,6 +912,7 @@ class IMP_Application extends Horde_Registry_Application */ protected function _prefsAccountsManagement() { + $success = false; $vars = Horde_Variables::getDefaultVariables(); switch ($vars->accounts_action) { @@ -945,6 +943,8 @@ class IMP_Application extends Horde_Registry_Application 'username' => $vars->accounts_username )); $GLOBALS['notification']->push(sprintf(_("Account \"%s\" added."), $vars->accounts_server), 'horde.success'); + + $success = true; } break; @@ -953,9 +953,14 @@ class IMP_Application extends Horde_Registry_Application $tmp = $imp_accounts->getAccount($vars->accounts_data); if ($imp_accounts->deleteAccount($vars->accounts_data)) { $GLOBALS['notification']->push(sprintf(_("Account \"%s\" deleted."), $tmp['server']), 'horde.success'); + $success = true; } break; } + + if ($success) { + $this->_mailboxesChanged(); + } } /** @@ -1050,10 +1055,7 @@ class IMP_Application extends Horde_Registry_Application return; } - $imp_folder = IMP_Folder::singleton(); - $imp_folder->clearFlistCache(); - $imaptree = IMP_Imap_Tree::singleton(); - $imaptree->init(); + $this->_mailboxesChanged(); $GLOBALS['imp_search']->initialize(true); } @@ -1097,4 +1099,17 @@ class IMP_Application extends Horde_Registry_Application return $credentials; } + /* Helper methods. */ + + /** + * Run tasks when the mailbox list has changed. + */ + protected function _mailboxesChanged() + { + $imp_folder = IMP_Folder::singleton(); + $imp_folder->clearFlistCache(); + $imaptree = IMP_Imap_Tree::singleton(); + $imaptree->init(); + } + } -- 2.11.0