Code

Fixed several sieveElement and their initialization
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 29 Mar 2007 09:04:47 +0000 (09:04 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 29 Mar 2007 09:04:47 +0000 (09:04 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5922 594d385d-05f5-0310-b6e9-bd551577e9d8

include/sieve/class_My_Tree.inc
include/sieve/class_sieveElement_Fileinto.inc
include/sieve/class_sieveElement_Redirect.inc
include/sieve/class_sieveElement_Reject.inc
include/sieve/class_sieveElement_Require.inc

index cc9600b6b4ecc9b247fa381aeb5ed888c8bc3d53..32bf58a038a7057fc63566053ea443dbea0f1337 100644 (file)
@@ -722,6 +722,7 @@ function sieve_create_strings($data,$force_string = FALSE)
       $ret = preg_replace("/,$/","",trim($ret));
       $ret = "[".$ret."]";
     }
+      $ret = preg_replace("/\"\"/","\"",$ret);
   }else{
 
     $Multiline = preg_match("/\n/",$data);
@@ -753,7 +754,10 @@ function sieve_get_strings($data,$id)
     while(isset($data[$id]) && $data[$id]['class']  != "right-bracket" && $id < count($data)){
 
       if($data[$id]['class'] == "quoted-string"){
-        $ret[] = $data[$id]['text'];
+        $text = $data[$id]['text']; 
+        $text= preg_replace("/^\"/","",$text);
+        $text= preg_replace("/\"$/","",$text);
+        $ret[] = $text;
       }
 
       $id ++;
index 6ac66371ca6fca283c5b7971a0a38611744dcbb1..f357d37d96d961bd4e1ea2065d8468deb9f985b8 100644 (file)
@@ -49,14 +49,11 @@ class sieve_fileinto
     /* Load element contents, should normaly be only one string 
      *  but if we found more than one, just append the following strings.
      */
-    foreach($data['ELEMENTS'] as $key => $node ){
-      if(in_array($node['class'],array("quoted-string","text"))){
-        $tmp = sieve_get_strings($data['ELEMENTS'],$key);
-        if(count($tmp['STRINGS'])){
-          foreach($tmp['STRINGS'] as $str){
-            $this->data.= $str;
-          }
-        }
+    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;
       }
     }
 
index 4f19c67e87c7dbd1473a177e5ed6fe16e704a5df..56f55cf77bc5dad7be80b318927b6ea02955ef1d 100644 (file)
@@ -35,15 +35,11 @@ class sieve_redirect
       $data = array('ELEMENTS' => array(array('class' => "quoted-string" ,"text" => _("Put a mail address here"))));
     }
 
-    foreach($data['ELEMENTS'] as $key => $node ){
-      if(in_array($node['class'],array("quoted-string","text"))){
-        $tmp = sieve_get_strings($data['ELEMENTS'],$key);
-        if(count($tmp['STRINGS'])){
-
-          foreach($tmp['STRINGS'] as $str){
-            $this->data.= $str;
-          }
-        }
+    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;
       }
     }
   }
index 0447c254a40d9d039a9b0b6c2bdfef320ae41604..398f6ed3644c511f295ca5096c8e4f42e6853ece 100644 (file)
@@ -10,7 +10,6 @@ class sieve_reject
   {
     if(isset($_POST['reject_message_'.$this->object_id])){
       $msg = stripslashes($_POST['reject_message_'.$this->object_id]);
-
       $this->data = $msg;
     }
   }
@@ -34,20 +33,13 @@ class sieve_reject
       $this->data = _("Your reject text here");
     }else{
 
-      /* Get reject text */
-      $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'];
-          }
+      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;
         }
       }
-      $this->data = preg_replace("/\"/","",$str);
     }
   }
 
index 535c591e86a73da987331e3766b6d2d89719b371..0a781daadee488c6571210dfbf1a534f512785e6 100644 (file)
@@ -12,23 +12,25 @@ 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;
@@ -46,7 +48,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 +82,7 @@ class sieve_require
   {
     $Require = "";
     foreach($this->data as $key){
-      $Require .= "\"".$key."\"".", ";
+      $Require .= $key.", ";
     }
     $Require = preg_replace("/,$/","",trim($Require));