From 6d5a1b9e8f426d5ddc7c5bf2840a25859ab9d9e1 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sat, 28 Jun 2014 10:07:44 +0200 Subject: Get rid of some rcube_config::all() calls --- program/include/rcmail.php | 35 ++++++++++++++++++++--------------- program/lib/Roundcube/rcube.php | 10 +++++++--- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/program/include/rcmail.php b/program/include/rcmail.php index cfdd1816e..0151020c7 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -730,14 +730,16 @@ class rcmail extends rcube */ public function logout_actions() { - $config = $this->config->all(); - $storage = $this->get_storage(); + $storage = $this->get_storage(); + $logout_expunge = $this->config->get('logout_expunge'); + $logout_purge = $this->config->get('logout_purge'); + $trash_mbox = $this->config->get('trash_mbox'); - if ($config['logout_purge'] && !empty($config['trash_mbox'])) { - $storage->clear_folder($config['trash_mbox']); + if ($logout_purge && !empty($trash_mbox)) { + $storage->clear_folder($trash_mbox); } - if ($config['logout_expunge']) { + if ($logout_expunge) { $storage->expunge_folder('INBOX'); } @@ -887,12 +889,15 @@ class rcmail extends rcube $prefix = $this->storage->get_namespace('prefix'); $prefix_len = strlen($prefix); - if (!$prefix_len) + if (!$prefix_len) { return; + } - $prefs = $this->config->all(); - if (!empty($prefs['namespace_fixed'])) + if ($this->config->get('namespace_fixed')) { return; + } + + $prefs = array(); // Build namespace prefix regexp $ns = $this->storage->get_namespace(); @@ -912,16 +917,16 @@ class rcmail extends rcube // Fix preferences $opts = array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox', 'archive_mbox'); foreach ($opts as $opt) { - if ($value = $prefs[$opt]) { + if ($value = $this->config->get($opt)) { if ($value != 'INBOX' && !preg_match($regexp, $value)) { $prefs[$opt] = $prefix.$value; } } } - if (!empty($prefs['search_mods'])) { + if (($search_mods = $this->config->get('search_mods')) && !empty($search_mods)) { $folders = array(); - foreach ($prefs['search_mods'] as $idx => $value) { + foreach ($search_mods as $idx => $value) { if ($idx != 'INBOX' && $idx != '*' && !preg_match($regexp, $idx)) { $idx = $prefix.$idx; } @@ -931,9 +936,9 @@ class rcmail extends rcube $prefs['search_mods'] = $folders; } - if (!empty($prefs['message_threading'])) { + if (($threading = $this->config->get('message_threading')) && !empty($threading)) { $folders = array(); - foreach ($prefs['message_threading'] as $idx => $value) { + foreach ($threading as $idx => $value) { if ($idx != 'INBOX' && !preg_match($regexp, $idx)) { $idx = $prefix.$idx; } @@ -943,8 +948,8 @@ class rcmail extends rcube $prefs['message_threading'] = $folders; } - if (!empty($prefs['collapsed_folders'])) { - $folders = explode('&&', $prefs['collapsed_folders']); + if ($collapsed = $this->config->get('collapsed_folders')) { + $folders = explode('&&', $collapsed); $count = count($folders); $folders_str = ''; diff --git a/program/lib/Roundcube/rcube.php b/program/lib/Roundcube/rcube.php index cf54c3c12..5f55414e6 100644 --- a/program/lib/Roundcube/rcube.php +++ b/program/lib/Roundcube/rcube.php @@ -172,9 +172,13 @@ class rcube public function get_dbh() { if (!$this->db) { - $config_all = $this->config->all(); - $this->db = rcube_db::factory($config_all['db_dsnw'], $config_all['db_dsnr'], $config_all['db_persistent']); - $this->db->set_debug((bool)$config_all['sql_debug']); + $this->db = rcube_db::factory( + $this->config->get('db_dsnw'), + $this->config->get('db_dsnr'), + $this->config->get('db_persistent') + ); + + $this->db->set_debug((bool)$this->config->get('sql_debug')); } return $this->db; -- cgit v1.2.3