Code

Fixed object up/down method
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 9 Mar 2007 13:09:50 +0000 (13:09 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 9 Mar 2007 13:09:50 +0000 (13:09 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5763 594d385d-05f5-0310-b6e9-bd551577e9d8

include/sieve/class_My_Tree.inc

index a8321a4502bef0c73afe47e197e0ff0135c85b6a..c7d08c8a757475d42837ff61556ebeea77856852 100644 (file)
@@ -202,26 +202,20 @@ class My_Tree extends Tree
 
   function move_single_element_to($from,$to)
   {
-    if($from == $to) return;
+    if($from == $to) {
+      return;
+    }
 
     $ret = array();
-
-
     $tmp = $this->pap;
 
-#    $tmp = array();
- #  foreach($this->pap as $class){
-  #    $tmp[] = get_class($class);
-   # }
+    $begin = array();
+    $middle = array();
+    $end = array();
+    $element = $this->pap[$from];
 
     if($from > $to ){
 
-      $element = $this->pap[$from];
-
-      $begin = array();
-      $middle = array();
-      $end = array();
-
       /* Get all element in fron to element to move */    
       if($from  != 0){
         $begin = array_slice($tmp,0,$to);
@@ -243,19 +237,10 @@ class My_Tree extends Tree
       foreach($end as $data){
         $ret[] = $data;
       }
-
-#      print_a(array("Anfang" => $begin ,$element, "middle" => $middle, "end" => $end));
-
       $this->pap = $ret;
     }
     if($from < $to ){
 
-      $element = $this->pap[$from];
-
-      $begin = array();
-      $middle = array();
-      $end = array();
-
       /* Get all element in fron to element to move */    
       if($from  != 0){
         $begin = array_slice($tmp,0,$from);
@@ -295,7 +280,19 @@ class My_Tree extends Tree
                                   "sieve_fileinto", 
                                   "sieve_redirect", 
                                   "sieve_discard",
-                                  "sieve_block_end");
+                                  "sieve_block_start"
+                                 );
+
+    $allowed_to_add_before = array("sieve_keep",
+                                  "sieve_require", 
+                                  "sieve_stop", 
+                                  "sieve_reject", 
+                                  "sieve_fileinto", 
+                                  "sieve_redirect", 
+                                  "sieve_discard",
+                                  "sieve_if", 
+                                  "sieve_block_end"
+                                 );
 
     if($direction == "down"){
       $test = $this->pap;
@@ -322,7 +319,7 @@ class My_Tree extends Tree
       while($key_id >=0 ){
 
         $current_class  = get_class($test[$key_id]);
-        if(in_array($current_class, $allowed_to_add_after)){
+        if(in_array($current_class, $allowed_to_add_before)){
           return($key_id);
         } 
         $key_id --;