From 05da1577aaa51cef329849c495469903333c59f2 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 29 Aug 2013 09:20:33 +0200 Subject: Fix setting of Junk and NonJunk flags by markasjunk plugin (#1489285) Added possibility to register flag mappings by a plugin. --- program/lib/Roundcube/rcube_imap_generic.php | 49 +++++++++++++++++++--------- 1 file changed, 34 insertions(+), 15 deletions(-) (limited to 'program/lib/Roundcube/rcube_imap_generic.php') diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php index e1193749b..bce4cd4e2 100644 --- a/program/lib/Roundcube/rcube_imap_generic.php +++ b/program/lib/Roundcube/rcube_imap_generic.php @@ -704,22 +704,11 @@ class rcube_imap_generic */ function connect($host, $user, $password, $options=null) { - // set options - if (is_array($options)) { - $this->prefs = $options; - } - // set auth method - if (!empty($this->prefs['auth_type'])) { - $auth_method = strtoupper($this->prefs['auth_type']); - } else { - $auth_method = 'CHECK'; - } + // configure + $this->set_prefs($options); - if (!empty($this->prefs['disabled_caps'])) { - $this->prefs['disabled_caps'] = array_map('strtoupper', (array)$this->prefs['disabled_caps']); - } - - $result = false; + $auth_method = $this->prefs['auth_type']; + $result = false; // initialize connection $this->error = ''; @@ -895,6 +884,36 @@ class rcube_imap_generic return false; } + /** + * Initializes environment + */ + protected function set_prefs($prefs) + { + // set preferences + if (is_array($prefs)) { + $this->prefs = $prefs; + } + + // set auth method + if (!empty($this->prefs['auth_type'])) { + $this->prefs['auth_type'] = strtoupper($this->prefs['auth_type']); + } + else { + $this->prefs['auth_type'] = 'CHECK'; + } + + // disabled capabilities + if (!empty($this->prefs['disabled_caps'])) { + $this->prefs['disabled_caps'] = array_map('strtoupper', (array)$this->prefs['disabled_caps']); + } + + // additional message flags + if (!empty($this->prefs['message_flags'])) { + $this->flags = array_merge($this->flags, $this->prefs['message_flags']); + unset($this->prefs['message_flags']); + } + } + /** * Checks connection status * -- cgit v1.2.3