Code

Added simple direct add of sieve elements.
[gosa.git] / include / sieve / class_sieveElement_If.inc
index c4808ce523d686c33d1b1fd80c2dfd1195b1622d..daf4f5bf0d408dc64e83b5f2f5e5cbbdbe3d654c 100644 (file)
@@ -98,6 +98,10 @@ class sieve_if
       $parsed = $this->_parsed;
     }
 
+    if($parsed == NULL) {
+        return(array(_("Can't save empty tests.")));
+    }
+
     /* Walk through all elements */
     foreach($parsed as $key => $data){
 
@@ -525,7 +529,9 @@ class sieve_if
       $parsed = $this->_parsed;
     }
 
-    if(!is_array($parsed)) return;
+    if(!is_array($parsed)) {
+      return;
+    }
 
     /* Walk through all elements */
     foreach($parsed as $key => $data){
@@ -642,7 +648,11 @@ class sieve_if
 
             $tmp2 = split(",",$vls);
             foreach($tmp2 as $val){
-              $tmp[] = "\"".trim(preg_replace("/\"/","",$val))."\"";
+              $tmp[] = trim($val);
+  
+              if(preg_match("/\"/",$val)){
+                $parsed[$key]['LastError'] = _("Invalid character found in address attribute. Quotes are not allowed here.");
+              }
             }
             $parsed[$key]['Key_List'] = $tmp;
           }
@@ -654,7 +664,10 @@ class sieve_if
 
             $tmp2 = split(",",$vls);
             foreach($tmp2 as $val){
-              $tmp[] = "\"".trim(preg_replace("/\"/","",$val))."\"";
+              $tmp[] = trim($val);
+              if(preg_match("/\"/",$val)){
+                $parsed[$key]['LastError'] = _("Invalid character found in value attribute. Quotes are not allowed here.");
+              }
             }
             $parsed[$key]['Value_List'] = $tmp;
           }
@@ -830,12 +843,8 @@ class sieve_if
     $smarty = get_smarty();
     $smarty->assign("ID", $this->object_id);
 
-    /* Only display navigation elements if necessary */
-    if($this->TYPE == "if"){
-      $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
-    }else{
-      $object_container = $smarty->fetch(get_template_path("templates/object_container_clear.tpl",TRUE,dirname(__FILE__)));
-    }
+    /* Get navigation element container */
+    $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
 
     $smarty->assign("Name", $name);
     $smarty->assign("Contents", $this->get_as_html());
@@ -1122,7 +1131,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%%/",_("Click here to add a new test"),$cont_tmp);
+          $cont_tmp = preg_replace("/%%OBJECT_CONTENT%%/","<b>"._("Click here to add a new test")."</b>",$cont_tmp);
 
           $smarty->assign("Inverse",$Inverse);
           $smarty->assign("Contents",$cont_tmp.$Contents);