diff --git a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php index 9bccfcacf..cafd281d5 100644 --- a/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php +++ b/plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php @@ -457,7 +457,7 @@ class rcube_sieve_engine else if ($action == 'ruleadd') { $rid = rcube_utils::get_input_value('_rid', rcube_utils::INPUT_POST); $id = $this->genid(); - $content = $this->rule_div($fid, $id, false); + $content = $this->rule_div($fid, $id, false, $_SESSION['managesieve-compact-form']); $this->rc->output->command('managesieve_rulefill', $content, $id, $rid); } @@ -1435,8 +1435,11 @@ class rcube_sieve_engine if (!$attrib['id']) $attrib['id'] = 'rcmfilterform'; - $fid = rcube_utils::get_input_value('_fid', rcube_utils::INPUT_GPC); - $scr = isset($this->form) ? $this->form : $this->script[$fid]; + $fid = rcube_utils::get_input_value('_fid', rcube_utils::INPUT_GPC); + $scr = isset($this->form) ? $this->form : $this->script[$fid]; + $compact = !empty($attrib['compact-form']); + + $_SESSION['managesieve-compact-form'] = true; // do not allow creation of new rules if ($fid == null && in_array('new_rule', $this->disabled_actions)) { @@ -1449,8 +1452,7 @@ class rcube_sieve_engine $hiddenfields->add(array('name' => '_framed', 'value' => ($_POST['_framed'] || $_GET['_framed'] ? 1 : 0))); $hiddenfields->add(array('name' => '_fid', 'value' => $fid)); - $out = '
'."\n"; - $out .= $hiddenfields->show(); + $out = $hiddenfields->show(); // 'any' flag if ((!isset($this->form) && empty($scr['tests']) && !empty($scr)) @@ -1460,72 +1462,105 @@ class rcube_sieve_engine } // filter name input - $field_id = '_name'; - $input_name = new html_inputfield(array('name' => '_name', 'id' => $field_id, 'size' => 30, - 'class' => ($this->errors['name'] ? 'error' : ''))); + $input_name = new html_inputfield(array( + 'name' => '_name', + 'id' => '_name', + 'size' => 30, + 'class' => ($this->errors['name'] ? ' error' : '') + )); if ($this->errors['name']) - $this->add_tip($field_id, $this->errors['name'], true); + $this->add_tip('_name', $this->errors['name'], true); - if (isset($scr)) - $input_name = $input_name->show($scr['name']); - else - $input_name = $input_name->show(); + $input_name = $input_name->show(isset($scr) ? $scr['name'] : ''); - $out .= sprintf("\n %s\n", - $field_id, rcube::Q($this->plugin->gettext('filtername')), $input_name); + $out .= sprintf("\n" . '
' + . '' + . '
%s
', + rcube::Q($this->plugin->gettext('filtername')), $input_name); // filter set selector if ($this->rc->task == 'mail') { - $out .= sprintf("\n  %s\n", + $out .= sprintf("\n" . '
' + . '' + . '
%s
', $field_id, rcube::Q($this->plugin->gettext('filterset')), $this->filtersets_list(array('id' => 'sievescriptname'), true)); } + else if ($compact) { + $out .= sprintf("\n" . '
' + . '' + . '
', + rcube::Q($this->plugin->gettext('filterdisabled'))); + } - $out .= '

