From 21a58fd84bb8da0f205c5863c4e71ce9cd7d1680 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 29 Mar 2007 09:04:47 +0000 Subject: [PATCH] Fixed several sieveElement and their initialization git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5922 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/sieve/class_My_Tree.inc | 6 +++++- include/sieve/class_sieveElement_Fileinto.inc | 13 +++++-------- include/sieve/class_sieveElement_Redirect.inc | 14 +++++--------- include/sieve/class_sieveElement_Reject.inc | 18 +++++------------- include/sieve/class_sieveElement_Require.inc | 16 +++++++++------- 5 files changed, 29 insertions(+), 38 deletions(-) diff --git a/include/sieve/class_My_Tree.inc b/include/sieve/class_My_Tree.inc index cc9600b6b..32bf58a03 100644 --- a/include/sieve/class_My_Tree.inc +++ b/include/sieve/class_My_Tree.inc @@ -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 ++; diff --git a/include/sieve/class_sieveElement_Fileinto.inc b/include/sieve/class_sieveElement_Fileinto.inc index 6ac66371c..f357d37d9 100644 --- a/include/sieve/class_sieveElement_Fileinto.inc +++ b/include/sieve/class_sieveElement_Fileinto.inc @@ -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; } } diff --git a/include/sieve/class_sieveElement_Redirect.inc b/include/sieve/class_sieveElement_Redirect.inc index 4f19c67e8..56f55cf77 100644 --- a/include/sieve/class_sieveElement_Redirect.inc +++ b/include/sieve/class_sieveElement_Redirect.inc @@ -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; } } } diff --git a/include/sieve/class_sieveElement_Reject.inc b/include/sieve/class_sieveElement_Reject.inc index 0447c254a..398f6ed36 100644 --- a/include/sieve/class_sieveElement_Reject.inc +++ b/include/sieve/class_sieveElement_Reject.inc @@ -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); } } diff --git a/include/sieve/class_sieveElement_Require.inc b/include/sieve/class_sieveElement_Require.inc index 535c591e8..0a781daad 100644 --- a/include/sieve/class_sieveElement_Require.inc +++ b/include/sieve/class_sieveElement_Require.inc @@ -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)); -- 2.30.2