From: hickert Date: Thu, 15 Mar 2007 09:51:45 +0000 (+0000) Subject: Some sieve filter changes X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=1918f305839d75b6e1d56d94086719bd3b62bdeb;p=gosa.git Some sieve filter changes git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5785 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/sieve/class_sieveElement_If.inc b/include/sieve/class_sieveElement_If.inc index d9a70f3b9..1663fdf40 100644 --- a/include/sieve/class_sieveElement_If.inc +++ b/include/sieve/class_sieveElement_If.inc @@ -106,6 +106,17 @@ class sieve_if } break; } + + /******************* + * True / False + *******************/ + + case "true" : + case "fasle" : + { + /* Can't fail anyway */ + break; + } /******************* * Default @@ -115,8 +126,6 @@ class sieve_if { if(isset($data['LastError']) && !empty($data['LastError'])){ $ret[] = $data['LastError']; - - echo "'".$data['LastError']."' ".$key."
" ; } } } diff --git a/include/sieve/class_sieveElement_Reject.inc b/include/sieve/class_sieveElement_Reject.inc index e930456fd..6c0a6f5b6 100644 --- a/include/sieve/class_sieveElement_Reject.inc +++ b/include/sieve/class_sieveElement_Reject.inc @@ -2,7 +2,7 @@ class sieve_reject { - var $data = array(); + var $data = ""; var $object_id = -1; @@ -23,26 +23,37 @@ class sieve_reject function sieve_reject($data,$object_id) { $this->object_id = $object_id; - $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']; + /* If the given data is emtpy + * (This is the case when we add new elements in the ui) + * Set a default text. + */ + if($data == NULL){ + $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']; + } } } + $this->data = preg_replace("/\"/","",$str); } - $this->data = preg_replace("/\"/","",$str); } function get_sieve_script_part() { return("reject ".sieve_create_strings($this->data).";\n"); } - + function execute() { /* check if this will be a @@ -61,5 +72,5 @@ class sieve_reject return($str); } } - - +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/include/sieve/class_sieveElement_Vacation.inc b/include/sieve/class_sieveElement_Vacation.inc index ec3250d48..f2a562fca 100644 --- a/include/sieve/class_sieveElement_Vacation.inc +++ b/include/sieve/class_sieveElement_Vacation.inc @@ -69,9 +69,12 @@ class sieve_vacation if($this->days){ $str.= ":days ".$this->days; } - $str .= ":addresses ".sieve_create_strings($this->addresses); - if($this->subject){ - $str.= ":subject ".sieve_create_strings($this->subject); + + if(count($this->addresses)){ + $str .= ":addresses ".sieve_create_strings($this->addresses); + if($this->subject){ + $str.= ":subject ".sieve_create_strings($this->subject); + } } if($this->mime){ $str.= ":mime ".sieve_create_strings($this->mime); @@ -98,7 +101,10 @@ class sieve_vacation $tmp = array(); $tmp2 = split(",",$vr); foreach($tmp2 as $val){ - $tmp[] = "\"".trim(preg_replace("/\"/","",$val))."\""; + $ad = trim(preg_replace("/\"/","",$val)); + if(!empty($ad)){ + $tmp[] = "\"".$ad."\""; + } } $this->addresses = $tmp; } @@ -112,7 +118,17 @@ class sieve_vacation function check() { - return(array()) ; + $msgs = array(); + $err = FALSE; + foreach($this->addresses as $addr){ + if(!is_email(preg_replace("/\"/","",$addr))){ + $err = true; + } + } + if($err){ + $msgs[] = _("Alternative sender addresse must be valid email addresses."); + } + return($msgs); } function execute() @@ -124,6 +140,8 @@ class sieve_vacation $Addresses = preg_replace("/,$/","",trim($Addresses)); $smarty = get_smarty(); + $smarty->assign("LastError",$this->check()); + $smarty->assign("LastErrorCnt",count($this->check())); $smarty->assign("Reason",$this->reason); $smarty->assign("Addresses",$Addresses); $smarty->assign("Subject",$this->subject); diff --git a/include/sieve/templates/element_vacation.tpl b/include/sieve/templates/element_vacation.tpl index ed6e2b072..837267805 100644 --- a/include/sieve/templates/element_vacation.tpl +++ b/include/sieve/templates/element_vacation.tpl @@ -1,7 +1,22 @@ +{if $LastErrorCnt != 0} + + + + + +
+ {t}Error{/t} + +{/if} + {foreach from=$LastError item=val key=key} + + + + {/foreach} {if $Expert}
+ {$LastError[$key]} +
@@ -22,7 +37,7 @@
- {t}Receiver{/t} + {t}Alternative sender addresses{/t} @@ -50,3 +65,11 @@ {/if}
+{if $LastErrorCnt != 0} + +
+{/if} + +