From ebb204793b976482ce7d729b3c7e9e1069b9e56e Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 23 Jul 2012 10:24:16 +0200 Subject: Added GUI for variables setting - RFC5229 (patch from Paweł Słowik) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/managesieve/managesieve.php | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'plugins/managesieve/managesieve.php') diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php index 70ef5f597..7f591f5a8 100644 --- a/plugins/managesieve/managesieve.php +++ b/plugins/managesieve/managesieve.php @@ -615,6 +615,9 @@ class managesieve extends rcube_plugin $days = get_input_value('_action_days', RCUBE_INPUT_POST); $subject = get_input_value('_action_subject', RCUBE_INPUT_POST, true); $flags = get_input_value('_action_flags', RCUBE_INPUT_POST); + $varnames = get_input_value('_action_varname', RCUBE_INPUT_POST); + $varvalues = get_input_value('_action_varvalue', RCUBE_INPUT_POST); + $varmods = get_input_value('_action_varmods', RCUBE_INPUT_POST); // we need a "hack" for radiobuttons foreach ($sizeitems as $item) @@ -849,6 +852,20 @@ class managesieve extends rcube_plugin if ($this->form['actions'][$i]['days'] && !preg_match('/^[0-9]+$/', $this->form['actions'][$i]['days'])) $this->errors['actions'][$i]['days'] = $this->gettext('forbiddenchars'); break; + + case 'set': + if (empty($varnames[$idx])) { + $this->errors['actions'][$i]['name'] = $this->gettext('cannotbeempty'); + } + if (empty($varvalues[$idx])) { + $this->errors['actions'][$i]['value'] = $this->gettext('cannotbeempty'); + } + foreach ($varmods[$idx] as $v_m) { + $this->form['actions'][$i][$v_m] = true; + } + $this->form['actions'][$i]['name'] = $varnames[$idx]; + $this->form['actions'][$i]['value'] = $varvalues[$idx]; + break; } $this->form['actions'][$i]['type'] = $type; @@ -1447,6 +1464,9 @@ class managesieve extends rcube_plugin $select_action->add(Q($this->gettext('addflags')), 'addflag'); $select_action->add(Q($this->gettext('removeflags')), 'removeflag'); } + if (in_array('variables', $this->exts)) { + $select_action->add(Q($this->gettext('setvariable')), 'set'); + } $select_action->add(Q($this->gettext('rulestop')), 'stop'); $select_type = $action['type']; @@ -1510,6 +1530,33 @@ class managesieve extends rcube_plugin } $out .= ''; + // set variable + $set_modifiers = array( + 'lower', + 'upper', + 'lowerfirst', + 'upperfirst', + 'quotewildcard', + 'length' + ); + + $out .= '
'; + $out .= '' .Q($this->gettext('setvarname')) . '
' + .'error_class($id, 'action', 'name', 'action_varname') .' />'; + $out .= '
' .Q($this->gettext('setvarvalue')) . '
' + .'error_class($id, 'action', 'value', 'action_varvalue') .' />'; + $out .= '
' .Q($this->gettext('setvarmodifiers')) . '
'; + foreach ($set_modifiers as $j => $s_m) { + $s_m_id = 'action_varmods' . $id . $s_m; + $out .= sprintf('%s
', + $id, $s_m, $s_m_id, (array_key_exists($s_m, (array)$action) && $action[$s_m] ? ' checked="checked"' : ''), $s_m); + } + $out .= '
'; + // mailbox select if ($action['type'] == 'fileinto') $mailbox = $this->mod_mailbox($action['target'], 'out'); -- cgit v1.2.3