Code

Updated error msgs in semantic class
[gosa.git] / include / sieve / class_sieveElement_If.inc
index 26bf54c42159e61c218cea3c1fde27a047ab867a..05f4895141ed53d8f739a4e24f7e1888d3b6964b 100644 (file)
@@ -11,14 +11,16 @@ class sieve_if
   var $comparators      = array();
   var $match_types      = array();
   var $operators        = array();
-
+  var $parent           = NULL;
   
   /* Initialize class 
    *  $elements   contains all tokens that belongs to this if/else tag
    *  $object_id  cotains an unique tag id, to be able to create uniqe html post names
    */
-  function sieve_if($elements,$object_id)
+  function sieve_if($elements,$object_id,$parent)
   {
+    $this->parent = $parent;
+  
     /* Possible address parts we can select */
     $this->address_parts = array( 
         ":all"       => _("Complete adress")." ("._("Default").")",
@@ -112,7 +114,7 @@ class sieve_if
          *******************/
 
         case "true" :
-        case "fasle" : 
+        case "false" : 
         {
           /* Can't fail anyway */
           break;
@@ -379,7 +381,10 @@ class sieve_if
           }          
 
           /* Add allof/anyof tag */
-          $script.= " ".$key." ( ";
+          if($Inverse){
+            $script .= "not ";
+          }
+          $script.= $key." ( ";
 
           /* Add each test parameter */
           foreach($data as $key2 => $dat){
@@ -426,6 +431,13 @@ class sieve_if
           $values["Address_Part"]    = ":all";
         }
         $data[$type]=$values;
+
+        $this->parent->add_require("relational");
+        if($type == "envelope"){
+          $this->parent->add_require("envelope");
+        }
+    
+
         break;
       }
       case "allof" :
@@ -438,8 +450,8 @@ class sieve_if
       {
         $tmp= array( 
             "Inverse"    => FALSE,
-            "Match_type" => ":contains",
-            "Value_List" => array(1,"M"));
+            "Match_type" => ":over",
+            "Value_List" => array("1M"));
 
         $tmp['LastError'] = "";
         $data[$type] = $tmp;
@@ -583,6 +595,10 @@ class sieve_if
               $parsed[$key]['LastError'] = _("Invalid operator given.");
             }
             $parsed[$key]['Comparator'] = $cp;
+
+            if($cp == "i;ascii-numeric"){
+              $this->parent->add_require("comparator-i;ascii-numeric");
+            }
           }
 
           /* In case of :count and :value match types 
@@ -680,6 +696,11 @@ class sieve_if
           $Units       = array( "M" => _("Megabyte") ,
                                 "K" => _("Kilobyte"));
 
+          /* Toggle Inverse ? */
+          if(isset($_POST['toggle_inverse_'.$element_id])){
+            $parsed[$key]['Inverse'] = !$parsed[$key]['Inverse'];
+          }
+
           /* Reset error */
           $parsed[$key]['LastError'] ="";
 
@@ -797,7 +818,12 @@ 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__)));
+
+    if($this->TYPE == "if"){
+      $object = $smarty->fetch(get_template_path("templates/element_if.tpl",TRUE,dirname(__FILE__)));
+    }else{
+      $object = $smarty->fetch(get_template_path("templates/element_elsif.tpl",TRUE,dirname(__FILE__)));
+    }
     $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
     return($str);
   }
@@ -1072,7 +1098,7 @@ class sieve_if
           $smarty->assign("DisplayAdd",TRUE);
           $smarty->assign("DisplayDel",FALSE);
           $cont_tmp = $smarty->fetch(get_template_path("templates/object_test_container.tpl",TRUE,dirname(__FILE__)));
-          $cont_tmp = preg_replace("/%%OBJECT_CONTENT%%/",_("Klick here to add a new test"),$cont_tmp);
+          $cont_tmp = preg_replace("/%%OBJECT_CONTENT%%/",_("Click here to add a new test"),$cont_tmp);
 
           $smarty->assign("Inverse",$Inverse);
           $smarty->assign("Contents",$cont_tmp.$Contents);
@@ -1114,13 +1140,7 @@ class sieve_if
         } 
         default : 
         {
-          $ret = "<table width='100%'  cellspacing=0 cellpadding=0>
-                    <tr>
-                      <td style='background-color: #FEDCA9 ; border: solid 1px        #EEEEEE'>";
-          $ret.= $key."<br>"; 
-          $ret.= "    </td>
-                    </tr>
-                  </table>";
+          trigger_error(_("Unhandled switch type"));
         }
       }
     }