Code

Put each class in a single file.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 13 Mar 2007 10:01:12 +0000 (10:01 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 13 Mar 2007 10:01:12 +0000 (10:01 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5771 594d385d-05f5-0310-b6e9-bd551577e9d8

20 files changed:
include/sieve/class_My_Parser.inc
include/sieve/class_My_Tree.inc
include/sieve/class_sieveElement_Block_End.inc [new file with mode: 0644]
include/sieve/class_sieveElement_Block_Start.inc [new file with mode: 0644]
include/sieve/class_sieveElement_Comment.inc [new file with mode: 0644]
include/sieve/class_sieveElement_Fileinto.inc [new file with mode: 0644]
include/sieve/class_sieveElement_If.inc
include/sieve/class_sieveElement_Keep.inc [new file with mode: 0644]
include/sieve/class_sieveElement_Redirect.inc [new file with mode: 0644]
include/sieve/class_sieveElement_Reject.inc [new file with mode: 0644]
include/sieve/class_sieveElement_Require.inc [new file with mode: 0644]
include/sieve/class_sieveElement_Stop.inc [new file with mode: 0644]
include/sieve/class_sieveElement_Vacation.inc [new file with mode: 0644]
include/sieve/class_sieveElements.inc [deleted file]
include/sieve/class_sieveManagement.inc
include/sieve/templates/element_address.tpl
include/sieve/templates/element_envelope.tpl
include/sieve/templates/element_header.tpl
include/sieve/templates/element_redirect.tpl
include/sieve/templates/element_require.tpl

index a45d24e83aa2455afb316ad7878c72eea7e82ff9..ea45beb998a90393108f1cfd02c5c62351fe060d 100644 (file)
@@ -45,6 +45,15 @@ class My_Parser extends Parser
        }
        
 
+       /* Check if there are errors, collect them and return them */
+       function check()
+       {
+               return($this->tree_->check());
+       }
+       
+
+       
+
        /* Initiate parser, but use some other 
      *  classes, that are rewritten.
      */
index 78522ba2a12de05f8eeda9dd45857b10476ff84a..1cb41a3a7e586215e3e14e6e4e9b318312432edd 100644 (file)
@@ -535,6 +535,19 @@ class My_Tree extends Tree
     $tmp = array("ELEMENTS" => array(array("class" => "qouted-string","text"=> "Bla bla, later more")));
     $this->pap[] = new sieve_comment($tmp,rand(1000,100000));
   }
+
+  function check()
+  {
+               $msgs = array();
+               foreach($this->pap as $obj){
+
+                       $o_msgs = $obj->check();
+                       foreach($o_msgs as $o_msg){
+                               $msgs[] = $o_msg;
+                       }
+               }
+               return($msgs);
+  }
 }
 
 
