Code

Made else elsif addable
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 16 Mar 2007 13:19:05 +0000 (13:19 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 16 Mar 2007 13:19:05 +0000 (13:19 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5802 594d385d-05f5-0310-b6e9-bd551577e9d8

include/sieve/class_My_Tree.inc
include/sieve/class_sieveElement_If.inc
include/sieve/class_sieveManagement.inc
include/sieve/templates/object_container_clear.tpl

index 0d718b2e517746c7cd7e9c94868d815887e09fb3..f38f3bab81eb608f548871ba84a78b5674dc6fbb 100644 (file)
@@ -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);
index 1e4f6829f73e71e83093dbf245f9333e9b3b63d6..26bf54c42159e61c218cea3c1fde27a047ab867a 100644 (file)
@@ -61,7 +61,7 @@ class sieve_if
    */
   function get_sieve_script_part()
   {
-    $tmp = "if ".$this->get_sieve_script_part_recursive($parsed = NULL,$id = 1,$obj_id=1);
+    $tmp = $this->TYPE." ".$this->get_sieve_script_part_recursive($parsed = NULL,$id = 1,$obj_id=1);
     return($tmp);
   } 
 
@@ -779,6 +779,8 @@ class sieve_if
     $name .= "<b>"._("Condition")."</b>";
     if($this->TYPE == "if"){
       $name .= "&nbsp;-&nbsp;"._("If");
+    }elseif($this->TYPE == "elsif"){
+      $name .= "&nbsp;-&nbsp;"._("Else if");
     }else{
       $name .= "&nbsp;-&nbsp;"._("Else");
     }
index 9bb2570b701c0589e630e2d0e63cff76794c6224..d25cdfa2eaa1634925890663888e1e2c1f41065f 100644 (file)
@@ -480,7 +480,8 @@ class sieveManagement extends plugin
 
 
         /* Element selected */
-        if(isset($_POST['element_type']) && isset($element_types[$_POST['element_type']])){
+        if(isset($_POST['element_type']) && isset($element_types[$_POST['element_type']]) 
+           || isset($_POST['element_type']) &&in_array($_POST['element_type'],array("sieve_else","sieve_elsif"))){
           $this->add_element_type = $_POST['element_type'];
         }
 
@@ -517,11 +518,22 @@ class sieveManagement extends plugin
           }
 
           /* Create elements we should add */
-          $ele[] = new $this->add_element_type(NULL, preg_replace("/[^0-9]/","",microtime()));
           if($this->add_element_type == "sieve_if"){
+            $ele[] = new $this->add_element_type(NULL, preg_replace("/[^0-9]/","",microtime()));
             $ele[] = new sieve_block_start(NULL,preg_replace("/[^0-9]/","",microtime()));
             $ele[] = new sieve_block_end(NULL,preg_replace("/[^0-9]/","",microtime()));
+          }elseif($this->add_element_type == "sieve_else"){
+            $ele[] = new sieve_block_end(NULL,preg_replace("/[^0-9]/","",microtime()));
+            $ele[] = new $this->add_element_type(NULL, preg_replace("/[^0-9]/","",microtime()));
+            $ele[] = new sieve_block_start(NULL,preg_replace("/[^0-9]/","",microtime()));
+          }elseif($this->add_element_type == "sieve_elsif"){
+            $ele[] = new sieve_block_end(NULL,preg_replace("/[^0-9]/","",microtime()));
+            $ele[] = new $this->add_element_type(NULL, preg_replace("/[^0-9]/","",microtime()));
+            $ele[] = new sieve_block_start(NULL,preg_replace("/[^0-9]/","",microtime()));
+          }else{
+            $ele[] = new $this->add_element_type(NULL, preg_replace("/[^0-9]/","",microtime()));
           }
+
           $start = $end = array();
           $found = false;
 
@@ -576,6 +588,19 @@ class sieveManagement extends plugin
       /* Only display select dialog if it is necessary */
       if($this->add_new_element){
         $smarty = get_smarty();
+    
+        $add_else_elsif = FALSE;
+        foreach($this->current_handler->tree_->pap as $obj){
+          if($obj->object_id == $this->add_new_id && in_array(get_class($obj),array("sieve_if","sieve_elsif"))){
+            $add_else_elsif = TRUE;
+          }
+        }
+
+        if($add_else_elsif){
+          $element_types['sieve_else'] = _("Else");
+          $element_types['sieve_elsif'] = _("Else if");
+        }
+  
         $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__)));
index 4791fa8c6797a3bebc296b1db9063061971a70e1..aefc8b10a10ae7489abfd707e611da300f1b3843 100644 (file)
@@ -1,6 +1,8 @@
 <table cellspacing=0 style='width:100%;background-color:#EEEEEE;border: solid 1px #BBB;346575;'>
        <tr>
                <td style='width:20px; background-color: #235464;'>     
+                       <input type='image' src='images/sieve_del_object.png' name='Remove_Object_{$ID}' 
+                               title='{t}Remove this object{/t}' alt='R'>
                </td>
                <td>
                        %%OBJECT_CONTENT%%