Code

Updated String handling in My_Tree class. To avoid losing quotes an every editing...
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 29 Mar 2007 08:23:05 +0000 (08:23 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 29 Mar 2007 08:23:05 +0000 (08:23 +0000)
Updated Vacation to save the reason attribute as > text: ... <

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5920 594d385d-05f5-0310-b6e9-bd551577e9d8

include/sieve/class_My_Tree.inc
include/sieve/class_sieveElement_Vacation.inc

index ee1276a36ac3c1aba3c85281c0f2aa6b0bd2696b..cc9600b6b4ecc9b247fa381aeb5ed888c8bc3d53 100644 (file)
@@ -731,9 +731,9 @@ function sieve_create_strings($data,$force_string = FALSE)
       $ret = "text: \r\n".$data."\r\n.\r\n";
     }else{
       $ret = "\"".$data."\"";
+      $ret = preg_replace("/\"\"/","\"",$ret);
     }
   }
-  $ret = preg_replace("/\"\"/","\"",$ret);
   $ret = preg_replace("/\n/","\r\n",$ret);
 
   return($ret);
@@ -759,7 +759,10 @@ function sieve_get_strings($data,$id)
       $id ++;
     }
   }elseif($data[$id]['class'] == "quoted-string"){
-    $ret[] = $data[$id]['text'];
+    $text = $data[$id]['text']; 
+    $text= preg_replace("/^\"/","",$text);
+    $text= preg_replace("/\"$/","",$text);
+    $ret[] = $text;
   }elseif($data[$id]['class'] == "number"){
     $ret[] = $data[$id]['text'];
   }elseif($data[$id]['class'] == "multi-line"){
index 9bb4a41b4ef1c8a8fad1ccb26fcfecb6a1bf64b9..477a7fe0ce2520c89d323f33c13e99101e80abae 100644 (file)
@@ -71,7 +71,7 @@ class sieve_vacation
         foreach($strs as $str){
           $data .= $str;
         }
-        $this->reason = $data;//preg_replace("/\"/","",$data);
+        $this->reason = $data;
       }
     }
   }
@@ -92,7 +92,12 @@ class sieve_vacation
     if($this->mime){
       $str.= ":mime ".sieve_create_strings($this->mime);
     }
-    $str .= "\n ".sieve_create_strings($this->reason);
+  
+    /* Append reason and ensure that this will be 
+     *  handled as multiline text element 
+     *  by adding a "\n" new line 
+     */
+    $str .= "\n ".sieve_create_strings($this->reason."\n");
     return($str." ; \n");
   }
 
@@ -116,7 +121,7 @@ class sieve_vacation
       foreach($tmp2 as $val){
         $ad = trim(preg_replace("/\"/","",$val));
         if(!empty($ad)){
-          $tmp[] = "\"".$ad."\"";
+          $tmp[] = $ad;
         }
       }
       $this->addresses = $tmp;
@@ -125,7 +130,7 @@ class sieve_vacation
     /* Get reason */
     if(isset($_POST['vacation_reason_'.$this->object_id])){
       $vr = stripslashes ($_POST['vacation_reason_'.$this->object_id]);
-      $this->reason = "\"".trim(preg_replace("/\"/","",$vr))."\"";
+      $this->reason = trim($vr);
     }
   }
 
@@ -134,7 +139,7 @@ class sieve_vacation
     $msgs = array();
     $err = FALSE;
     foreach($this->addresses as $addr){
-      if(!is_email(preg_replace("/\"/","",$addr))){
+      if(!is_email($addr)){
         $err = true;
       }
     }