From: hickert Date: Tue, 13 Mar 2007 13:25:11 +0000 (+0000) Subject: Some changes X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c58824de6cd08e54853aac4561e71c4a71bc8c72;p=gosa.git Some changes git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5774 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/include/sieve/class_My_Tree.inc b/include/sieve/class_My_Tree.inc index 1cb41a3a7..1816f92b7 100644 --- a/include/sieve/class_My_Tree.inc +++ b/include/sieve/class_My_Tree.inc @@ -16,12 +16,51 @@ class My_Tree extends Tree var $mode_stack = array(); var $pap = array(); + var $add_new = FALSE; + var $add_new_id = 0; + var $add_type = "up"; + var $add_element_type = ""; /* Create a html interface for the current sieve filter */ function dump() { error_reporting(E_ALL); + $element_types= array( + "sieve_keep" => _("Keep"), + "sieve_comment" => _("Comment"), + "sieve_fileinto" => _("File into"), + "sieve_keep" => _("Keep"), + "sieve_redirect" => _("Redirect"), + "sieve_reject" => _("Reject"), + "sieve_require" => _("Require"), + "sieve_stop" => _("Stop"), + "sieve_vacation" => _("Vacation message"), + "sieve_if" => _("If")); + + + if($this->add_new && isset($_POST['element_type']) && isset($element_types[$_POST['element_type']])){ + $this->add_element_type = $_POST['element_type']; + } + + + if($this->add_new && isset($_POST['select_new_element_type'])){ + + $ele = new $this->add_element_type(array(),microtime()); + + $this->pap[] = $ele; + $this->add_new = FALSE; + } + + if($this->add_new){ + + $smarty = get_smarty(); + $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__))); + return($str); + } /* Only parse the tokens once */ if(!count($this->pap)){ @@ -33,7 +72,6 @@ class My_Tree extends Tree /* Create html results */ $smarty = get_smarty(); - $smarty->fetch(get_template_path("templates/element_stop.tpl",TRUE,dirname(__FILE__))); $this -> dump_ = ""; foreach($this->pap as $key => $object){ @@ -146,7 +184,14 @@ class My_Tree extends Tree 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"))){ + if(in_array(get_class($obj),array("sieve_if", + "sieve_elsif", + "sieve_vacation", + "sieve_comment", + "sieve_reject", + "sieve_fileinto", + "sieve_require", + "sieve_redirect"))){ if(isset($this->pap[$key]) && method_exists($this->pap[$key],"save_object")){ @@ -169,29 +214,41 @@ class My_Tree extends Tree $this->move_up_down($key,"down"); $once = FALSE; } + if(isset($obj->object_id) && preg_match("/^Add_Object_Top_".$obj->object_id."_/",$name) && $once){ + $this->add_new_object($obj->object_id,"top"); + $once = FALSE; + } + if(isset($obj->object_id) && preg_match("/^Add_Object_Bottom_".$obj->object_id."_/",$name) && $once){ + $this->add_new_object($obj->object_id,"bottom"); + $once = FALSE; + } } } } + /* Add a new object at the given position */ + function add_new_object($id,$top_bottom = "bottom") + { + $this->add_new = TRUE; + $this->add_new_id = $id; + $this->add_type = $top_bottom; + } + + + /* Remove the object at the given position */ 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; diff --git a/include/sieve/class_sieveElement_Discard.inc b/include/sieve/class_sieveElement_Discard.inc new file mode 100644 index 000000000..5998164b6 --- /dev/null +++ b/include/sieve/class_sieveElement_Discard.inc @@ -0,0 +1,35 @@ +object_id = $object_id; + } + + function get_sieve_script_part() + { + return("discard;\n"); + } + + function save_object() + { + + } + + function execute() + { + $smarty = get_smarty(); + $smarty->assign("ID", $this->object_id); + $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__))); + $object = $smarty->fetch(get_template_path("templates/element_discard.tpl",TRUE,dirname(__FILE__))); + $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container); + return($str); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/include/sieve/class_sieveManagement.inc b/include/sieve/class_sieveManagement.inc index fdce9e31c..cfbbb748e 100644 --- a/include/sieve/class_sieveManagement.inc +++ b/include/sieve/class_sieveManagement.inc @@ -218,11 +218,6 @@ class sieveManagement extends plugin /* Create output for currently opened sieve script */ if($this->current_handler){ $ret = $this->current_handler->execute(); - $ret .= "
- -   - -
"; return($ret); } diff --git a/include/sieve/templates/edit_frame_base.tpl b/include/sieve/templates/edit_frame_base.tpl index 9de761cfb..d99edbba0 100644 --- a/include/sieve/templates/edit_frame_base.tpl +++ b/include/sieve/templates/edit_frame_base.tpl @@ -19,3 +19,8 @@ +
+ +   + +
diff --git a/include/sieve/templates/object_container.tpl b/include/sieve/templates/object_container.tpl index cbd6dd938..94d539888 100644 --- a/include/sieve/templates/object_container.tpl +++ b/include/sieve/templates/object_container.tpl @@ -1,4 +1,15 @@ + + + +
+   + +   + +