Code

Added some checks
[gosa.git] / include / sieve / class_My_Tree.inc
index 0dd19a21eab158856cb90dc5615415054f0ff403..f38f3bab81eb608f548871ba84a78b5674dc6fbb 100644 (file)
@@ -69,14 +69,14 @@ class My_Tree extends Tree
     if($node['class'] == "block-start"){
       $tmp = array_pop($this->mode_stack);
       $this->handle_elements($tmp,$node_id);
-      $this->handle_elements(array("TYPE" => "block_start"),$node_id);
+      $this->handle_elements(array("TYPE" => "block_start"),preg_replace("/[^0-9]/","",microtime()));
     }
 
     /* This closes the last mode */
     if($node['class'] == "block-end"){
       $tmp = array_pop($this->mode_stack);
       $this->handle_elements($tmp,$node_id);
-      $this->handle_elements(array("TYPE" => "block_end"),$node_id);
+      $this->handle_elements(array("TYPE" => "block_end"),preg_replace("/[^0-9]/","",microtime()));
     }
 
     /* Semicolon indicates a new command */
@@ -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);
@@ -518,12 +524,6 @@ class My_Tree extends Tree
     return($tmp);
   }
 
-  function Add_Element()
-  {
-    $tmp = array("ELEMENTS" => array(array("class" => "qouted-string","text"=> "Bla bla, later more")));
-    $this->pap[] = new sieve_comment($tmp,rand(1000,100000));
-  }
-
   function check()
   {
                $msgs = array();