Skip to content

Commit

Permalink
Managesieve: Add option to automatically set vacation :from address (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
alecpl committed Sep 22, 2016
1 parent c1c0a0d commit 46f45a3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ CHANGELOG Roundcube Webmail
- Indicate that a collapsed thread has flagged children (#5013)
- Implemented message/rfc822 attachment preview
- Update to jsTimezoneDetect 1.0.6
- Managesieve: Add option to automatically set vacation :from address (#5428)
- Managesieve: Support 'string' test from variables extension [RFC 5229] (#5248)
- Managesieve: Support 'duplicate' extension [RFC 7352]
- Managesieve: Unhide advanced rule controls if there are inputs with errors
Expand Down
1 change: 1 addition & 0 deletions plugins/managesieve/Changelog
Original file line number Diff line number Diff line change
@@ -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]
-----------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions plugins/managesieve/config.inc.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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');
16 changes: 13 additions & 3 deletions plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -1947,7 +1947,17 @@ function action_div($fid, $id, $div=true)
// 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>';
Expand Down Expand Up @@ -1977,8 +1987,8 @@ function action_div($fid, $id, $div=true)
'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>';
Expand Down
14 changes: 12 additions & 2 deletions plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,16 +339,26 @@ public function vacation_form($attrib)
'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));
$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", $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(
Expand Down
16 changes: 1 addition & 15 deletions plugins/managesieve/skins/larry/managesieve.css
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ td.rowtargets > span.listarea
border-top: none;
}

#vacationform .listelement input,
#filter-form .listelement input
{
border: none;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 46f45a3

Please sign in to comment.