From 7111eb19ff6c1a898777de7fac3f6df8affdbc09 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 16 Mar 2007 13:19:05 +0000 Subject: [PATCH] Made else elsif addable git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5802 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/sieve/class_My_Tree.inc | 12 ++++++-- include/sieve/class_sieveElement_If.inc | 4 ++- include/sieve/class_sieveManagement.inc | 29 +++++++++++++++++-- .../templates/object_container_clear.tpl | 2 ++ 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/include/sieve/class_My_Tree.inc b/include/sieve/class_My_Tree.inc index 0d718b2e5..f38f3bab8 100644 --- a/include/sieve/class_My_Tree.inc +++ b/include/sieve/class_My_Tree.inc @@ -169,9 +169,10 @@ class My_Tree extends Tree function remove_object($key_id) { $class = get_class($this->pap[$key_id]); - if(in_array($class,array("sieve_if"))){ + if(in_array($class,array("sieve_if","sieve_elsif","sieve_else"))){ $block_start= $key_id; $block_end = $this->get_block_end($key_id); + for($i = $block_start ; $i <= $block_end ; $i ++ ){ unset($this->pap[$i]); } @@ -309,7 +310,7 @@ class My_Tree extends Tree /* Only execute if this is a really a block element. * Block elements is only sieve_if */ - if(in_array(get_class($this->pap[$start]),array("sieve_if"))){ + if(in_array(get_class($this->pap[$start]),array("sieve_if","sieve_elsif","sieve_else"))){ $class = get_class($this->pap[$start]); $next_class = get_class($this->pap[$start+1]); @@ -335,7 +336,12 @@ class My_Tree extends Tree } $start ++; $class = get_class($this->pap[$start]); - $next_class = get_class($this->pap[$start+1]); + + if(isset($this->pap[$start+1])){ + $next_class = get_class($this->pap[$start+1]); + }else{ + $next_class =""; + } } } return($start); diff --git a/include/sieve/class_sieveElement_If.inc b/include/sieve/class_sieveElement_If.inc index 1e4f6829f..26bf54c42 100644 --- a/include/sieve/class_sieveElement_If.inc +++ b/include/sieve/class_sieveElement_If.inc @@ -61,7 +61,7 @@ class sieve_if */ function get_sieve_script_part() { - $tmp = "if ".$this->get_sieve_script_part_recursive($parsed = NULL,$id = 1,$obj_id=1); + $tmp = $this->TYPE." ".$this->get_sieve_script_part_recursive($parsed = NULL,$id = 1,$obj_id=1); return($tmp); } @@ -779,6 +779,8 @@ class sieve_if $name .= ""._("Condition").""; if($this->TYPE == "if"){ $name .= " - "._("If"); + }elseif($this->TYPE == "elsif"){ + $name .= " - "._("Else if"); }else{ $name .= " - "._("Else"); } diff --git a/include/sieve/class_sieveManagement.inc b/include/sieve/class_sieveManagement.inc index 9bb2570b7..d25cdfa2e 100644 --- a/include/sieve/class_sieveManagement.inc +++ b/include/sieve/class_sieveManagement.inc @@ -480,7 +480,8 @@ class sieveManagement extends plugin /* Element selected */ - if(isset($_POST['element_type']) && isset($element_types[$_POST['element_type']])){ + if(isset($_POST['element_type']) && isset($element_types[$_POST['element_type']]) + || isset($_POST['element_type']) &&in_array($_POST['element_type'],array("sieve_else","sieve_elsif"))){ $this->add_element_type = $_POST['element_type']; } @@ -517,11 +518,22 @@ class sieveManagement extends plugin } /* Create elements we should add */ - $ele[] = new $this->add_element_type(NULL, preg_replace("/[^0-9]/","",microtime())); if($this->add_element_type == "sieve_if"){ + $ele[] = new $this->add_element_type(NULL, preg_replace("/[^0-9]/","",microtime())); $ele[] = new sieve_block_start(NULL,preg_replace("/[^0-9]/","",microtime())); $ele[] = new sieve_block_end(NULL,preg_replace("/[^0-9]/","",microtime())); + }elseif($this->add_element_type == "sieve_else"){ + $ele[] = new sieve_block_end(NULL,preg_replace("/[^0-9]/","",microtime())); + $ele[] = new $this->add_element_type(NULL, preg_replace("/[^0-9]/","",microtime())); + $ele[] = new sieve_block_start(NULL,preg_replace("/[^0-9]/","",microtime())); + }elseif($this->add_element_type == "sieve_elsif"){ + $ele[] = new sieve_block_end(NULL,preg_replace("/[^0-9]/","",microtime())); + $ele[] = new $this->add_element_type(NULL, preg_replace("/[^0-9]/","",microtime())); + $ele[] = new sieve_block_start(NULL,preg_replace("/[^0-9]/","",microtime())); + }else{ + $ele[] = new $this->add_element_type(NULL, preg_replace("/[^0-9]/","",microtime())); } + $start = $end = array(); $found = false; @@ -576,6 +588,19 @@ class sieveManagement extends plugin /* Only display select dialog if it is necessary */ if($this->add_new_element){ $smarty = get_smarty(); + + $add_else_elsif = FALSE; + foreach($this->current_handler->tree_->pap as $obj){ + if($obj->object_id == $this->add_new_id && in_array(get_class($obj),array("sieve_if","sieve_elsif"))){ + $add_else_elsif = TRUE; + } + } + + if($add_else_elsif){ + $element_types['sieve_else'] = _("Else"); + $element_types['sieve_elsif'] = _("Else if"); + } + $smarty->assign("element_types",$element_types ); $smarty->assign("element_type",$this->add_element_type); $str = $smarty->fetch(get_template_path("templates/add_element.tpl",TRUE,dirname(__FILE__))); diff --git a/include/sieve/templates/object_container_clear.tpl b/include/sieve/templates/object_container_clear.tpl index 4791fa8c6..aefc8b10a 100644 --- a/include/sieve/templates/object_container_clear.tpl +++ b/include/sieve/templates/object_container_clear.tpl @@ -1,6 +1,8 @@
+ %%OBJECT_CONTENT%% -- 2.30.2