diff options
author | Aleksander Machniak <machniak@kolabsys.com> | 2016-09-22 10:26:21 +0300 |
---|---|---|
committer | Aleksander Machniak <machniak@kolabsys.com> | 2016-09-22 10:26:21 +0300 |
commit | 46f45a3970c2f6701b96557cf5364985da1776c3 (patch) | |
tree | 5b4f373087d4bf8b24203ecf8b5ae5db11840520 /plugins/managesieve | |
parent | c1c0a0d815b90dc35af28ba71fc988f7badb1af0 (diff) |
Managesieve: Add option to automatically set vacation :from address (#5428)
Diffstat (limited to 'plugins/managesieve')
-rw-r--r-- | plugins/managesieve/Changelog | 1 | ||||
-rw-r--r-- | plugins/managesieve/config.inc.php.dist | 4 | ||||
-rw-r--r-- | plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php | 16 | ||||
-rw-r--r-- | plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php | 14 | ||||
-rw-r--r-- | plugins/managesieve/skins/larry/managesieve.css | 16 |
5 files changed, 31 insertions, 20 deletions
diff --git a/plugins/managesieve/Changelog b/plugins/managesieve/Changelog index deeecc90c..916c2998f 100644 --- a/plugins/managesieve/Changelog +++ b/plugins/managesieve/Changelog @@ -1,5 +1,6 @@ - Fix parsing of vacation date-time with non-default date_format (#5372) - Fix regression where js error is thrown if server does not support 'duplicate' extension +- Add option to automatically set vacation :from address (#5428) * version 8.7 [2016-07-19] ----------------------------------------------------------- diff --git a/plugins/managesieve/config.inc.php.dist b/plugins/managesieve/config.inc.php.dist index 835db538c..5b4586af0 100644 --- a/plugins/managesieve/config.inc.php.dist +++ b/plugins/managesieve/config.inc.php.dist @@ -96,5 +96,9 @@ $config['managesieve_vacation_interval'] = 0; // of these on initial vacation form creation. $config['managesieve_vacation_addresses_init'] = false; +// Sometimes you want to always reply with mail email address +// This option enables automatic filling of :from field on initial vacation form creation. +$config['managesieve_vacation_from_init'] = false; + // Supported methods of notify extension. Default: 'mailto' $config['managesieve_notify_methods'] = array('mailto'); diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php index 004e1e6d9..23dd42d8f 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php @@ -1947,7 +1947,17 @@ class rcube_sieve_engine // vacation $vsec = in_array('vacation-seconds', $this->exts); $auto_addr = $this->rc->config->get('managesieve_vacation_addresses_init'); - $addresses = isset($action['addresses']) || !$auto_addr ? (array) $action['addresses'] : $this->user_emails(); + $from_addr = $this->rc->config->get('managesieve_vacation_from_init'); + + if (empty($action)) { + if ($auto_addr) { + $action['addresses'] = $this->user_emails(); + } + if ($from_addr) { + $default_identity = $this->rc->user->list_emails(true); + $action['from'] = $default_identity['email']; + } + } $out .= '<div id="action_vacation' .$id.'" style="display:' .($action['type']=='vacation' ? 'inline' : 'none') .'">'; $out .= '<span class="label">'. rcube::Q($this->plugin->gettext('vacationreason')) .'</span><br>'; @@ -1977,8 +1987,8 @@ class rcube_sieve_engine 'class' => $this->error_class($id, 'action', 'from', 'action_from'), )); $out .= '<br><span class="label">' .rcube::Q($this->plugin->gettext('vacationaddr')) . '</span><br>'; - $out .= $this->list_input($id, 'action_addresses', $addresses, true, - $this->error_class($id, 'action', 'addresses', 'action_addresses'), 30) + $out .= $this->list_input($id, 'action_addresses', $action['addresses'], true, + $this->error_class($id, 'action', 'addresses', 'action_addresses'), 30) . html::a(array('href' => '#', 'onclick' => rcmail_output::JS_OBJECT_NAME . ".managesieve_vacation_addresses($id)"), rcube::Q($this->plugin->gettext('filladdresses'))); $out .= '<br><span class="label">' . rcube::Q($this->plugin->gettext($vsec ? 'vacationinterval' : 'vacationdays')) . '</span><br>'; diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php index 874110534..bba774490 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php @@ -339,8 +339,18 @@ class rcube_sieve_vacation extends rcube_sieve_engine 'noclose' => true ) + $attrib); + $from_addr = $this->rc->config->get('managesieve_vacation_from_init'); $auto_addr = $this->rc->config->get('managesieve_vacation_addresses_init'); - $addresses = !$auto_addr || count($this->vacation) > 1 ? (array) $this->vacation['addresses'] : $this->user_emails(); + + if (count($this->vacation) < 2) { + if ($auto_addr) { + $this->vacation['addresses'] = $this->user_emails(); + } + if ($from_addr) { + $default_identity = $this->rc->user->list_emails(true); + $this->vacation['from'] = $default_identity['email']; + } + } // form elements $from = new html_inputfield(array('name' => 'vacation_from', 'id' => 'vacation_from', 'size' => 50)); @@ -348,7 +358,7 @@ class rcube_sieve_vacation extends rcube_sieve_engine $reason = new html_textarea(array('name' => 'vacation_reason', 'id' => 'vacation_reason', 'cols' => 60, 'rows' => 8)); $interval = new html_inputfield(array('name' => 'vacation_interval', 'id' => 'vacation_interval', 'size' => 5)); $addresses = '<textarea name="vacation_addresses" id="vacation_addresses" data-type="list" data-size="30" style="display: none">' - . rcube::Q(implode("\n", $addresses), 'strict', false) . '</textarea>'; + . rcube::Q(implode("\n", (array) $this->vacation['addresses']), 'strict', false) . '</textarea>'; $status = new html_select(array('name' => 'vacation_status', 'id' => 'vacation_status')); $action = new html_select(array('name' => 'vacation_action', 'id' => 'vacation_action', 'onchange' => 'vacation_action_select()')); $addresses_link = new html_inputfield(array( diff --git a/plugins/managesieve/skins/larry/managesieve.css b/plugins/managesieve/skins/larry/managesieve.css index 6cea15935..2545ca406 100644 --- a/plugins/managesieve/skins/larry/managesieve.css +++ b/plugins/managesieve/skins/larry/managesieve.css @@ -373,6 +373,7 @@ td.rowtargets > span.listarea border-top: none; } +#vacationform .listelement input, #filter-form .listelement input { border: none; @@ -440,21 +441,6 @@ body.iframe.mail #filter-form max-height: 91px; } -#vacationform .listelement, -#vacationform .listelement .reset { - height: 22px; -} - -#vacationform .listelement .reset { - background-position: -1px 3px; -} - -#vacationform .listelement input { - vertical-align: top; - border: 0; - box-shadow: none; -} - #vacationform td.vacation { white-space: nowrap; } |