Aleksander Machniak
2015-11-15 162bc85be9ded67203e4471c51cb26c19853d1a2
Add support for :from parameter in vacation action (patch from Michele Locati)
4 files modified
38 ■■■■■ changed files
plugins/managesieve/Changelog 4 ●●●● patch | view | raw | blame | history
plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php 12 ●●●●● patch | view | raw | blame | history
plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php 20 ●●●●● patch | view | raw | blame | history
plugins/managesieve/localization/en_US.inc 2 ●●●●● patch | view | raw | blame | history
plugins/managesieve/Changelog
@@ -1,3 +1,7 @@
* version 8.5 [2015-11-15]
-----------------------------------------------------------
- Add support for :from parameter in vacation action (patch from Michele Locati)
* version 8.4 [2015-04-20]
-----------------------------------------------------------
- Add option to prepopulate vacation addresses on form init (#1490030)
plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php
@@ -616,6 +616,7 @@
            $addresses      = rcube_utils::get_input_value('_action_addresses', rcube_utils::INPUT_POST, true);
            $intervals      = rcube_utils::get_input_value('_action_interval', rcube_utils::INPUT_POST);
            $interval_types = rcube_utils::get_input_value('_action_interval_type', rcube_utils::INPUT_POST);
            $from           = rcube_utils::get_input_value('_action_from', rcube_utils::INPUT_POST);
            $subject        = rcube_utils::get_input_value('_action_subject', rcube_utils::INPUT_POST, true);
            $flags          = rcube_utils::get_input_value('_action_flags', rcube_utils::INPUT_POST);
            $varnames       = rcube_utils::get_input_value('_action_varname', rcube_utils::INPUT_POST);
@@ -981,10 +982,11 @@
                    $interval_type = $interval_types[$idx] == 'seconds' ? 'seconds' : 'days';
                    $this->form['actions'][$i]['reason']    = str_replace("\r\n", "\n", $reason);
                    $this->form['actions'][$i]['from']      = $from[$idx];
                    $this->form['actions'][$i]['subject']   = $subject[$idx];
                    $this->form['actions'][$i]['addresses'] = array_shift($addresses);
                    $this->form['actions'][$i][$interval_type] = $intervals[$idx];
// @TODO: vacation :mime, :from, :handle
// @TODO: vacation :mime, :handle
                    foreach ((array)$this->form['actions'][$i]['addresses'] as $aidx => $address) {
                        $this->form['actions'][$i]['addresses'][$aidx] = $address = trim($address);
@@ -996,6 +998,10 @@
                            $this->errors['actions'][$i]['addresses'] = $this->plugin->gettext('noemailwarning');
                            break;
                        }
                    }
                    if (!empty($this->form['actions'][$i]['from']) && !rcube_utils::check_email($this->form['actions'][$i]['from'])) {
                        $this->errors['actions'][$i]['from'] = $this->plugin->gettext('noemailwarning');
                    }
                    if ($this->form['actions'][$i]['reason'] == '')
@@ -1787,6 +1793,10 @@
            .'<input type="text" name="_action_subject['.$id.']" id="action_subject'.$id.'" '
            .'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('vacationfrom')) . '</span><br />'
            .'<input type="text" name="_action_from['.$id.']" id="action_from'.$id.'" '
            .'value="' . $action['from'] . '" size="35" '
            . $this->error_class($id, 'action', 'from', 'action_from') .' />';
        $out .= '<br /><span class="label">' .rcube::Q($this->plugin->gettext('vacationaddr')) . '</span><br />'
            . $this->list_input($id, 'action_addresses', $addresses, true,
                $this->error_class($id, 'action', 'addresses', 'action_addresses'), 30)
plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php
@@ -181,6 +181,7 @@
        }
        $status        = rcube_utils::get_input_value('vacation_status', rcube_utils::INPUT_POST);
        $from          = rcube_utils::get_input_value('vacation_from', rcube_utils::INPUT_POST);
        $subject       = rcube_utils::get_input_value('vacation_subject', rcube_utils::INPUT_POST, true);
        $reason        = rcube_utils::get_input_value('vacation_reason', rcube_utils::INPUT_POST, true);
        $addresses     = rcube_utils::get_input_value('vacation_addresses', rcube_utils::INPUT_POST, true);
@@ -198,7 +199,8 @@
        $interval_type                   = $interval_type == 'seconds' ? 'seconds' : 'days';
        $vacation_action['type']         = 'vacation';
        $vacation_action['reason']       = $this->strip_value(str_replace("\r\n", "\n", $reason));
        $vacation_action['subject']      = $subject;
        $vacation_action['subject']      = trim($subject);
        $vacation_action['from']         = trim($from);
        $vacation_action['addresses']    = $addresses;
        $vacation_action[$interval_type] = $interval;
        $vacation_tests                  = (array) $this->vacation['tests'];
@@ -213,6 +215,10 @@
                $error = 'noemailwarning';
                break;
            }
        }
        if (!empty($vacation_action['from']) && !rcube_utils::check_email($vacation_action['from'])) {
            $error = 'noemailwarning';
        }
        if ($vacation_action['reason'] == '') {
@@ -335,6 +341,7 @@
        $addresses = !$auto_addr || count($this->vacation) > 1 ? (array) $this->vacation['addresses'] : $this->user_emails();
        // 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));
@@ -471,6 +478,8 @@
        // Advanced tab
        $table = new html_table(array('cols' => 2));
        $table->add('title', html::label('vacation_from', $this->plugin->gettext('vacation.from')));
        $table->add(null, $from->show($this->vacation['from']));
        $table->add('title', html::label('vacation_addresses', $this->plugin->gettext('vacation.addresses')));
        $table->add(null, $addresses . $addresses_link->show($this->plugin->gettext('filladdresses')));
        $table->add('title', html::label('vacation_interval', $this->plugin->gettext('vacation.interval')));
@@ -753,6 +762,7 @@
            'action'    => $this->vacation['action'],
            'target'    => $this->vacation['target'],
            'addresses' => $this->vacation['addresses'],
            'from'      => $this->vacation['from'],
        );
        return $vacation;
@@ -781,7 +791,8 @@
        $vacation['type']      = 'vacation';
        $vacation['reason']    = $this->strip_value(str_replace("\r\n", "\n", $data['message']));
        $vacation['addresses'] = $data['addresses'];
        $vacation['subject']   = $data['subject'];
        $vacation['subject']   = trim($data['subject']);
        $vacation['from']      = trim($data['from']);
        $vacation_tests        = (array) $this->vacation['tests'];
        foreach ((array) $vacation['addresses'] as $aidx => $address) {
@@ -796,6 +807,11 @@
            }
        }
        if (!empty($vacation['from']) && !rcube_utils::check_email($vacation['from'])) {
            $this->error = "Invalid address in 'from': " . $vacation['from'];
            return false;
        }
        if ($vacation['reason'] == '') {
            $this->error = "No vacation message specified";
            return false;
plugins/managesieve/localization/en_US.inc
@@ -60,6 +60,7 @@
$labels['vacationdays'] = 'How often send messages (in days):';
$labels['vacationinterval'] = 'How often send messages:';
$labels['vacationreason'] = 'Message body (vacation reason):';
$labels['vacationfrom'] = 'Reply sender address:';
$labels['vacationsubject'] = 'Message subject:';
$labels['days'] = 'days';
$labels['seconds'] = 'seconds';
@@ -165,6 +166,7 @@
$labels['vacation'] = 'Vacation';
$labels['vacation.reply'] = 'Reply message';
$labels['vacation.advanced'] = 'Advanced settings';
$labels['vacation.from'] = 'Reply sender address';
$labels['vacation.subject'] = 'Subject';
$labels['vacation.body'] = 'Body';
$labels['vacation.start'] = 'Vacation start';