From fd4b9a52f5cc8294117250652c9fcb4365ef69a4 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 9 Mar 2007 14:48:00 +0000 Subject: [PATCH] Removed some code git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5764 594d385d-05f5-0310-b6e9-bd551577e9d8 --- html/images/sieve_move_object_down.png | Bin 685 -> 694 bytes include/sieve/class_My_Tree.inc | 140 ++++++------------------- 2 files changed, 34 insertions(+), 106 deletions(-) diff --git a/html/images/sieve_move_object_down.png b/html/images/sieve_move_object_down.png index 586a7657e4b5bbbf93d167eb36f3849207e1bb8b..b6ad2153f2b4284a33aeeebd66637a64d26118fe 100644 GIT binary patch delta 621 zcmV-z0+Ri$1-1o{RDTU32`};9x&QzILrFwIR5;6}lRHdQK@^6+Gxy%zyUW5#fIxUG zK|xW_!bgPI2!%$$g3wrCVq>B)+nCsFMPihOf?^vjG_j<>#z>`&kEk)RkVJ`!MC6^- zMObtn_m0J0mW4>8e=?cLnVBzt{*!~&S{%n=aBvV$0+`#D;eXW&(psanMzq%XUsAZQ z1)2Z_Xm9@sOaQrJ03MxaG>V996vNUmaHBlZ(PBvkM8t7*Htnbfz%^xAWK+q46EhZz z5s$~WxKqJM?dkr3`l@mh*M-Vm2Cox#t5)FVGQ1i-1H|%xp`jtRNeh|G`>(4^CoEhI zU2QhDW&h48cz-$4NAlB?O$SB6>5a1hwoeEJ6e#f91}d}8+dEN~CLV2hZ+aos17%*Z z0_|v@&mdqclqrP5A?6>Cmd!lB+W^?W=VE|Hj1ptdm3xM1DN`Irh4(euW|m;kMj2p9 zhU%8i!zV7^A5|h~%^c9b3DE9GcV%*{?$pSw^S#X&?tdDS^S=lN4Qxx8P3Ab#-cY{3 z=R(KK4|q4n)r|}cZ+BUrdbYOsA(yT=*&V116Dsu+@GF7=h0m|>Sq`%a&D4T%NgQsU zYu^gU$DjK0G%>$aQ`y{gv@R0DwglTRl=u~nW3aGd-4qyB3VPc90swGUCdQW+Q+pfR zyAIY=`)2U_1YBVuX~lu-O6A*h_P`DRK&O}Aj4vmw&fSNOH#^x{M*2j^X|H!0==A`FVft4o{!@PdVyDStL7i$v00000NkvXX Hu0mjfZU-x2 delta 612 zcmV-q0-OD|1+4{;RDT9310aO~jsO4xI!Q!9R5;6}lgmp~VHn1L-*+x^W;~8vz(|nV zh()z&Q3U-HF4{$#E<`fXx?I>o2CAJ?*@XxSv;t`%1!=Pj0~dm1E>grxGk8g-QHL{^ zbKVxt9BptDJ@CS}d4BK5^S&=4f{0Kj1sH%?R|=rJyBpv45q}Y-YG$R>Zh#4#1mZwY zH3q;ekO9J`X3Y^h-GkMzkDy!zxEC>k4nr#o5h;t!`ux`)vhcbS$S9>qBog%Y_U-`e z{AbQy`-nDeRKT$_2fd@KIUlWIWxc}NCz&lDq}Dx^O3~QZh^_&0(`m+29at7P7M|x7 z8JpQ;YjI72kHFxzAM#rrhexE2|I{C|f9?DkO7Ls|0000_get_next_free_move_slot($key_id,$direction)."
"; - $this->move_single_element_to($key_id,$this->_get_next_free_move_slot($key_id,$direction)); + if(in_array($e_class,array( "sieve_stop", + "sieve_keep", + "sieve_require", + "sieve_stop", + "sieve_reject", + "sieve_fileinto", + "sieve_redirect", + "sieve_discard"))){ + $this->move_single_element($key_id,$this->_get_next_free_move_slot($key_id,$direction)); } } - function move_single_element_to($from,$to) + /* This function moves the single element at + * position $from to position $to. + */ + function move_single_element($from,$to) { if($from == $to) { return; @@ -267,12 +276,20 @@ class My_Tree extends Tree } + /* Returns the next free position where we + * can add a new sinle element + * $key_id = Current position + * $direction = Forward or backward. + */ function _get_next_free_move_slot($key_id,$direction) { $last_class = ""; $current_class =""; $next_class = ""; + /* After this elements we can add new elements + * without having any trouble. + */ $allowed_to_add_after = array("sieve_keep", "sieve_require", "sieve_stop", @@ -283,6 +300,9 @@ class My_Tree extends Tree "sieve_block_start" ); + /* Before this elements we can add new elements + * without having any trouble. + */ $allowed_to_add_before = array("sieve_keep", "sieve_require", "sieve_stop", @@ -295,29 +315,28 @@ class My_Tree extends Tree ); if($direction == "down"){ + + /* Get free position before $key_id */ $test = $this->pap; - - while($key_id < count($test)){ - - if(($key_id+1) == count($test)) return($key_id); - + if(($key_id+1) == count($test)) { + return($key_id); + } $key_id ++; - $current_class = get_class($test[$key_id]); if(in_array($current_class, $allowed_to_add_after)){ return($key_id); } } }else{ - + + /* Get next free position */ $test = $this->pap; - - if($key_id == 0) return($key_id); - + if($key_id == 0) { + return($key_id); + } $key_id --; while($key_id >=0 ){ - $current_class = get_class($test[$key_id]); if(in_array($current_class, $allowed_to_add_before)){ return($key_id); @@ -327,97 +346,6 @@ class My_Tree extends Tree } } - function move_object_up($key_id) - { - $new = array(); - $add_now = NULL; - $key_id --; - - if(!$key_id < 0) return; - - foreach($this->pap as $key => $data){ - if($key == $key_id){ - $add_now = $data; - continue; - }else{ - $new[] = $data; - } - - if($add_now != NULL){ - - $new[] = $add_now; - $add_now = NULL; - } - } - if($add_now != NULL){ - $new[] = $add_now; - } - $this->pap = $new; - } - - - /* This function moves the given element one position down - * if the next position is between - * '}' 'else[if]' or 'if' '{' use next available - */ - function move_object_down($key_id) - { - $new = array(); - $add_now = NULL; - - /* Walk through all elements, till we found the given id. - * If we found it, skip adding the current element, - * first add the next element followed by the current. - */ - foreach($this->pap as $key => $data){ - - /* Have we found the given id */ - if($key == $key_id){ - $add_now = $data; - $last_class = get_class($data); - continue; - }else{ - - /* Add entry */ - $new[] = $data; - } - - /* We have skipped adding an element before, - * try to add it now, if the position allows this. - */ - if($add_now != NULL){ - - /* Don't allow adding an element directly after - * if/else/elsif - */ - if(in_array(get_class($data),array("sieve_if","sieve_elsif","sieve_else"))){ - continue; - } - - /* If this is an block end, check if there - * follows an if/else/elsif and skip adding the element in this case. - */ - $next =""; - if(isset($this->pap[$key+1])){ - $next = get_class($this->pap[$key+1]); - } - if(in_array(get_class($data),array("sieve_block_end")) && in_array($next,array("sieve_elsif","sieve_else"))){ - continue; - } - - /* Add element, position seems to be ok */ - $new[] = $add_now; - $add_now = NULL; - } - } - - /* Element wasn't added, add it as last element */ - if($add_now != NULL){ - $new[] = $add_now; - } - $this->pap = $new; - } - /* Need to be reviewed */ function get_sieve_script() -- 2.30.2