From c55337ce67ff50b2b2836852939b3ec79316215b Mon Sep 17 00:00:00 2001 From: alecpl Date: Mon, 30 Nov 2009 12:06:12 +0000 Subject: - write error to log if connection to managesieve server cannot be established --- plugins/managesieve/managesieve.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php index 92185e083..065524032 100644 --- a/plugins/managesieve/managesieve.php +++ b/plugins/managesieve/managesieve.php @@ -61,11 +61,13 @@ class managesieve extends rcube_plugin require_once($this->home . '/lib/Net/Sieve.php'); require_once($this->home . '/lib/rcube_sieve.php'); + $host = str_replace('%h', $_SESSION['imap_host'], $this->rc->config->get('managesieve_host', 'localhost')); + $port = $this->rc->config->get('managesieve_port', 2000); + // try to connect to managesieve server and to fetch the script $this->sieve = new rcube_sieve($_SESSION['username'], $this->rc->decrypt($_SESSION['password']), - str_replace('%h', $_SESSION['imap_host'], $this->rc->config->get('managesieve_host', 'localhost')), - $this->rc->config->get('managesieve_port', 2000), + $host, $port, $this->rc->config->get('managesieve_usetls', false), $this->rc->config->get('managesieve_disabled_extensions'), $this->rc->config->get('managesieve_debug', false) @@ -120,6 +122,9 @@ class managesieve extends rcube_plugin $this->rc->output->show_message('managesieve.filterunknownerror', 'error'); break; } + + raise_error(array('code' => 403, 'type' => 'php', 'message' => "Unable to connect to managesieve on $host:$port"), true, false); + // to disable 'Add filter' button set env variable $this->rc->output->set_env('filterconnerror', true); $this->script = array(); @@ -547,10 +552,12 @@ class managesieve extends rcube_plugin $select = new html_select(array('name' => '_set', 'id' => $attrib['id'], 'onchange' => 'rcmail.managesieve_set()')); - asort($list, SORT_LOCALE_STRING); + if ($list) { + asort($list, SORT_LOCALE_STRING); - foreach($list as $set) - $select->add($set . ($set == $active ? ' ('.$this->gettext('active').')' : ''), $set); + foreach($list as $set) + $select->add($set . ($set == $active ? ' ('.$this->gettext('active').')' : ''), $set); + } $out = $select->show($this->sieve->current); -- cgit v1.2.3