summaryrefslogtreecommitdiff
path: root/plugins/managesieve/managesieve.php
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/managesieve/managesieve.php')
-rw-r--r--plugins/managesieve/managesieve.php82
1 files changed, 73 insertions, 9 deletions
diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php
index 486b3fb1d..e7828f1da 100644
--- a/plugins/managesieve/managesieve.php
+++ b/plugins/managesieve/managesieve.php
@@ -62,7 +62,7 @@ class managesieve extends rcube_plugin
"x-beenthere",
);
- const VERSION = '5.0';
+ const VERSION = '5.2';
const PROGNAME = 'Roundcube (Managesieve)';
@@ -109,16 +109,16 @@ class managesieve extends rcube_plugin
function mail_task_handler()
{
// use jQuery for popup window
- $this->require_plugin('jqueryui');
+ $this->require_plugin('jqueryui');
// include js script and localization
$this->init_ui();
// include styles
- $skin = $this->rc->config->get('skin');
- if (!file_exists($this->home."/skins/$skin/managesieve_mail.css"))
- $skin = 'default';
- $this->include_stylesheet("skins/$skin/managesieve_mail.css");
+ $skin_path = $this->local_skin_path();
+ if (is_file($this->home . "/$skin_path/managesieve_mail.css")) {
+ $this->include_stylesheet("$skin_path/managesieve_mail.css");
+ }
// add 'Create filter' item to message menu
$this->api->add_content(html::tag('li', null,
@@ -143,6 +143,13 @@ class managesieve extends rcube_plugin
*/
function mail_headers($args)
{
+ // this hook can be executed many times
+ if ($this->mail_headers_done) {
+ return $args;
+ }
+
+ $this->mail_headers_done = true;
+
$headers = $args['headers'];
$ret = array();
@@ -615,6 +622,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)
@@ -707,9 +717,12 @@ class managesieve extends rcube_plugin
if (!count($headers))
$this->errors['tests'][$i]['header'] = $this->gettext('cannotbeempty');
else {
- foreach ($headers as $hr)
- if (!preg_match('/^[a-z0-9-]+$/i', $hr))
+ foreach ($headers as $hr) {
+ // RFC2822: printable ASCII except colon
+ if (!preg_match('/^[\x21-\x39\x41-\x7E]+$/i', $hr)) {
$this->errors['tests'][$i]['header'] = $this->gettext('forbiddenchars');
+ }
+ }
}
if (empty($this->errors['tests'][$i]['header']))
@@ -846,6 +859,25 @@ 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':
+ $this->form['actions'][$i]['name'] = $varnames[$idx];
+ $this->form['actions'][$i]['value'] = $varvalues[$idx];
+ foreach ((array)$varmods[$idx] as $v_m) {
+ $this->form['actions'][$i][$v_m] = true;
+ }
+
+ if (empty($varnames[$idx])) {
+ $this->errors['actions'][$i]['name'] = $this->gettext('cannotbeempty');
+ }
+ else if (!preg_match('/^[0-9a-z_]+$/i', $varnames[$idx])) {
+ $this->errors['actions'][$i]['name'] = $this->gettext('forbiddenchars');
+ }
+
+ if (!isset($varvalues[$idx]) || $varvalues[$idx] === '') {
+ $this->errors['actions'][$i]['value'] = $this->gettext('cannotbeempty');
+ }
+ break;
}
$this->form['actions'][$i]['type'] = $type;
@@ -994,7 +1026,7 @@ class managesieve extends rcube_plugin
$this->rc->output->set_env('contentframe', $attrib['name']);
$this->rc->output->set_env('blankpage', $attrib['src'] ?
- $this->rc->output->abs_url($attrib['src']) : 'program/blank.gif');
+ $this->rc->output->abs_url($attrib['src']) : 'program/resources/blank.gif');
return html::tag('iframe', $attrib);
}
@@ -1444,6 +1476,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'];
@@ -1507,6 +1542,35 @@ class managesieve extends rcube_plugin
}
$out .= '</div>';
+ // set variable
+ $set_modifiers = array(
+ 'lower',
+ 'upper',
+ 'lowerfirst',
+ 'upperfirst',
+ 'quotewildcard',
+ 'length'
+ );
+
+ $out .= '<div id="action_set' .$id.'" style="display:' .($action['type']=='set' ? 'inline' : 'none') .'">';
+ $out .= '<span class="label">' .Q($this->gettext('setvarname')) . '</span><br />'
+ .'<input type="text" name="_action_varname['.$id.']" id="action_varname'.$id.'" '
+ .'value="' . Q($action['name']) . '" size="35" '
+ . $this->error_class($id, 'action', 'name', 'action_varname') .' />';
+ $out .= '<br /><span class="label">' .Q($this->gettext('setvarvalue')) . '</span><br />'
+ .'<input type="text" name="_action_varvalue['.$id.']" id="action_varvalue'.$id.'" '
+ .'value="' . Q($action['value']) . '" size="35" '
+ . $this->error_class($id, 'action', 'value', 'action_varvalue') .' />';
+ $out .= '<br /><span class="label">' .Q($this->gettext('setvarmodifiers')) . '</span><br />';
+ foreach ($set_modifiers as $j => $s_m) {
+ $s_m_id = 'action_varmods' . $id . $s_m;
+ $out .= sprintf('<input type="checkbox" name="_action_varmods[%s][]" value="%s" id="%s"%s />%s<br>',
+ $id, $s_m, $s_m_id,
+ (array_key_exists($s_m, (array)$action) && $action[$s_m] ? ' checked="checked"' : ''),
+ Q($this->gettext('var' . $s_m)));
+ }
+ $out .= '</div>';
+
// mailbox select
if ($action['type'] == 'fileinto')
$mailbox = $this->mod_mailbox($action['target'], 'out');