Code

Added DNS and DHCP enable disable options into setup step 2
[gosa.git] / include / sieve / class_sieveElement_Require.inc
index ee7f12a2d66f59d2ae050a0b814f5c48f0d9ecca..9ef9e2985849b2d1e92bcba2759a707bca0ceeaa 100644 (file)
@@ -5,6 +5,7 @@ class sieve_require
   var $data = array();
   var $object_id = -1;
   var $parent = NULL;  
+  var $skip_save_object =FALSE;
 
   function sieve_require($data,$object_id,$parent)
   {
@@ -12,32 +13,40 @@ class sieve_require
     $this->object_id = $object_id;
     if($data != NULL){
 
-      foreach($data['ELEMENTS'] as $node ){
-        if(in_array($node['class'],array("quoted-string","text"))){
-          $this->data[] = preg_replace("/\"/","",$node['text']);
+      for($i = 0 ; $i < count($data['ELEMENTS']) ; $i++){
+        $tmp = sieve_get_strings($data['ELEMENTS'],$i);
+        $i  = $i + $tmp['OFFSET'];
+        foreach($tmp['STRINGS'] as $str){
+          $this->data[]= $str;
         }
       }
     }
   }
 
+
   /* Add a new require statement and ensure 
    *  that it is not specified twice 
    */
   function Add_Require($str)
   {
     $current = array();
-
     foreach($this->data as $dat){
-      $current[] = preg_replace("/\"/","",$dat);
+      $current[] = $dat;
     }
     if(!in_array($str,$current)){
       $this->data[] = $str;
     }
-    $this->data = array_unique($this->data);;
+    $this->data = array_unique($this->data);
+    $this->skip_save_object = TRUE;
   }
 
   function save_object()
   {
+    if($this->skip_save_object){
+      $this->skip_save_object = FALSE;
+      return;
+    }
+
     /* Get the values should check for, they are seperated by , */
     if(isset($_POST['require_'.$this->object_id])){
       $vls = stripslashes($_POST['require_'.$this->object_id]);
@@ -46,7 +55,7 @@ class sieve_require
       $tmp2 = split(",",$vls);
       foreach($tmp2 as $val){
         
-        $val = trim(preg_replace("/\"/","",$val));
+        $val = trim($val);
     
         if(empty($val)) continue;        
   
@@ -80,7 +89,7 @@ class sieve_require
   {
     $Require = "";
     foreach($this->data as $key){
-      $Require .= "\"".$key."\"".", ";
+      $Require .= $key.", ";
     }
     $Require = preg_replace("/,$/","",trim($Require));
 
@@ -92,7 +101,7 @@ class sieve_require
     $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_require.tpl",TRUE,dirname(__FILE__)));
-    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
+    $str = preg_replace("/%%OBJECT_CONTENT%%/",addcslashes($object,"\\"),$object_container);
     return($str);
   }
 }