From 40b6df30c5a1e8f3597a2ded8bca592530023cca Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Mon, 23 Jul 2012 05:01:44 -0400
Subject: [PATCH] Fixed scrollbars in Larry's iframes

---
 plugins/managesieve/managesieve.php |   68 +++++++++++++++++++++++++++++++---
 1 files changed, 62 insertions(+), 6 deletions(-)

diff --git a/plugins/managesieve/managesieve.php b/plugins/managesieve/managesieve.php
index 2ef5712..70b280d 100644
--- a/plugins/managesieve/managesieve.php
+++ b/plugins/managesieve/managesieve.php
@@ -27,8 +27,6 @@
  * You should have received a copy of the GNU General Public License along
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * $Id$
  */
 
 class managesieve extends rcube_plugin
@@ -128,8 +126,9 @@
                 'command'  => 'managesieve-create',
                 'label'    => 'managesieve.filtercreate',
                 'type'     => 'link',
-                'classact' => 'filterlink active',
-                'class'    => 'filterlink',
+                'classact' => 'icon filterlink active',
+                'class'    => 'icon filterlink',
+                'innerclass' => 'icon filterlink',
             ))), 'messagemenu');
 
         // register some labels/messages
@@ -616,6 +615,9 @@
             $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)
@@ -708,9 +710,12 @@
                             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 +851,25 @@
                         $this->errors['actions'][$i]['reason'] = $this->gettext('cannotbeempty');
                     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;
                 }
 
@@ -1445,6 +1469,9 @@
             $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'];
@@ -1508,6 +1535,35 @@
         }
         $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');

--
Gitblit v1.9.1