From ca55fae1641ace4e5faff4d0eca0f74e3902eee5 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 7 Mar 2007 07:22:24 +0000 Subject: [PATCH] Some updates git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5754 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/sieve/class_My_Tree.inc | 2 +- include/sieve/class_sieveElement_If.inc | 82 ++++++++++---------- include/sieve/class_sieveElements.inc | 57 +++++++++++--- include/sieve/templates/element_allof.tpl | 15 ++++ include/sieve/templates/element_anyof.tpl | 15 ++++ include/sieve/templates/element_boolean.tpl | 18 +++-- include/sieve/templates/element_exists.tpl | 4 +- include/sieve/templates/element_header.tpl | 5 +- include/sieve/templates/element_size.tpl | 4 +- include/sieve/templates/element_vacation.tpl | 38 +++++++++ 10 files changed, 178 insertions(+), 62 deletions(-) create mode 100644 include/sieve/templates/element_allof.tpl create mode 100644 include/sieve/templates/element_anyof.tpl create mode 100644 include/sieve/templates/element_vacation.tpl diff --git a/include/sieve/class_My_Tree.inc b/include/sieve/class_My_Tree.inc index 922156017..bca523f2c 100644 --- a/include/sieve/class_My_Tree.inc +++ b/include/sieve/class_My_Tree.inc @@ -138,7 +138,7 @@ class My_Tree extends Tree { foreach($this->pap as $key => $obj){ - if(in_array(get_class($obj),array("sieve_if"))){ + if(in_array(get_class($obj),array("sieve_if","sieve_vacation"))){ $this->pap[$key]->save_object(); } } diff --git a/include/sieve/class_sieveElement_If.inc b/include/sieve/class_sieveElement_If.inc index 03934e460..0b8c5caad 100644 --- a/include/sieve/class_sieveElement_If.inc +++ b/include/sieve/class_sieveElement_If.inc @@ -562,6 +562,9 @@ class sieve_if case "allof" : { + if(isset($_POST['toggle_inverse_'.$element_id])){ + $parsed[$key]['Inverse'] = !$parsed[$key]['Inverse']; + } foreach($data as $key2 => $dat){ if(($key2 === "Inverse") && ($key2 == "Inverse")){ continue; @@ -577,6 +580,9 @@ class sieve_if case "anyof" : { + if(isset($_POST['toggle_inverse_'.$element_id])){ + $parsed[$key]['Inverse'] = !$parsed[$key]['Inverse']; + } foreach($data as $key2 => $dat){ if(($key2 === "Inverse") && ($key2 == "Inverse")){ continue; @@ -713,6 +719,11 @@ class sieve_if break; } + + /******************* + * Envelope + *******************/ + case "envelope": { $address_parts = $this->address_parts; @@ -730,26 +741,31 @@ class sieve_if $smarty->assign("match_type", $data['Match_type']); $smarty->assign("operator" , preg_replace("/\"/","",$data['Match_type_value'])); $smarty->assign("comparator", $data['Comparator']); - $keys = ""; foreach($data['Key_List'] as $key){ - $keys .= $key."\n"; + $keys .= $key.", "; } - + $keys = preg_replace("/,$/","",trim($keys)); + $values = ""; foreach($data['Value_List'] as $key){ - $values .= $key."\n"; + $values .= $key.", "; } + $values = preg_replace("/,$/","",trim($values)); $smarty->assign("keys",$keys); $smarty->assign("values",$values); - $smarty->assign("ID" , $element_id); $ret .= $smarty->fetch(get_template_path("templates/element_envelope.tpl",TRUE,dirname(__FILE__))); break; } + + /******************* + * Address + *******************/ + case "address" : { $address_parts = $this->address_parts; @@ -860,24 +876,18 @@ class sieve_if case "allof" : { - $ret = " - - "; - $ret.= " - -
". - "".$str_inverse._("All of")."". - "". - ""; - + $Contents = ""; foreach($data as $key => $dat){ if(($key === "Inverse") && ($key == "Inverse")){ continue; } - $ret.= $this->get_as_html($dat, ($id +1),$key); + $Contents .= $this->get_as_html($dat, ($id +1),$key); } - $ret.= "
"; + $smarty = get_smarty(); + $smarty->assign("Inverse",$Inverse); + $smarty->assign("Contents",$Contents); + $smarty->assign("ID" , $element_id); + $ret .= $smarty->fetch(get_template_path("templates/element_allof.tpl",TRUE,dirname(__FILE__))); break ; } @@ -888,36 +898,30 @@ class sieve_if case "anyof" : { - $ret = " - - "; - $ret.= "
". - "".$str_inverse._("Any of")."". - "". - ""; + $Contents = ""; foreach($data as $key => $dat){ if(($key === "Inverse") && ($key == "Inverse")){ continue; } - $ret.= $this->get_as_html($dat, ($id + 1),$key); + $Contents .= $this->get_as_html($dat, ($id +1),$key); } + $smarty = get_smarty(); + $smarty->assign("Inverse",$Inverse); + $smarty->assign("Contents",$Contents); + $smarty->assign("ID" , $element_id); + $ret .= $smarty->fetch(get_template_path("templates/element_anyof.tpl",TRUE,dirname(__FILE__))); + break ; + } + default : + { + $ret = " + +
"; + $ret.= $key."
"; $ret.= "
"; - break ; } - default : - { - $ret = " - - - -
"; - $ret.= $key."
"; - $ret.= "
"; - - } } } return($ret); diff --git a/include/sieve/class_sieveElements.inc b/include/sieve/class_sieveElements.inc index 768a4dfc6..1c62f35fa 100644 --- a/include/sieve/class_sieveElements.inc +++ b/include/sieve/class_sieveElements.inc @@ -195,11 +195,13 @@ class sieve_vacation var $subject = FALSE; var $from = ""; var $mime = ""; - var $hanlde = ""; + var $handle = ""; var $reason = ""; var $addresses= array(); + var $object_id= -1; + var $Expert = FALSE; - function sieve_vacation($data) + function sieve_vacation($data,$object_id) { /* Usage: vacation [":days" number] [":subject" string] [":from" string] [":addresses" string-list] @@ -264,17 +266,54 @@ class sieve_vacation return($str."\n"); } + + function save_object() + { + /* Get release date */ + if(isset($_POST['vacation_release_'.$this->object_id])){ + $this->days = $_POST['vacation_release_'.$this->object_id]; + } + + /* Check if we want to toggle the expert mode */ + if(isset($_POST['Toggle_Expert_'.$this->object_id])){ + $this->Expert = !$this->Expert; + } + + /* Get release date */ + if(isset($_POST['vacation_receiver_'.$this->object_id])){ + $vr = stripslashes ($_POST['vacation_receiver_'.$this->object_id]); + $tmp = array(); + $tmp2 = split(",",$vr); + foreach($tmp2 as $val){ + $tmp[] = "\"".trim(preg_replace("/\"/","",$val))."\""; + } + $this->addresses = $tmp; + } + + /* Get reason */ + if(isset($_POST['vacation_reason_'.$this->object_id])){ + $vr = stripslashes ($_POST['vacation_reason_'.$this->object_id]); + $this->reason = "\"".trim(preg_replace("/\"/","",$vr))."\""; + } + } + function execute() { - $str =""; - $str .=""._("Vacation message").""; - foreach($this->addresses as $addr){ - $str .="
"; + $Addresses = ""; + foreach($this->addresses as $key){ + $Addresses .= $key.", "; } - $str .="
"; - - return($str); + $Addresses = preg_replace("/,$/","",trim($Addresses)); + + $smarty = get_smarty(); + $smarty->assign("Reason",$this->reason); + $smarty->assign("Addresses",$Addresses); + $smarty->assign("Subject",$this->subject); + $smarty->assign("Days",$this->days); + $smarty->assign("ID",$this->object_id); + $smarty->assign("Expert",$this->Expert); + return($smarty->fetch(get_template_path("templates/element_vacation.tpl",TRUE,dirname(__FILE__)))); } } diff --git a/include/sieve/templates/element_allof.tpl b/include/sieve/templates/element_allof.tpl new file mode 100644 index 000000000..a4e811ab2 --- /dev/null +++ b/include/sieve/templates/element_allof.tpl @@ -0,0 +1,15 @@ + + + + + +
+ {if $Inverse} + + {else} + + {/if} + + + {$Contents} +
diff --git a/include/sieve/templates/element_anyof.tpl b/include/sieve/templates/element_anyof.tpl new file mode 100644 index 000000000..7eebc2ec8 --- /dev/null +++ b/include/sieve/templates/element_anyof.tpl @@ -0,0 +1,15 @@ + + + + + +
+ {if $Inverse} + + {else} + + {/if} + + + {$Contents} +
diff --git a/include/sieve/templates/element_boolean.tpl b/include/sieve/templates/element_boolean.tpl index 61578ddb7..47a97c1b2 100755 --- a/include/sieve/templates/element_boolean.tpl +++ b/include/sieve/templates/element_boolean.tpl @@ -1,6 +1,12 @@ -{t}Bool{/t} - - -
+ + + + +
+ {t}Bool{/t} + + +
+
diff --git a/include/sieve/templates/element_exists.tpl b/include/sieve/templates/element_exists.tpl index 164313af5..626cf875c 100644 --- a/include/sieve/templates/element_exists.tpl +++ b/include/sieve/templates/element_exists.tpl @@ -1,7 +1,7 @@ -{t}Exists{/t} - +
+ {t}Exists{/t} {if $LastError != ""} {$LastError}
diff --git a/include/sieve/templates/element_header.tpl b/include/sieve/templates/element_header.tpl index c88466f1a..fe7f472cd 100755 --- a/include/sieve/templates/element_header.tpl +++ b/include/sieve/templates/element_header.tpl @@ -1,5 +1,4 @@ - - +
{if $Expert} @@ -78,7 +77,7 @@
{t}If{/t}   - {t}Envelope{/t} + {t}Header{/t} {if $Inverse} diff --git a/include/sieve/templates/element_size.tpl b/include/sieve/templates/element_size.tpl index c589de5bf..def994dff 100644 --- a/include/sieve/templates/element_size.tpl +++ b/include/sieve/templates/element_size.tpl @@ -1,7 +1,7 @@ -{t}Size{/t} - +
+{t}Size{/t} {if $LastError != ""} {$LastError}
diff --git a/include/sieve/templates/element_vacation.tpl b/include/sieve/templates/element_vacation.tpl new file mode 100644 index 000000000..4cb133a8b --- /dev/null +++ b/include/sieve/templates/element_vacation.tpl @@ -0,0 +1,38 @@ + + + + + {if $Expert} + + + + + + + + + + {else} + + + + + {/if} +
+ {t}Release date{/t}  + + + + {t}Receiver{/t} + + + + +
+ +
+ + + +
+ -- 2.30.2