diff --git a/plugins/managesieve/Changelog b/plugins/managesieve/Changelog
index 628725c97..a230ca2cc 100644
--- a/plugins/managesieve/Changelog
+++ b/plugins/managesieve/Changelog
@@ -1,3 +1,4 @@
+- Add option to prepopulate vacation addresses on form init (#1490030)
- Add option to define default vacation interval
- Fix missing position idicator in Larry skin when dragging a filter
- Fix incorrect filter data after filter delete (#1490356)
diff --git a/plugins/managesieve/config.inc.php.dist b/plugins/managesieve/config.inc.php.dist
index 08b98288c..835db538c 100644
--- a/plugins/managesieve/config.inc.php.dist
+++ b/plugins/managesieve/config.inc.php.dist
@@ -91,5 +91,10 @@ $config['managesieve_vacation'] = 0;
// to define interval in seconds here (as a string), e.g. "3600s".
$config['managesieve_vacation_interval'] = 0;
+// Some servers require vacation :addresses to be filled with all
+// user addresses (aliases). This option enables automatic filling
+// of these on initial vacation form creation.
+$config['managesieve_vacation_addresses_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 b8af0373d..46237340d 100644
--- a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
+++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
@@ -441,6 +441,11 @@ class rcube_sieve_engine
$this->rc->output->command('managesieve_actionfill', $content, $id, $aid);
}
+ else if ($action == 'addresses') {
+ $aid = rcube_utils::get_input_value('_aid', rcube_utils::INPUT_POST);
+
+ $this->rc->output->command('managesieve_vacation_addresses_update', $aid, $this->user_emails());
+ }
$this->rc->output->send();
}
@@ -1769,7 +1774,10 @@ class rcube_sieve_engine
. "\n";
// vacation
- $vsec = in_array('vacation-seconds', $this->exts);
+ $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();
+
$out .= '
';
$out .= ''. rcube::Q($this->plugin->gettext('vacationreason')) .'
'
.'';
$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(
+ 'type' => 'button',
+ 'href' => '#',
+ 'class' => 'button',
+ 'onclick' => rcmail_output::JS_OBJECT_NAME . '.managesieve_vacation_addresses()'
+ ));
$status->add($this->plugin->gettext('vacation.on'), 'on');
$status->add($this->plugin->gettext('vacation.off'), 'off');
@@ -461,7 +470,7 @@ class rcube_sieve_vacation extends rcube_sieve_engine
$table = new html_table(array('cols' => 2));
$table->add('title', html::label('vacation_addresses', $this->plugin->gettext('vacation.addresses')));
- $table->add(null, $addresses);
+ $table->add(null, $addresses . $addresses_link->show($this->plugin->gettext('filladdresses')));
$table->add('title', html::label('vacation_interval', $this->plugin->gettext('vacation.interval')));
$table->add(null, $interval_txt);
diff --git a/plugins/managesieve/localization/en_US.inc b/plugins/managesieve/localization/en_US.inc
index f455d55f6..3b03b6bf1 100644
--- a/plugins/managesieve/localization/en_US.inc
+++ b/plugins/managesieve/localization/en_US.inc
@@ -56,7 +56,7 @@ $labels['add'] = 'Add';
$labels['del'] = 'Delete';
$labels['sender'] = 'Sender';
$labels['recipient'] = 'Recipient';
-$labels['vacationaddr'] = 'My additional e-mail address(es):';
+$labels['vacationaddr'] = 'My e-mail addresses:';
$labels['vacationdays'] = 'How often send messages (in days):';
$labels['vacationinterval'] = 'How often send messages:';
$labels['vacationreason'] = 'Message body (vacation reason):';
@@ -172,7 +172,7 @@ $labels['vacation.end'] = 'Vacation end';
$labels['vacation.status'] = 'Status';
$labels['vacation.on'] = 'On';
$labels['vacation.off'] = 'Off';
-$labels['vacation.addresses'] = 'My additional addresses';
+$labels['vacation.addresses'] = 'My e-mail addresses';
$labels['vacation.interval'] = 'Reply interval';
$labels['vacation.after'] = 'Put vacation rule after';
$labels['vacation.saving'] = 'Saving data...';
@@ -181,6 +181,7 @@ $labels['vacation.keep'] = 'Keep';
$labels['vacation.discard'] = 'Discard';
$labels['vacation.redirect'] = 'Redirect to';
$labels['vacation.copy'] = 'Send copy to';
+$labels['filladdresses'] = 'Fill with all my addresses';
$labels['arialabelfiltersetactions'] = 'Filter set actions';
$labels['arialabelfilteractions'] = 'Filter actions';
$labels['arialabelfilterform'] = 'Filter properties';
diff --git a/plugins/managesieve/managesieve.js b/plugins/managesieve/managesieve.js
index f0b5dc83e..1098b5b9e 100644
--- a/plugins/managesieve/managesieve.js
+++ b/plugins/managesieve/managesieve.js
@@ -581,6 +581,20 @@ rcube_webmail.prototype.managesieve_formbuttons = function(div)
}
};
+// update vacation addresses field with user identities
+rcube_webmail.prototype.managesieve_vacation_addresses = function(id)
+{
+ var lock = this.set_busy(true, 'loading');
+ this.http_post('plugin.managesieve-action', {_act: 'addresses', _aid: id}, lock);
+};
+
+// update vacation addresses field with user identities
+rcube_webmail.prototype.managesieve_vacation_addresses_update = function(id, addresses)
+{
+ var field = $('#vacation_addresses,#action_addresses' + (id || ''));
+ smart_field_reset(field.get(0), addresses);
+};
+
function rule_header_select(id)
{
var obj = document.getElementById('header' + id),
@@ -802,6 +816,21 @@ function smart_field_row(value, name, idx, size)
return elem;
}
+// Reset and fill the smart list input with new data
+function smart_field_reset(field, data)
+{
+ var id = field.id + '_list',
+ list = data.length ? data : [''];
+ area = $('#' + id);
+
+ area.empty();
+
+ // add input rows
+ $.each(list, function(i, v) {
+ area.append(smart_field_row(v, field.name, i, $(field).data('size')));
+ });
+}
+
// Register onmouse(leave/enter) events for tips on specified form element
rcube_webmail.prototype.managesieve_tip_register = function(tips)
{
diff --git a/plugins/managesieve/skins/classic/managesieve.css b/plugins/managesieve/skins/classic/managesieve.css
index 836e16d5a..5e7ea1a1c 100644
--- a/plugins/managesieve/skins/classic/managesieve.css
+++ b/plugins/managesieve/skins/classic/managesieve.css
@@ -219,6 +219,11 @@ td.rowtargets div.adv span.label
min-width: 65px;
}
+td.rowtargets div a
+{
+ margin-left: 10px;
+}
+
html.mozilla #filter-form select
{
padding-top: 3px;
@@ -338,6 +343,7 @@ a.button.disabled
display: inline-block;
max-height: 67px;
overflow-y: auto;
+ vertical-align: middle;
}
td.rowtargets > span.listarea
@@ -428,3 +434,7 @@ body.iframe.mail #filter-form
vertical-align: top;
border: 0;
}
+
+#vacationform input.button {
+ margin-left: 10px;
+}
diff --git a/plugins/managesieve/skins/larry/managesieve.css b/plugins/managesieve/skins/larry/managesieve.css
index aa502a07c..d5098e0ce 100644
--- a/plugins/managesieve/skins/larry/managesieve.css
+++ b/plugins/managesieve/skins/larry/managesieve.css
@@ -194,6 +194,10 @@ td.rowtargets div.adv span.label
min-width: 70px;
}
+td.rowtargets div a {
+ margin-left: 10px;
+}
+
input.disabled, input.disabled:hover
{
color: #999999;
@@ -312,7 +316,7 @@ a.button.disabled
/* revert larry style button */
#filter-form input.button
{
- padding: inherit;
+ padding: 4px 12px;
}
fieldset
@@ -332,6 +336,7 @@ fieldset
display: inline-block;
max-height: 59px;
overflow-y: auto;
+ vertical-align: middle;
}
td.rowtargets > span.listarea
@@ -448,3 +453,7 @@ body.iframe.mail #filter-form
#vacationform td.vacation {
white-space: nowrap;
}
+
+#vacationform input.button {
+ margin-left: 10px;
+}