summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dde3924)
raw | patch | inline | side by side (parent: dde3924)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 9 Mar 2007 14:48:00 +0000 (14:48 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 9 Mar 2007 14:48:00 +0000 (14:48 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5764 594d385d-05f5-0310-b6e9-bd551577e9d8
html/images/sieve_move_object_down.png | patch | blob | history | |
include/sieve/class_My_Tree.inc | patch | blob | history |
index 586a7657e4b5bbbf93d167eb36f3849207e1bb8b..b6ad2153f2b4284a33aeeebd66637a64d26118fe 100644 (file)
Binary files a/html/images/sieve_move_object_down.png and b/html/images/sieve_move_object_down.png differ
Binary files a/html/images/sieve_move_object_down.png and b/html/images/sieve_move_object_down.png differ
index c7d08c8a757475d42837ff61556ebeea77856852..be103e1c2b4a915c43c3beaba4fe69ab55cb8733 100644 (file)
echo "move block";
}
- if(in_array($e_class,array("sieve_stop","sieve_keep","sieve_require", "sieve_stop", "sieve_reject", "sieve_fileinto", "sieve_redirect", "sieve_discard"))){
- echo "move single ".$key_id." to ".$this->_get_next_free_move_slot($key_id,$direction)."<br>";
- $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;
}
+ /* 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",
"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",
);
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);
}
}
- 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()