diff --git a/include/sieve/class_sieveElement_Block_End.inc b/include/sieve/class_sieveElement_Block_End.inc
new file mode 100644 (file)
index 0000000..403585f
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+
+class sieve_block_end 
+{
+  function execute()
+  {
+    $smarty = get_smarty();
+    return($smarty->fetch(get_template_path("templates/element_block_end.tpl",TRUE,dirname(__FILE__))));
+  }
+  function check()
+  {
+    return(array());
+  }
+
+  function get_sieve_script_part()
+  {
+    return("}\n");
+  } 
+  function save_object()
+  {
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/include/sieve/class_sieveElement_Block_Start.inc b/include/sieve/class_sieveElement_Block_Start.inc
new file mode 100644 (file)
index 0000000..799f1fa
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+
+class sieve_block_start 
+{
+  function execute()
+  {
+    $smarty = get_smarty();
+    return($smarty->fetch(get_template_path("templates/element_block_start.tpl",TRUE,dirname(__FILE__))));
+  }
+
+  function check()
+  {
+    return(array());
+  }
+
+  function save_object()
+  {
+  }
+
+  function get_sieve_script_part()
+  {
+    return("{\n");
+  } 
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/include/sieve/class_sieveElement_Comment.inc b/include/sieve/class_sieveElement_Comment.inc
new file mode 100644 (file)
index 0000000..d3f6747
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+
+/* Sieve comment tag */
+class sieve_comment 
+{
+  var $data = "";
+  var $object_id= -1;
+
+  function get_sieve_script_part()
+  {
+    return($this->data."\n");
+  } 
+    
+  function sieve_comment($data,$object_id)
+  {
+    $this->object_id = $object_id;
+    foreach($data['ELEMENTS'] as $node){
+       $this->data .= $node['text'];
+    }
+  }
+
+  function save_object()
+  {
+    if(isset($_POST['comment_'.$this->object_id])){
+      $cm = $_POST['comment_'.$this->object_id];
+      $this->data = "/*".$cm."*/";
+    }
+  }
+
+  function execute()
+  {
+    $smarty = get_smarty();
+    $smarty->assign("ID", $this->object_id);
+    $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
+    $Comment = $this->data;
+
+    /* Remove comment tags */
+    if(preg_match("/^#/",$Comment)){
+      $Comment = preg_replace("/^#/","",$Comment);
+    }elseif(preg_match("#\/\*#",$Comment)){
+      $Comment = preg_replace("#^\/\*#","",$Comment);
+      $Comment = preg_replace("#\*\/$#","",$Comment);
+    }
+    /* Create html object */ 
+    $smarty = get_smarty();
+    $smarty->assign("Comment",$Comment);
+    $smarty->assign("ID",$this->object_id);
+    $object = $smarty->fetch(get_template_path("templates/element_comment.tpl",TRUE,dirname(__FILE__)));    
+    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
+    return($str);
+  }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/include/sieve/class_sieveElement_Fileinto.inc b/include/sieve/class_sieveElement_Fileinto.inc
new file mode 100644 (file)
index 0000000..e595250
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+
+class sieve_fileinto 
+{
+  var $data     = array();
+  var $object_id= -1;
+  var $options  = array();
+
+  function save_object()
+  {
+    $mbs = $this->get_mail_boxes();
+    
+    if(isset($_POST['fileinto_'.$this->object_id])){
+      $mb = $_POST['fileinto_'.$this->object_id];
+
+      if(isset($mbs[$mb])) {
+        $this->data[0] = $mb; 
+      }
+    }
+  }
+
+  function sieve_fileinto($data,$object_id)
+  {
+    $this->object_id = $object_id;
+    foreach($data['ELEMENTS'] as $node ){
+      if(in_array($node['class'],array("quoted-string","text"))){
+        $this->data[] = preg_replace("/\"/","",$node['text']);
+      }
+    }
+  }
+
+  function get_sieve_script_part()
+  {
+    $tmp = "";
+    foreach($this->data as $dat){
+      $tmp.= "\"".$dat."\", ";
+    }
+    $tmp = preg_replace("/,$/","",trim($tmp));
+    $tmp = preg_replace ("/\"\"/","\"",$tmp);
+    return("fileinto ".$tmp.";\n");
+  } 
+    
+  function execute()
+  {
+    $smarty = get_smarty();
+    $smarty->assign("Selected",$this->data[0]);
+    $smarty->assign("Boxes", $this->get_mail_boxes());
+    $smarty->assign("ID", $this->object_id);
+    $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
+    $object= $smarty->fetch(get_template_path("templates/element_fileinto.tpl",TRUE,dirname(__FILE__)));
+    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
+
+    return($str);
+  }
+
+  function get_mail_boxes()
+  {
+    return(array("not"=>"not","impplemented/yet"=>"impplemented/yet"));
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
index c35c91a860e9a5abf99734b25649415bf9c989db..2cd0a65041eb08fd73c6c4505c338b65a18e98a7 100644 (file)
@@ -64,6 +64,63 @@ class sieve_if
   } 
 
 
+  /* Return error msgs */
+  function check()
+  {
+    $check = $this->check_recursive();
+    return($check);
+  }
+
+  /* Recursivly fetch all error msgs */
+  function check_recursive($parsed = NULL,$id = 1,$obj_id=1)
+  {
+    $ret = array();
+    if($parsed == NULL){
+      $parsed = $this->_parsed;
+    }
+
+    /* Walk through all elements */
+    foreach($parsed as $key => $data){
+
+      /* Create elements */
+      switch($key)
+      {
+        /*******************
+         * Allof / Anyof
+         *******************/
+        case "anyof" :
+        case "allof" :
+        { 
+          foreach($data as $key2 => $dat){
+            if(($key2 === "Inverse") && ($key2 == "Inverse")){
+              continue;
+            }
+            $msgs = $this->check_recursive($dat, ($id +1),$key2);
+
+            foreach($msgs as $msg){
+              $ret[] = $msg;
+            }
+          }
+          break;
+        }
+    
+        /*******************
+         * Default
+         *******************/
+
+        default: 
+        {
+          if(isset($data['LastError']) && !empty($data['LastError'])){
+            $ret[] = $data['LastError']; 
+          }
+        }
+      }
+    }
+    return($ret);
+  }
+
   /* Recursivly create a sieve script out of the given 
    *  tags and tokens provided by $parsed.
    *  $id       specifies the depth of the current element.
@@ -101,9 +158,7 @@ class sieve_if
           if($Inverse){
             $script .= "not ";
           }
           $script .= $key;
-   
           break;
         }
 
@@ -387,6 +442,8 @@ class sieve_if
           $match_types   = $this->match_types; 
           $operators     = $this->operators;
 
+          $parsed[$key]['LastError'] = "";
+
           /* Toggle Inverse ? */
           if(isset($_POST['toggle_inverse_'.$element_id])){
             $parsed[$key]['Inverse'] = !$parsed[$key]['Inverse'];
@@ -401,27 +458,30 @@ class sieve_if
           if(isset($_POST['address_part_'.$element_id])){
             $ap = $_POST['address_part_'.$element_id];
 
-            if(isset($address_parts[$ap])){
-              $parsed[$key]['Address_Part'] = $ap;
+            if(!isset($address_parts[$ap])){
+              $parsed[$key]['LastError'] = _("Invalid type of address part.") ;
             }
+            $parsed[$key]['Address_Part'] = $ap;
           }
 
           /* Check if match type has changed */
           if(isset($_POST['matchtype_'.$element_id])){
             $mt = $_POST['matchtype_'.$element_id];
 
-            if(isset($match_types[$mt])){
-              $parsed[$key]['Match_type'] = $mt;
+            if(!isset($match_types[$mt])){
+              $parsed[$key]['LastError'] = _("Invalid match type given.");
             }
+            $parsed[$key]['Match_type'] = $mt;
           }
 
           /* Get the comparator tag, if posted */
           if(isset($_POST['comparator_'.$element_id])){
             $cp = $_POST['comparator_'.$element_id];
 
-            if(isset($comparators[$cp])){
-              $parsed[$key]['Comparator'] = $cp;
+            if(!isset($comparators[$cp])){
+              $parsed[$key]['LastError'] = _("Invalid operator given.");
             }
+            $parsed[$key]['Comparator'] = $cp;
           }
 
           /* In case of :count and :value match types 
@@ -431,9 +491,10 @@ class sieve_if
             if(isset($_POST['operator_'.$element_id])){
               $op = $_POST['operator_'.$element_id];
 
-              if(isset($operators[$op])){
-                $parsed[$key]['Match_type_value'] = $op;
+              if(!isset($operators[$op])){
+                $parsed[$key]['LastError'] = _("Please specify a valid operator.");
               }
+              $parsed[$key]['Match_type_value'] = $op;
             }
           }
 
@@ -524,9 +585,7 @@ class sieve_if
           /* Get match type */
           if(isset($_POST['Match_type_'.$element_id])){
             $mt = $_POST['Match_type_'.$element_id];
-            if(isset($Match_types[$mt])){
-              $parsed['size']['Match_type'] = $mt;
-            }else{
+            if(!isset($Match_types[$mt])){
               $parsed['size']['LastError'] = _("Please select a valid match type in the list box below.");
             }
           }
@@ -539,22 +598,20 @@ class sieve_if
           if(isset($_POST['Value_'.$element_id])){
             $vl = $_POST['Value_'.$element_id];
          
-            if(is_numeric($vl) && preg_match("/^[0-9]*$/",$vl)){
-              $value = $vl;
-            }else{
+            if(!(is_numeric($vl) && preg_match("/^[0-9]*$/",$vl))){
               $parsed['size']['LastError'] = _("Only numeric values are allowed here.");
             }
+            $value = $vl;
           }        
 
           /* Get unit */
           if(isset($_POST['Value_Unit_'.$element_id])){
             $ut = $_POST['Value_Unit_'.$element_id];
        
-            if(isset($Units[$ut])){
-              $unit = $ut;
-            }else{
+            if(!isset($Units[$ut])){
               $parsed['size']['LastError'] = _("No valid unit selected");
             }
+            $unit = $ut;
           }        
 
           $parsed['size']['Value_List'][0] = $value.$unit;
@@ -627,12 +684,7 @@ class sieve_if
     $smarty->assign("Name", $name);
     $smarty->assign("Contents", $this->get_as_html());
     $object = $smarty->fetch(get_template_path("templates/element_if_else.tpl",TRUE,dirname(__FILE__)));
-
-
-
     $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
-   
-
     return($str);
   }
 
@@ -650,10 +702,8 @@ class sieve_if
 
       /* Create Inverse Tag */
       if(is_array($data) && isset($data['Inverse']) && $data['Inverse']){
-        $str_inverse = "<font color='red'><b>"._("Not")."</b></font>&nbsp;";
         $Inverse = TRUE;
       }else{
-        $str_inverse = "";
         $Inverse = FALSE;
       }
 
@@ -705,11 +755,10 @@ class sieve_if
           $smarty->assign("comparators",$comparators);
           $smarty->assign("match_types",$match_types);
           $smarty->assign("operators",$operators);
-
+          $smarty->assign("LastError",$data['LastError']);
           $smarty->assign("match_type", $data['Match_type']);
           $smarty->assign("operator"  , preg_replace("/\"/","",$data['Match_type_value']));
           $smarty->assign("comparator", preg_replace("/\"/","",$data['Comparator']));
-        
 
           $keys = "";
           foreach($data['Key_List'] as $key){
@@ -727,7 +776,6 @@ class sieve_if
           $smarty->assign("Inverse",$Inverse);
           $smarty->assign("values",$values);
           $smarty->assign("Expert", $data['Expert']);
-
  
           $smarty->assign("ID"  , $element_id); 
           $ret .= $smarty->fetch(get_template_path("templates/element_header.tpl",TRUE,dirname(__FILE__)));
@@ -752,7 +800,7 @@ class sieve_if
           $smarty->assign("Expert", $data['Expert']);
           $smarty->assign("match_types",$match_types);
           $smarty->assign("operators",$operators);
-
+          $smarty->assign("LastError",$data['LastError']);
           $smarty->assign("match_type", $data['Match_type']);
           $smarty->assign("operator"  , preg_replace("/\"/","",$data['Match_type_value']));
           $smarty->assign("comparator", preg_replace("/\"/","",$data['Comparator']));
@@ -793,13 +841,12 @@ class sieve_if
           $smarty->assign("address_parts",$address_parts);
           $smarty->assign("comparators",$comparators);
           $smarty->assign("match_types",$match_types);
+          $smarty->assign("LastError",$data['LastError']);
           $smarty->assign("operators",$operators);
-
           $smarty->assign("match_type", $data['Match_type']);
           $smarty->assign("operator"  , preg_replace("/\"/","",$data['Match_type_value']));
           $smarty->assign("comparator", preg_replace("/\"/","",$data['Comparator']));
           $smarty->assign("address_part", $data['Address_Part']);
-
           $smarty->assign("Expert", $data['Expert']);
         
           $keys = "";
@@ -815,8 +862,6 @@ class sieve_if
           $values = preg_replace("/,$/","",trim($values));
           $smarty->assign("keys",$keys);
           $smarty->assign("values",$values);
-
           $smarty->assign("ID"  , $element_id); 
           $ret .= $smarty->fetch(get_template_path("templates/element_address.tpl",TRUE,dirname(__FILE__)));
           break;
@@ -860,7 +905,6 @@ class sieve_if
         /*******************
          * Exists 
          *******************/
-       
         
         case "exists" : 
         {
@@ -1054,6 +1098,7 @@ class sieve_if
           $values["Address_Part"]    = $Address_Part;
         }
         $tmp[$type] = $values;
+        $tmp[$type]['LastError'] = "";
         break;
       }
 
@@ -1091,6 +1136,7 @@ class sieve_if
         $tmp[$type]= array( "Inverse"    => $Inverse,
                             "Match_type" => $Match_type,
                             "Value_List" => $Value_List);
+        $tmp[$type]['LastError'] = "";
         break;
       }
 
@@ -1102,11 +1148,13 @@ class sieve_if
       case "true": 
       {
         $tmp['true'] = "true";
+        $tmp[$type]['LastError'] = "";
         break;
       }
       case "false":
       {
         $tmp['false'] = "false";
+        $tmp[$type]['LastError'] = "";
         break;
       }
 
@@ -1131,6 +1179,7 @@ class sieve_if
         
         $tmp['exists'] = array('Inverse' => $Inverse,
                                'Values'  => $tmp2['STRINGS']);
+        $tmp[$type]['LastError'] = "";
         break;
       }
 
diff --git a/include/sieve/class_sieveElement_Keep.inc b/include/sieve/class_sieveElement_Keep.inc
new file mode 100644 (file)
index 0000000..8a8a412
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+
+/* This class handles the keep statement */
+class sieve_keep 
+{
+  var $object_id = -1;
+
+  function sieve_keep($data,$object_id)
+  {
+    $this->object_id = $object_id;
+  }
+
+  function save_object()
+  {
+  }
+
+  function check()
+  {
+    return(array());
+  }
+
+  function execute()
+  {
+    $smarty = get_smarty();
+    $smarty->assign("ID", $this->object_id);
+    $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
+    $object = $smarty->fetch(get_template_path("templates/element_keep.tpl",TRUE,dirname(__FILE__)));
+    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
+    return($str);
+  }
+  function get_sieve_script_part()
+  {
+    return("keep;\n");
+  } 
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/include/sieve/class_sieveElement_Redirect.inc b/include/sieve/class_sieveElement_Redirect.inc
new file mode 100644 (file)
index 0000000..13b851e
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+class sieve_redirect 
+{
+  var $data = array();
+  var $object_id = -1;
+
+  function save_object()
+  {
+    if(isset($_POST['redirect_to_'.$this->object_id])){
+      $rt = stripslashes($_POST['redirect_to_'.$this->object_id]);
+
+      $rt = "\"".trim(preg_replace("/\"/","",$rt))."\"";
+      $this->data = $rt;
+    }
+  }
+
+
+  function sieve_redirect($data,$object_id)
+  {
+    foreach($data['ELEMENTS'] as $node ){
+      if(in_array($node['class'],array("quoted-string","text"))){
+        $this->data = $node['text'];
+      }
+    }
+  }
+
+
+  function get_sieve_script_part()
+  {
+    return("redirect ".sieve_create_strings($this->data).";\n");
+  } 
+   
+  function execute()
+  {
+    $values = $this->data;
+
+    $smarty = get_smarty();
+    $smarty->assign("ID", $this->object_id);
+    $smarty->assign("Destinations" , $values);
+    $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
+    $object= $smarty->fetch(get_template_path("templates/element_redirect.tpl",TRUE,dirname(__FILE__)));
+    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
+    return($str);
+  }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/include/sieve/class_sieveElement_Reject.inc b/include/sieve/class_sieveElement_Reject.inc
new file mode 100644 (file)
index 0000000..0d54238
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+
+class sieve_reject 
+{
+  var $data = array();
+  var $object_id = -1;
+
+
+  function save_object()
+  {
+    if(isset($_POST['reject_message_'.$this->object_id])){
+      $msg = stripslashes($_POST['reject_message_'.$this->object_id]);
+
+      $this->data = $msg;
+    }
+  }
+
+  function sieve_reject($data,$object_id)
+  {
+    $this->object_id = $object_id;
+    $str = "";
+    foreach($data['ELEMENTS'] as $node ){
+      if(in_array($node['class'],array("quoted-string","text","multi-line"))){
+
+        if($node['class'] == "multi-line"){
+          $str .= preg_replace("/^text:[ \n\r]*/","",$node['text']);
+          $str =  preg_replace("/[  \n\r]*\.[  \n\r]*$/","",$str);
+        }else{
+          $str .= $node['text'];
+        }
+      }
+    }
+    $this->data = preg_replace("/\"/","",$str);
+  }
+
+  function get_sieve_script_part()
+  {
+    return("reject ".sieve_create_strings($this->data).";\n");
+  } 
+    
+  function execute()
+  {
+    /* check if this will be a 
+     *   - single string ""
+     *   - or a multi line text: ... ; 
+     */
+    $Multiline = preg_match("/\n/",$this->data);
+
+    $smarty = get_smarty();
+    $smarty->assign("ID", $this->object_id);
+    $smarty->assign("Message",$this->data);
+    $smarty->assign("Multiline",$Multiline);
+    $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
+    $object= $smarty->fetch(get_template_path("templates/element_reject.tpl",TRUE,dirname(__FILE__)));
+    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
+    return($str);
+  }
+}
+
+
diff --git a/include/sieve/class_sieveElement_Require.inc b/include/sieve/class_sieveElement_Require.inc
new file mode 100644 (file)
index 0000000..dffbf37
--- /dev/null
@@ -0,0 +1,75 @@
+<?php
+
+class sieve_require 
+{
+  var $data = array();
+  var $object_id = -1;
+  
+  function sieve_require($data,$object_id)
+  {
+    $this->object_id = $object_id;
+    foreach($data['ELEMENTS'] as $node ){
+      if(in_array($node['class'],array("quoted-string","text"))){
+        $this->data[] = preg_replace("/\"/","",$node['text']);
+      }
+    }
+  }
+
+  function save_object()
+  {
+    /* Get the values should check for, they are seperated by , */
+    if(isset($_POST['require_'.$this->object_id])){
+      $vls = stripslashes($_POST['require_'.$this->object_id]);
+      $tmp = array();
+
+      $tmp2 = split(",",$vls);
+      foreach($tmp2 as $val){
+        
+        $val = trim(preg_replace("/\"/","",$val));
+    
+        if(empty($val)) continue;        
+  
+        $tmp[] = "\"".$val."\"";
+      }
+      $this->data = $tmp;
+    }
+  }
+
+  function check()
+  {
+    $msgs = array();
+  
+    if(!count($this->data)){
+      $msgs[] = _("Please specify at least one valid requirement.");
+    }
+    return($msgs);
+  }
+
+  function get_sieve_script_part()
+  {
+    $tmp = sieve_create_strings($this->data);
+    return("require ".$tmp.";\n");
+  } 
+    
+  function execute()
+  {
+    $Require = "";
+    foreach($this->data as $key){
+      $Require .= $key.", ";
+    }
+    $Require = preg_replace("/,$/","",trim($Require));
+
+    $smarty = get_smarty();
+    $smarty->assign("Require",$Require);
+    $tmp = $this->check();
+    $smarty->assign("LastError",$tmp);
+    $smarty->assign("LastErrorCnt",count($tmp));
+    $smarty->assign("ID", $this->object_id);
+    $object_container = $smarty->fetch(get_template_path("templates/object_container_clear.tpl",TRUE,dirname(__FILE__)));
+    $object= $smarty->fetch(get_template_path("templates/element_require.tpl",TRUE,dirname(__FILE__)));
+    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
+    return($str);
+  }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/include/sieve/class_sieveElement_Stop.inc b/include/sieve/class_sieveElement_Stop.inc
new file mode 100644 (file)
index 0000000..915b8d9
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+/* This class handles the stop statement */
+class sieve_stop 
+{
+  var $object_id = -1;
+
+  function sieve_stop($data,$object_id)
+  {
+    $this->object_id = $object_id;
+  }
+
+  function save_object()
+  {
+  }
+
+  function check()
+  {
+    return(array());
+  }
+
+  function execute()
+  {
+    $smarty = get_smarty();
+    $smarty->assign("ID", $this->object_id);
+    $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
+    $object= $smarty->fetch(get_template_path("templates/element_stop.tpl",TRUE,dirname(__FILE__)));
+    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
+    return($str);
+  }
+
+  function get_sieve_script_part()
+  {
+    return("stop; \n");
+  } 
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/include/sieve/class_sieveElement_Vacation.inc b/include/sieve/class_sieveElement_Vacation.inc
new file mode 100644 (file)
index 0000000..182f023
--- /dev/null
@@ -0,0 +1,128 @@
+<?php
+
+class sieve_vacation 
+{
+  var $days     = FALSE;
+  var $subject  = FALSE;
+  var $from     = "";
+  var $mime     = "";
+  var $handle   = "";
+  var $reason   = "";
+  var $addresses= array();
+  var $object_id= -1;
+  var $Expert   = FALSE;
+
+  function sieve_vacation($data,$object_id)
+  {
+    /* Usage:   vacation [":days" number] [":subject" string]
+       [":from" string] [":addresses" string-list]
+       [":mime"] [":handle" string] <reason: string> */
+
+    /* Not all attribute types are supported by the sieve class right now */
+    $known_attrs = array(":days",":subject",":from",":mime",":handle");
+
+    /* Walk through elements */
+    for($i = 0 ; $i < count($data['ELEMENTS']) ; $i ++){
+
+      /* get current element */
+      $node = $data['ELEMENTS'][$i];
+
+      /* Check if tag is in the specified list of attributes */
+      if($node['class'] == "tag" && in_array($node['text'],$known_attrs)){
+
+        $var = preg_replace("/\:/","",$node['text']);
+        $this->$var = $data['ELEMENTS'][$i+1]['text'];
+        $i ++;
+      }
+
+      /* Check for addresses */
+      if($node['class'] == "tag" && $node['text'] == ":addresses") {
+        $this->addresses = array();
+        $i ++;
+
+        /* Multiple or single address given */
+        if($data['ELEMENTS'][$i]['class'] == "left-bracket"){
+          while($data['ELEMENTS'][$i]['class'] != "right-bracket" && ($i < count($data['ELEMENTS']))){
+            $i ++;
+            if($data['ELEMENTS'][$i]['class'] == "quoted-string"){
+              $this->addresses[] = preg_replace("/\"/i","",$data['ELEMENTS'][$i]['text']);
+            }
+          }
+        }else{
+              $this->addresses[] = $data['ELEMENTS'][$i]['text'] ;
+        }
+      }
+
+      /* Add the vacation message */
+      if($node['class'] == "quoted-string"){
+        $this->reason = $node['text'];
+      }
+    }
+  }
+
+  function get_sieve_script_part()
+  {
+    $str = "vacation ";
+    if($this->days){
+      $str.= ":days ".$this->days;
+    }
+    $str .= ":addresses ".sieve_create_strings($this->addresses);
+    if($this->subject){
+      $str.= ":subject ".sieve_create_strings($this->subject);
+    }
+    if($this->mime){
+      $str.= ":mime ".sieve_create_strings($this->mime);
+    }
+    $str .= "\n ".sieve_create_strings($this->reason);
+    return($str." ; \n");
+  }
+
+  function save_object()
+  {
+    /* Get release date */
+    if(isset($_POST['vacation_release_'.$this->object_id])){
+      $this->days = $_POST['vacation_release_'.$this->object_id];
+    }
+
+    /* Check if we want to toggle the expert mode */
+    if(isset($_POST['Toggle_Expert_'.$this->object_id])){
+      $this->Expert = !$this->Expert;
+    }
+
+    /* Get release date */
+    if(isset($_POST['vacation_receiver_'.$this->object_id])){
+      $vr = stripslashes ($_POST['vacation_receiver_'.$this->object_id]);
+      $tmp = array();
+      $tmp2 = split(",",$vr);
+      foreach($tmp2 as $val){
+        $tmp[] = "\"".trim(preg_replace("/\"/","",$val))."\"";
+      }
+      $this->addresses = $tmp;
+    }
+
+    /* Get reason */
+    if(isset($_POST['vacation_reason_'.$this->object_id])){
+      $vr = stripslashes ($_POST['vacation_reason_'.$this->object_id]);
+      $this->reason = "\"".trim(preg_replace("/\"/","",$vr))."\"";
+    }
+  }
+  function execute()
+  {
+    $Addresses = "";
+    foreach($this->addresses as $key){
+      $Addresses .= $key.", ";
+    }
+    $Addresses = preg_replace("/,$/","",trim($Addresses));
+    $smarty = get_smarty();
+    $smarty->assign("Reason",$this->reason);
+    $smarty->assign("Addresses",$Addresses);
+    $smarty->assign("Subject",$this->subject);
+    $smarty->assign("Days",$this->days);
+    $smarty->assign("ID",$this->object_id);
+    $smarty->assign("Expert",$this->Expert);
+    return($smarty->fetch(get_template_path("templates/element_vacation.tpl",TRUE,dirname(__FILE__))));
+  }
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/include/sieve/class_sieveElements.inc b/include/sieve/class_sieveElements.inc
deleted file mode 100644 (file)
index 3b84ebd..0000000
+++ /dev/null
@@ -1,562 +0,0 @@
-<?php
-
-/* Sieve else tag */
-class sieve_elsif extends sieve_if 
-{
-  var $TYPE = "elsif";
-}
-
-class sieve_else 
-{
-  var $object_id = -1;
-
-  function sieve_else($data,$object_id)
-  {
-    $this->object_id = $object_id;
-  }
-
-  function save_object()
-  {
-  }
-
-  function execute()
-  {
-    $smarty = get_smarty();
-    $smarty->assign("ID", $this->object_id);
-    $object_container = $smarty->fetch(get_template_path("templates/object_container_clear.tpl",TRUE,dirname(__FILE__)));
-    $object= $smarty->fetch(get_template_path("templates/element_else.tpl",TRUE,dirname(__FILE__)));
-    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
-    return($str);
-  }
-
-  function get_sieve_script_part()
-  {
-    return(" else ");
-  } 
-}
-
-
-/* Sieve comment tag */
-class sieve_comment 
-{
-  var $data = "";
-  var $object_id= -1;
-
-  function get_sieve_script_part()
-  {
-    return($this->data."\n");
-  } 
-    
-  function sieve_comment($data,$object_id)
-  {
-    $this->object_id = $object_id;
-    foreach($data['ELEMENTS'] as $node){
-       $this->data .= $node['text'];
-    }
-  }
-
-  function save_object()
-  {
-    if(isset($_POST['comment_'.$this->object_id])){
-      $cm = $_POST['comment_'.$this->object_id];
-      $this->data = "/*".$cm."*/";
-    }
-  }
-
-  function execute()
-  {
-    $smarty = get_smarty();
-    $smarty->assign("ID", $this->object_id);
-    $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
-    $Comment = $this->data;
-
-    /* Remove comment tags */
-    if(preg_match("/^#/",$Comment)){
-      $Comment = preg_replace("/^#/","",$Comment);
-    }elseif(preg_match("#\/\*#",$Comment)){
-      $Comment = preg_replace("#^\/\*#","",$Comment);
-      $Comment = preg_replace("#\*\/$#","",$Comment);
-    }
-    /* Create html object */ 
-    $smarty = get_smarty();
-    $smarty->assign("Comment",$Comment);
-    $smarty->assign("ID",$this->object_id);
-    $object = $smarty->fetch(get_template_path("templates/element_comment.tpl",TRUE,dirname(__FILE__)));    
-    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
-    return($str);
-  }
-}
-
-
-class sieve_require 
-{
-  var $data = array();
-  var $object_id = -1;
-  
-  function sieve_require($data,$object_id)
-  {
-    $this->object_id = $object_id;
-    foreach($data['ELEMENTS'] as $node ){
-      if(in_array($node['class'],array("quoted-string","text"))){
-        $this->data[] = preg_replace("/\"/","",$node['text']);
-      }
-    }
-  }
-
-  function save_object()
-  {
-    /* Get the values should check for, they are seperated by , */
-    if(isset($_POST['require_'.$this->object_id])){
-      $vls = stripslashes($_POST['require_'.$this->object_id]);
-      $tmp = array();
-
-      $tmp2 = split(",",$vls);
-      foreach($tmp2 as $val){
-        $tmp[] = "\"".trim(preg_replace("/\"/","",$val))."\"";
-      }
-      $this->data = $tmp;
-    }
-  }
-
-  function get_sieve_script_part()
-  {
-    $tmp = sieve_create_strings($this->data);
-    return("require ".$tmp.";\n");
-  } 
-    
-  function execute()
-  {
-    $Require = "";
-    foreach($this->data as $key){
-      $Require .= $key.", ";
-    }
-    $Require = preg_replace("/,$/","",trim($Require));
-
-    $smarty = get_smarty();
-    $smarty->assign("Require",$Require);
-    $smarty->assign("ID", $this->object_id);
-    $object_container = $smarty->fetch(get_template_path("templates/object_container_clear.tpl",TRUE,dirname(__FILE__)));
-    $object= $smarty->fetch(get_template_path("templates/element_require.tpl",TRUE,dirname(__FILE__)));
-    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
-    return($str);
-  }
-}
-
-class sieve_discard 
-{
-  var $data = array();
-  var $object_id = -1;
-
-  function sieve_discard($data,$object_id)
-  {
-    $this->object_id = $object_id;
-  }
-
-  function get_sieve_script_part()
-  {
-    return("discard;\n");
-  } 
-    
-  function save_object()
-  {
-  
-  }
-
-  function execute()
-  {
-    $smarty = get_smarty();
-    $smarty->assign("ID", $this->object_id);
-    $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
-    $object = $smarty->fetch(get_template_path("templates/element_discard.tpl",TRUE,dirname(__FILE__)));
-    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
-    return($str);
-  }
-}
-
-
-
-class sieve_reject 
-{
-  var $data = array();
-  var $object_id = -1;
-
-
-  function save_object()
-  {
-    if(isset($_POST['reject_message_'.$this->object_id])){
-      $msg = stripslashes($_POST['reject_message_'.$this->object_id]);
-
-      $this->data = $msg;
-    }
-  }
-
-  function sieve_reject($data,$object_id)
-  {
-    $this->object_id = $object_id;
-    $str = "";
-    foreach($data['ELEMENTS'] as $node ){
-      if(in_array($node['class'],array("quoted-string","text","multi-line"))){
-
-        if($node['class'] == "multi-line"){
-          $str .= preg_replace("/^text:[ \n\r]*/","",$node['text']);
-          $str =  preg_replace("/[  \n\r]*\.[  \n\r]*$/","",$str);
-        }else{
-          $str .= $node['text'];
-        }
-      }
-    }
-    $this->data = preg_replace("/\"/","",$str);
-  }
-
-  function get_sieve_script_part()
-  {
-    return("reject ".sieve_create_strings($this->data).";\n");
-  } 
-    
-  function execute()
-  {
-    /* check if this will be a 
-     *   - single string ""
-     *   - or a multi line text: ... ; 
-     */
-    $Multiline = preg_match("/\n/",$this->data);
-
-    $smarty = get_smarty();
-    $smarty->assign("ID", $this->object_id);
-    $smarty->assign("Message",$this->data);
-    $smarty->assign("Multiline",$Multiline);
-    $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
-    $object= $smarty->fetch(get_template_path("templates/element_reject.tpl",TRUE,dirname(__FILE__)));
-    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
-    return($str);
-  }
-}
-
-class sieve_redirect 
-{
-  var $data = array();
-  var $object_id = -1;
-
-  function save_object()
-  {
-    if(isset($_POST['redirect_to_'.$this->object_id])){
-      $rt = stripslashes($_POST['redirect_to_'.$this->object_id]);
-
-      $rt = "\"".trim(preg_replace("/\"/","",$rt))."\"";
-      $this->data = $rt;
-    }
-  }
-
-
-  function sieve_redirect($data,$object_id)
-  {
-    foreach($data['ELEMENTS'] as $node ){
-      if(in_array($node['class'],array("quoted-string","text"))){
-        $this->data = $node['text'];
-      }
-    }
-  }
-
-
-  function get_sieve_script_part()
-  {
-    return("redirect ".sieve_create_strings($this->data).";\n");
-  } 
-   
-  function execute()
-  {
-    $values = $this->data;
-
-    $smarty = get_smarty();
-    $smarty->assign("ID", $this->object_id);
-    $smarty->assign("Destinations" , $values);
-    $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
-    $object= $smarty->fetch(get_template_path("templates/element_redirect.tpl",TRUE,dirname(__FILE__)));
-    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
-    return($str);
-  }
-}
-
-class sieve_fileinto 
-{
-  var $data     = array();
-  var $object_id= -1;
-  var $options  = array();
-
-  function save_object()
-  {
-    $mbs = $this->get_mail_boxes();
-    
-    if(isset($_POST['fileinto_'.$this->object_id])){
-      $mb = $_POST['fileinto_'.$this->object_id];
-
-      if(isset($mbs[$mb])) {
-        $this->data[0] = $mb; 
-      }
-    }
-  }
-
-  function sieve_fileinto($data,$object_id)
-  {
-    $this->object_id = $object_id;
-    foreach($data['ELEMENTS'] as $node ){
-      if(in_array($node['class'],array("quoted-string","text"))){
-        $this->data[] = preg_replace("/\"/","",$node['text']);
-      }
-    }
-  }
-
-  function get_sieve_script_part()
-  {
-    $tmp = "";
-    foreach($this->data as $dat){
-      $tmp.= "\"".$dat."\", ";
-    }
-    $tmp = preg_replace("/,$/","",trim($tmp));
-    $tmp = preg_replace ("/\"\"/","\"",$tmp);
-    return("fileinto ".$tmp.";\n");
-  } 
-    
-  function execute()
-  {
-    $smarty = get_smarty();
-    $smarty->assign("Selected",$this->data[0]);
-    $smarty->assign("Boxes", $this->get_mail_boxes());
-    $smarty->assign("ID", $this->object_id);
-    $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
-    $object= $smarty->fetch(get_template_path("templates/element_fileinto.tpl",TRUE,dirname(__FILE__)));
-    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
-    return($str);
-  }
-
-  function get_mail_boxes()
-  {
-    return(array("not"=>"not","impplemented/yet"=>"impplemented/yet"));
-  }
-}
-
-class sieve_vacation 
-{
-  var $days     = FALSE;
-  var $subject  = FALSE;
-  var $from     = "";
-  var $mime     = "";
-  var $handle   = "";
-  var $reason   = "";
-  var $addresses= array();
-  var $object_id= -1;
-  var $Expert   = FALSE;
-
-  function sieve_vacation($data,$object_id)
-  {
-    /* Usage:   vacation [":days" number] [":subject" string]
-       [":from" string] [":addresses" string-list]
-       [":mime"] [":handle" string] <reason: string> */
-
-    /* Not all attribute types are supported by the sieve class right now */
-    $known_attrs = array(":days",":subject",":from",":mime",":handle");
-
-    /* Walk through elements */
-    for($i = 0 ; $i < count($data['ELEMENTS']) ; $i ++){
-
-      /* get current element */
-      $node = $data['ELEMENTS'][$i];
-
-      /* Check if tag is in the specified list of attributes */
-      if($node['class'] == "tag" && in_array($node['text'],$known_attrs)){
-
-        $var = preg_replace("/\:/","",$node['text']);
-        $this->$var = $data['ELEMENTS'][$i+1]['text'];
-        $i ++;
-      }
-
-      /* Check for addresses */
-      if($node['class'] == "tag" && $node['text'] == ":addresses") {
-        $this->addresses = array();
-        $i ++;
-
-        /* Multiple or single address given */
-        if($data['ELEMENTS'][$i]['class'] == "left-bracket"){
-          while($data['ELEMENTS'][$i]['class'] != "right-bracket" && ($i < count($data['ELEMENTS']))){
-            $i ++;
-            if($data['ELEMENTS'][$i]['class'] == "quoted-string"){
-              $this->addresses[] = preg_replace("/\"/i","",$data['ELEMENTS'][$i]['text']);
-            }
-          }
-        }else{
-          $this->addresses[] = $data['ELEMENTS'][$i]['text'] ;
-        }
-      }
-
-      /* Add the vacation message */
-      if($node['class'] == "quoted-string"){
-        $this->reason = $node['text'];
-      }
-    }
-  }
-
-  function get_sieve_script_part()
-  {
-    $str = "vacation ";
-    if($this->days){
-      $str.= ":days ".$this->days;
-    }
-    $str .= ":addresses ".sieve_create_strings($this->addresses);
-    if($this->subject){
-      $str.= ":subject ".sieve_create_strings($this->subject);
-    }
-    if($this->mime){
-      $str.= ":mime ".sieve_create_strings($this->mime);
-    }
-    $str .= "\n ".sieve_create_strings($this->reason);
-    return($str." ; \n");
-  } 
-    
-  
-  function save_object()
-  {
-    /* Get release date */
-    if(isset($_POST['vacation_release_'.$this->object_id])){
-      $this->days = $_POST['vacation_release_'.$this->object_id];
-    }
-
-    /* Check if we want to toggle the expert mode */
-    if(isset($_POST['Toggle_Expert_'.$this->object_id])){
-      $this->Expert = !$this->Expert;
-    }
-
-    /* Get release date */
-    if(isset($_POST['vacation_receiver_'.$this->object_id])){
-      $vr = stripslashes ($_POST['vacation_receiver_'.$this->object_id]);
-      $tmp = array();
-      $tmp2 = split(",",$vr);
-      foreach($tmp2 as $val){
-        $tmp[] = "\"".trim(preg_replace("/\"/","",$val))."\"";
-      }
-      $this->addresses = $tmp;      
-    }
-
-    /* Get reason */
-    if(isset($_POST['vacation_reason_'.$this->object_id])){
-      $vr = stripslashes ($_POST['vacation_reason_'.$this->object_id]);
-      $this->reason = "\"".trim(preg_replace("/\"/","",$vr))."\"";
-    }
-  }
-
-  function execute()
-  {
-    $Addresses = "";
-    foreach($this->addresses as $key){
-      $Addresses .= $key.", ";
-    }
-    $Addresses = preg_replace("/,$/","",trim($Addresses));
-    $smarty = get_smarty();
-    $smarty->assign("Reason",$this->reason);
-    $smarty->assign("Addresses",$Addresses);
-    $smarty->assign("Subject",$this->subject);
-    $smarty->assign("Days",$this->days);
-    $smarty->assign("ID",$this->object_id);
-    $smarty->assign("Expert",$this->Expert);
-    return($smarty->fetch(get_template_path("templates/element_vacation.tpl",TRUE,dirname(__FILE__))));
-  }
-}
-
-class sieve_block_start 
-{
-  function execute()
-  {
-    $smarty = get_smarty();
-    return($smarty->fetch(get_template_path("templates/element_block_start.tpl",TRUE,dirname(__FILE__))));
-  }
-
-  function save_object()
-  {
-  }
-
-  function get_sieve_script_part()
-  {
-    return("{\n");
-  } 
-}
-
-class sieve_block_end 
-{
-  function execute()
-  {
-    $smarty = get_smarty();
-    return($smarty->fetch(get_template_path("templates/element_block_end.tpl",TRUE,dirname(__FILE__))));
-  }
-  function get_sieve_script_part()
-  {
-    return("}\n");
-  } 
-  function save_object()
-  {
-  }
-
-}
-
-/* This class handles the keep statement */
-class sieve_keep 
-{
-  var $object_id = -1;
-
-  function sieve_keep($data,$object_id)
-  {
-    $this->object_id = $object_id;
-  }
-
-  function save_object()
-  {
-  }
-
-  function execute()
-  {
-    $smarty = get_smarty();
-    $smarty->assign("ID", $this->object_id);
-    $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
-    $object = $smarty->fetch(get_template_path("templates/element_keep.tpl",TRUE,dirname(__FILE__)));
-    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
-    return($str);
-  }
-  function get_sieve_script_part()
-  {
-    return("keep;\n");
-  } 
-    
-}
-
-/* This class handles the stop statement */
-class sieve_stop 
-{
-  var $object_id = -1;
-
-  function sieve_stop($data,$object_id)
-  {
-    $this->object_id = $object_id;
-  }
-
-  function save_object()
-  {
-  }
-
-  function execute()
-  {
-    $smarty = get_smarty();
-    $smarty->assign("ID", $this->object_id);
-    $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
-    $object= $smarty->fetch(get_template_path("templates/element_stop.tpl",TRUE,dirname(__FILE__)));
-    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
-    return($str);
-  }
-
-  function get_sieve_script_part()
-  {
-    return("stop; \n");
-  } 
-    
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
index da36074a0e57c9a711ca25d8d360560eafe0f3fd..fdce9e31c5527ca9968589a4186534e525ef9d10 100644 (file)
@@ -204,9 +204,15 @@ class sieveManagement extends plugin
 
     /* Save currently edited sieve script. */
     if(isset($_POST['save_sieve_changes'])){
-      $this->scripts[$this->current_script]['PARSER'] = $this->current_handler;
-      $this->scripts[$this->current_script]['EDITED'] = TRUE;
-      $this->current_handler = NULL; 
+      $chk = $this->current_handler->check();
+      if(!count($chk)){
+        $this->scripts[$this->current_script]['PARSER'] = $this->current_handler;
+        $this->scripts[$this->current_script]['EDITED'] = TRUE;
+        $this->current_handler = NULL; 
+      }else{
+        print_a($chk);
+        print_red(_("Please fix all errors before saving."));
+      }
     }
 
     /* Create output for currently opened sieve script */
index 80e4384abdc86d43a8ec74c2c831424345146365..853e161905eae7310ea3df25da434d73518d3ad3 100755 (executable)
@@ -1,6 +1,24 @@
 
+{if $LastError != ""}
+       <table style='width:100%;'> 
+               <tr>
+                       <td style='width:40px; background-color: #FF0000; text-align:center; border: dotted 3px #ff7c1c'>
+                               <img src='images/warning.png' alt='{t}Error{/t}'>
+                       </td>
+                       <td>
+{/if}
+
 <table cellspacing=0 cellpadding=2 style='background-color:#EEEEDD;width:100%; border: solid 1px #CCCCCC'>
        {if $Expert}
+       {if $LastError != ""}
+               <tr>
+                               <td colspan=4>
+                           <font color='red'><b>{$LastError}</b></font>
+                               </td>
+                       </tr>
+
+        {/if}
+
        <tr>
                <td>
                        {t}Match type{/t}
                </td>
        </tr>
        {else}
+       {if $LastError != ""}
+               <tr>
+                               <td colspan=4>
+                           <font color='red'><b>{$LastError}</b></font>
+                               </td>
+                       </tr>
+
+        {/if}
        <tr>
                <td style='vertical-align:top;'>
                        {t}If{/t}
        </tr>
        {/if}
 </table>
+{if $LastError != ""}
+
+                       </td>
+               </tr>
+       </table>
+{/if}
index c99cfdd3c8cac0f293205cb8d68f21de6d01845e..6bc8e235161fb79d313e80db3071acb0200d3482 100755 (executable)
@@ -1,6 +1,26 @@
 
+
+{if $LastError != ""}
+       <table style='width:100%;'> 
+               <tr>
+                       <td style='width:40px; background-color: #FF0000; text-align:center; border: dotted 3px #ff7c1c'>
+                               <img src='images/warning.png' alt='{t}Error{/t}'>
+                       </td>
+                       <td>
+{/if}
+
 <table cellspacing=0 cellpadding=2 style='background-color:#EEEEDD;width:100%; border: solid 1px #CCCCCC'>
        {if $Expert}
+       {if $Expert}
+       {if $LastError != ""}
+               <tr>
+                               <td colspan=4>
+                           <font color='red'><b>{$LastError}</b></font>
+                               </td>
+                       </tr>
+
+        {/if}
+
        <tr>
                <td>
                        {t}Match type{/t}
                </td>
        </tr>
        {else}
+       {if $LastError != ""}
+               <tr>
+                               <td colspan=4>
+                           <font color='red'><b>{$LastError}</b></font>
+                               </td>
+                       </tr>
+
+        {/if}
        <tr>
                <td style='vertical-align:top;'>
                        {t}If{/t}
        </tr>
        {/if}
 </table>
+{if $LastError != ""}
+
+                       </td>
+               </tr>
+       </table>
+{/if}
index 7483454182c3e4c8f03def11cc9c572144b978ff..a96a78229c72f71b71226482ec07d029b0f88add 100755 (executable)
@@ -1,5 +1,24 @@
+
+{if $LastError != ""}
+       <table style='width:100%;'> 
+               <tr>
+                       <td style='width:40px; background-color: #FF0000; text-align:center; border: dotted 3px #ff7c1c'>
+                               <img src='images/warning.png' alt='{t}Error{/t}'>
+                       </td>
+                       <td>
+{/if}
+
 <table cellspacing=0 cellpadding=2 style='background-color:#EEEEDD;width:100%; border: solid 1px #CCCCCC'>
        {if $Expert}
+       {if $LastError != ""}
+               <tr>
+                               <td colspan=4>
+                           <font color='red'><b>{$LastError}</b></font>
+                               </td>
+                       </tr>
+
+        {/if}
+
 
         <tr>
         <td>
     </tr>
 
        {else}
+       {if $LastError != ""}
+               <tr>
+                               <td colspan=4>
+                           <font color='red'><b>{$LastError}</b></font>
+                               </td>
+                       </tr>
+
+        {/if}
                 <tr>
         <td style='vertical-align:top;'>
             {t}If{/t}
 
        {/if}
 </table>
+{if $LastError != ""}
+
+                       </td>
+               </tr>
+       </table>
+{/if}
index 0cac45fe63af0a707f97b6509fd2092ca294a2dc..bf624d913900026ca735eceb8d867298100208f0 100644 (file)
@@ -1,8 +1,22 @@
+{if $LastError != ""}
+       <table style='width:100%;'> 
+               <tr>
+                       <td style='width:40px; background-color: #FF0000; text-align:center; border: dotted 3px #ff7c1c'>
+                               <img src='images/warning.png' alt='{t}Error{/t}'>
+                       </td>
+                       <td>
+{/if}
+
 <table cellspacing=0 width='100%' style='background-color: #d1ffcc'>
        <tr>
                <td>
                        <b>{t}Redirect{/t}</b>
                        {t}Redirect mail to following recipients{/t}
+                       &nbsp;
+                       {if $LastError != ""}   
+                               <br>
+                               <font color='red'><b>{$LastError}</b></font>
+                       {/if}                   
                </td>
        </tr>
        <tr>
                </td>
        </tr>
 </table>
+
+{if $LastError != ""}
+
+                       </td>
+               </tr>
+       </table>
+{/if}
index 761e636b046922dbc2d0a222f9461e9f78197ab5..b4d74ff4de8510aabe19ce5054b3bd052523b1b5 100644 (file)
@@ -1,4 +1,22 @@
+{if $LastErrorCnt != 0}
+    <table style='width:100%;'>
+        <tr>
+            <td style='width:40px; background-color: #FF0000; text-align:center; border: dotted 3px #ff7c1c'>
+                <img src='images/warning.png' alt='{t}Error{/t}'>
+            </td>
+            <td>
+{/if}
+
 <table cellspacing=0 style='width:100%;background-color:#e4ffc9;'>
+       
+       {foreach from=$LastError item=val key=key}
+               <tr>
+                       <td colspan=4>
+                               <font color='red'><b>{$LastError[$key]}</b></font>
+                       </td>
+               </tr>
+
+       {/foreach}
        <tr>
                <td style=''>
                        <b>{t}Require{/t}</b>
                </td>
        </tr>
 </table>
+
+{if $LastErrorCnt != 0}
+
+            </td>
+        </tr>
+    </table>
+{/if}
+