Add option to prepopulate vacation addresses on form init (#1490030)

pull/280/head
Aleksander Machniak 9 years ago
parent 4d35a983cc
commit d0a4f1152e

@ -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)

@ -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');

@ -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
. "</textarea>\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 .= '<div id="action_vacation' .$id.'" style="display:' .($action['type']=='vacation' ? 'inline' : 'none') .'">';
$out .= '<span class="label">'. rcube::Q($this->plugin->gettext('vacationreason')) .'</span><br />'
.'<textarea name="_action_reason['.$id.']" id="action_reason' .$id. '" '
@ -1780,8 +1788,10 @@ class rcube_sieve_engine
.'value="' . (is_array($action['subject']) ? rcube::Q(implode(', ', $action['subject']), 'strict', false) : $action['subject']) . '" size="35" '
. $this->error_class($id, 'action', 'subject', 'action_subject') .' />';
$out .= '<br /><span class="label">' .rcube::Q($this->plugin->gettext('vacationaddr')) . '</span><br />'
. $this->list_input($id, 'action_addresses', $action['addresses'], true,
$this->error_class($id, 'action', 'addresses', 'action_addresses'), 30);
. $this->list_input($id, 'action_addresses', $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 />'
.'<input type="text" name="_action_interval['.$id.']" id="action_interval'.$id.'" '
.'value="' .rcube::Q(rcube_sieve_vacation::vacation_interval($action), 'strict', false) . '" size="2" '
@ -2389,4 +2399,21 @@ class rcube_sieve_engine
$this->headers += $headers;
}
/**
* Get all e-mail addresses of the user
*/
protected function user_emails()
{
$addresses = $this->rc->user->list_emails();
foreach ($addresses as $idx => $email) {
$addresses[$idx] = $email['email'];
}
$addresses = array_unique($addresses);
sort($addresses);
return $addresses;
}
}

@ -329,14 +329,23 @@ class rcube_sieve_vacation extends rcube_sieve_engine
'noclose' => true
) + $attrib);
$auto_addr = $this->rc->config->get('managesieve_vacation_addresses_init');
$addresses = !$auto_addr || count($this->vacation) > 1 ? (array) $this->vacation['addresses'] : $this->user_emails();
// form elements
$subject = new html_inputfield(array('name' => 'vacation_subject', 'id' => 'vacation_subject', 'size' => 50));
$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", (array) $this->vacation['addresses']), 'strict', false) . '</textarea>';
. rcube::Q(implode("\n", $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(
'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);

@ -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';

@ -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)
{

@ -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;
}

@ -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;
}

Loading…
Cancel
Save