' . rcube::Q($this->plugin->gettext('messagesrules')) . "\n"; + if ($compact) { + $select = new html_select(array('name' => '_join', 'id' => '_join' . $id, + 'onchange' => 'rule_join_radio(this.value)')); - // any, allof, anyof radio buttons - $field_id = '_allof'; - $input_join = new html_radiobutton(array('name' => '_join', 'id' => $field_id, 'value' => 'allof', - 'onclick' => 'rule_join_radio(\'allof\')', 'class' => 'radio')); + foreach (array('allof', 'anyof', 'any') as $val) { + $select->add($this->plugin->gettext('filter' . $val), $val); + } - if (isset($scr) && !$any) - $input_join = $input_join->show($scr['join'] ? 'allof' : ''); - else - $input_join = $input_join->show(); + $join = $any ? 'any' : 'allof'; + if (isset($scr) && !$any) { + $join = $scr['join'] ? 'allof' : 'anyof'; + } - $out .= $input_join . html::label($field_id, rcube::Q($this->plugin->gettext('filterallof'))); + $out .= sprintf("\n" . '
' + . '' + . '
%s
', + rcube::Q($this->plugin->gettext('scope')), $select->show($join)); - $field_id = '_anyof'; - $input_join = new html_radiobutton(array('name' => '_join', 'id' => $field_id, 'value' => 'anyof', - 'onclick' => 'rule_join_radio(\'anyof\')', 'class' => 'radio')); + $out .= '\n" : "\n
\n"; // actions - $out .= '
' . rcube::Q($this->plugin->gettext('messagesactions')) . "\n"; + $label = $this->plugin->gettext($compact ? 'actions' : 'messagesactions'); + $out .= '
' . rcube::Q($label) . "\n"; $rows_num = isset($scr) ? count($scr['actions']) : 1; @@ -1547,10 +1582,14 @@ class rcube_sieve_engine ); $this->rc->output->add_gui_object('sieveform', 'filterform'); - return $out; + $attrib['name'] = 'filterform'; + $attrib['action'] = './'; + $attrib['method'] = 'post'; + + return html::tag('form', $attrib, $out, array('name', 'action', 'method', 'class')); } - function rule_div($fid, $id, $div=true) + function rule_div($fid, $id, $div = true, $compact = false) { $rule = isset($this->form) ? $this->form['tests'][$id] : $this->script[$fid]['tests'][$id]; $rows_num = isset($this->form) ? count($this->form['tests']) : count($this->script[$fid]['tests']); @@ -1607,6 +1646,7 @@ class rcube_sieve_engine } } + $tout = '
'; $aout = $select_header->show($test); // custom headers input @@ -1629,11 +1669,11 @@ class rcube_sieve_engine } } - // custom variable input - $tout = $this->list_input($id, 'custom_header', $custom, isset($custom), + // custom header and variable inputs + $aout .= $this->list_input($id, 'custom_header', $custom, isset($custom), $this->error_class($id, 'test', 'header', 'custom_header'), 15) . "\n"; - $tout .= $this->list_input($id, 'custom_var', $customv, isset($customv), + $aout .= $this->list_input($id, 'custom_var', $customv, isset($customv), $this->error_class($id, 'test', 'header', 'custom_var'), 15) . "\n"; // matching type select (operator) @@ -1702,7 +1742,7 @@ class rcube_sieve_engine $select_dp->add(rcube::Q($this->plugin->gettext($part)), $part); } - $tout .= $select_dp->show($rule['test'] == 'currentdate' || $rule['test'] == 'date' ? $rule['part'] : ''); + $aout .= $select_dp->show($rule['test'] == 'currentdate' || $rule['test'] == 'date' ? $rule['part'] : ''); } // message test select (e.g. duplicate) @@ -1723,11 +1763,16 @@ class rcube_sieve_engine $rule['test'] != 'size' && $rule['test'] != 'exists' && $rule['test'] != 'duplicate', $this->error_class($id, 'test', 'target', 'rule_target')) . "\n"; - $select_size_op = new html_select(array('name' => "_rule_size_op[]", 'id' => 'rule_size_op'.$id)); + $select_size_op = new html_select(array('name' => "_rule_size_op[]", 'id' => 'rule_size_op'.$id, 'class' => 'input-group-addon')); $select_size_op->add(rcube::Q($this->plugin->gettext('filterover')), 'over'); $select_size_op->add(rcube::Q($this->plugin->gettext('filterunder')), 'under'); - $tout .= '
'; + $select_size_item = new html_select(array('name' => "_rule_size_item[]", 'id' => 'rule_size_item'.$id, 'class' => 'input-group-addon')); + foreach (array('', 'K', 'M', 'G') as $unit) { + $select_size_item->add($this->plugin->gettext($unit . 'B'), $unit); + } + + $tout .= '
'; $tout .= $select_size_op->show($rule['test']=='size' ? $rule['type'] : ''); $tout .= html::tag('input', array( 'type' => 'text', @@ -1737,15 +1782,8 @@ class rcube_sieve_engine 'size' => 10, 'class' => $this->error_class($id, 'test', 'sizetarget', 'rule_size_i'), )); - foreach (array('', 'K', 'M', 'G') as $unit) { - $tout .= html::label(null, html::tag('input', array( - 'type' => 'radio', - 'name' => '_rule_size_item['.$id.']', - 'value' => $unit, - 'checked' => $sizeitem == $unit, - 'class' => 'radio', - )) . $this->rc->gettext($unit . 'B')); - } + $tout .= $select_size_item->show($sizeitem); + $tout .= '
'; $tout .= '
'; // Advanced modifiers (address, envelope) @@ -1767,10 +1805,10 @@ class rcube_sieve_engine } $need_mod = !in_array($rule['test'], array('size', 'body', 'date', 'currentdate', 'duplicate', 'string')); - $mout = '