From d451bedd85ca057fc83558191b6ef21b06e5a298 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 12 Mar 2007 13:55:02 +0000 Subject: [PATCH] Some sieve update git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5767 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/sieve/class_My_Tree.inc | 32 +++++++++++++++++-- include/sieve/class_sieveElements.inc | 30 +++++++++++------ include/sieve/templates/element_block_end.tpl | 13 -------- .../sieve/templates/element_block_start.tpl | 18 ++--------- include/sieve/templates/element_comment.tpl | 2 +- include/sieve/templates/element_discard.tpl | 2 +- include/sieve/templates/element_else.tpl | 2 +- include/sieve/templates/element_fileinto.tpl | 2 +- include/sieve/templates/element_if_else.tpl | 2 +- include/sieve/templates/element_keep.tpl | 2 +- include/sieve/templates/element_redirect.tpl | 4 +-- include/sieve/templates/element_reject.tpl | 2 +- include/sieve/templates/element_require.tpl | 6 ++-- include/sieve/templates/element_stop.tpl | 2 +- include/sieve/templates/object_container.tpl | 4 +-- .../templates/object_container_clear.tpl | 4 +-- 16 files changed, 70 insertions(+), 57 deletions(-) diff --git a/include/sieve/class_My_Tree.inc b/include/sieve/class_My_Tree.inc index cb18851b9..78522ba2a 100644 --- a/include/sieve/class_My_Tree.inc +++ b/include/sieve/class_My_Tree.inc @@ -143,10 +143,15 @@ class My_Tree extends Tree function save_object() { + reset($this->pap); foreach($this->pap as $key => $obj){ if(in_array(get_class($obj),array("sieve_if","sieve_elsif","sieve_vacation","sieve_comment","sieve_reject","sieve_fileinto","sieve_require","sieve_redirect"))){ - $this->pap[$key]->save_object(); + + + if(isset($this->pap[$key]) && method_exists($this->pap[$key],"save_object")){ + $this->pap[$key]->save_object(); + } } $once = TRUE; @@ -169,8 +174,29 @@ class My_Tree extends Tree } - function remove_object($key_id){ - unset($this->pap[$key_id]); + function remove_object($key_id) + { + + $class = get_class($this->pap[$key_id]); + + if(in_array($class,array("sieve_if"))){ + + $block_start= $key_id; + $block_end = $this->get_block_end($key_id); + + for($i = $block_start ; $i <= $block_end ; $i ++ ){ + unset($this->pap[$i]); + } + + }else{ + unset($this->pap[$key_id]); + } + + $tmp = array(); + foreach($this->pap as $element){ + $tmp[] = $element; + } + $this->pap = $tmp; } diff --git a/include/sieve/class_sieveElements.inc b/include/sieve/class_sieveElements.inc index 3c133fdf1..511e836c9 100644 --- a/include/sieve/class_sieveElements.inc +++ b/include/sieve/class_sieveElements.inc @@ -132,11 +132,14 @@ class sieve_require $Require .= $key.", "; } $Require = preg_replace("/,$/","",trim($Require)); - + $smarty = get_smarty(); $smarty->assign("Require",$Require); - $smarty->assign("ID",$this->object_id); - return($smarty->fetch(get_template_path("templates/element_require.tpl",TRUE,dirname(__FILE__)))); + $smarty->assign("ID", $this->object_id); + $object_container = $smarty->fetch(get_template_path("templates/object_container_clear.tpl",TRUE,dirname(__FILE__))); + $object= $smarty->fetch(get_template_path("templates/element_require.tpl",TRUE,dirname(__FILE__))); + $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container); + return($str); } } @@ -220,10 +223,13 @@ class sieve_reject $Multiline = preg_match("/\n/",$this->data); $smarty = get_smarty(); - $smarty->assign("ID",$this->object_id); - $smarty->assign("Multiline",$Multiline); + $smarty->assign("ID", $this->object_id); $smarty->assign("Message",$this->data); - return($smarty->fetch(get_template_path("templates/element_reject.tpl",TRUE,dirname(__FILE__)))); + $smarty->assign("Multiline",$Multiline); + $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__))); + $object= $smarty->fetch(get_template_path("templates/element_reject.tpl",TRUE,dirname(__FILE__))); + $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container); + return($str); } } @@ -278,9 +284,12 @@ class sieve_redirect $values = preg_replace("/,$/","",trim($values)); $smarty = get_smarty(); + $smarty->assign("ID", $this->object_id); $smarty->assign("Destinations" , $values); - $smarty->assign("ID" , $this->object_id); - return($smarty->fetch(get_template_path("templates/element_redirect.tpl",TRUE,dirname(__FILE__)))); + $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__))); + $object= $smarty->fetch(get_template_path("templates/element_redirect.tpl",TRUE,dirname(__FILE__))); + $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container); + return($str); } } @@ -330,7 +339,10 @@ class sieve_fileinto $smarty->assign("Selected",$this->data[0]); $smarty->assign("Boxes", $this->get_mail_boxes()); $smarty->assign("ID", $this->object_id); - return($smarty->fetch(get_template_path("templates/element_fileinto.tpl",TRUE,dirname(__FILE__)))); + $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__))); + $object= $smarty->fetch(get_template_path("templates/element_fileinto.tpl",TRUE,dirname(__FILE__))); + $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container); + return($str); } function get_mail_boxes() diff --git a/include/sieve/templates/element_block_end.tpl b/include/sieve/templates/element_block_end.tpl index 52fbc8c5a..b5af6fbde 100644 --- a/include/sieve/templates/element_block_end.tpl +++ b/include/sieve/templates/element_block_end.tpl @@ -1,16 +1,3 @@ - - - - -
-
- - - - - -
-
diff --git a/include/sieve/templates/element_block_start.tpl b/include/sieve/templates/element_block_start.tpl index 8d3055549..d79212f16 100644 --- a/include/sieve/templates/element_block_start.tpl +++ b/include/sieve/templates/element_block_start.tpl @@ -1,21 +1,9 @@ - +
- - -
-
- - - - -
-
- - -
+ + diff --git a/include/sieve/templates/element_comment.tpl b/include/sieve/templates/element_comment.tpl index d3094d85d..6a52d04e9 100644 --- a/include/sieve/templates/element_comment.tpl +++ b/include/sieve/templates/element_comment.tpl @@ -1,4 +1,4 @@ - +
{t}Comment{/t} diff --git a/include/sieve/templates/element_discard.tpl b/include/sieve/templates/element_discard.tpl index 01a9e8cc5..a557876c8 100644 --- a/include/sieve/templates/element_discard.tpl +++ b/include/sieve/templates/element_discard.tpl @@ -1,6 +1,6 @@ - diff --git a/include/sieve/templates/element_else.tpl b/include/sieve/templates/element_else.tpl index 86eb1f2cc..d7cd58fe1 100644 --- a/include/sieve/templates/element_else.tpl +++ b/include/sieve/templates/element_else.tpl @@ -1,4 +1,4 @@ -
+ {t}Discard message{/t}
+
{t}else{/t} diff --git a/include/sieve/templates/element_fileinto.tpl b/include/sieve/templates/element_fileinto.tpl index 1bd1d8453..b73dc5a03 100644 --- a/include/sieve/templates/element_fileinto.tpl +++ b/include/sieve/templates/element_fileinto.tpl @@ -1,6 +1,6 @@ -
+ {t}Move mail into folder{/t} - diff --git a/include/sieve/templates/element_keep.tpl b/include/sieve/templates/element_keep.tpl index eae62debd..519f2e468 100644 --- a/include/sieve/templates/element_keep.tpl +++ b/include/sieve/templates/element_keep.tpl @@ -1,6 +1,6 @@
+ {$Name} {$Contents}
- diff --git a/include/sieve/templates/element_redirect.tpl b/include/sieve/templates/element_redirect.tpl index 47bcbe2f2..0cac45fe6 100644 --- a/include/sieve/templates/element_redirect.tpl +++ b/include/sieve/templates/element_redirect.tpl @@ -1,8 +1,8 @@ -
+ {t}Keep message{/t}
+
diff --git a/include/sieve/templates/element_reject.tpl b/include/sieve/templates/element_reject.tpl index f5cd572a6..6b9238dcc 100644 --- a/include/sieve/templates/element_reject.tpl +++ b/include/sieve/templates/element_reject.tpl @@ -12,7 +12,7 @@
{t}Redirect{/t} - {t}Redirect mail to following recipients{/t} + {t}Redirect mail to following recipients{/t}
- +
diff --git a/include/sieve/templates/element_require.tpl b/include/sieve/templates/element_require.tpl index 0cde8e3fb..761e636b0 100644 --- a/include/sieve/templates/element_require.tpl +++ b/include/sieve/templates/element_require.tpl @@ -1,11 +1,11 @@ - +
- - diff --git a/include/sieve/templates/element_stop.tpl b/include/sieve/templates/element_stop.tpl index 92a4c214b..8a617a65c 100644 --- a/include/sieve/templates/element_stop.tpl +++ b/include/sieve/templates/element_stop.tpl @@ -1,6 +1,6 @@
+ {t}Require{/t}
+
- diff --git a/include/sieve/templates/object_container.tpl b/include/sieve/templates/object_container.tpl index 5b8188123..cbd6dd938 100644 --- a/include/sieve/templates/object_container.tpl +++ b/include/sieve/templates/object_container.tpl @@ -1,6 +1,6 @@ -
+ {t}Stop{/t}
{t}Stop execution here!{/t}
+
-
+ + -
+ %%OBJECT_CONTENT%% -- 2.30.2