Code

Updated save_object handling ..
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 16 Mar 2007 11:34:47 +0000 (11:34 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 16 Mar 2007 11:34:47 +0000 (11:34 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5798 594d385d-05f5-0310-b6e9-bd551577e9d8

include/sieve/class_sieveElement_Comment.inc
include/sieve/class_sieveManagement.inc

index 0b718b80489b401cf5b21ae011f1e88c6cdb5990..bad1dce113a80a9b8715f3cf13b6046070aa5f2e 100644 (file)
@@ -32,7 +32,7 @@ class sieve_comment
   function save_object()
   {
     if(isset($_POST['comment_'.$this->object_id])){
-      $cm = $_POST['comment_'.$this->object_id];
+      $cm = stripslashes( $_POST['comment_'.$this->object_id]);
       $this->data = "/*".$cm."*/";
     }
   }
index 439077628b539983df34fe0f6436467565c884ba..b436808a41a8c2d4552db4c1977efc18987b7bfc 100644 (file)
@@ -511,8 +511,8 @@ class sieveManagement extends plugin
               $next_free = $this->current_handler->tree_->_get_next_free_move_slot($index,$direction);
               $next_free ++;
             }else{
-              $next_free = $this->current_handler->tree_->_get_next_free_move_slot($index,$direction);
               $direction = "down";
+              $next_free = $this->current_handler->tree_->_get_next_free_move_slot($index,$direction);
             }
             $this->add_new_id = $this->current_handler->tree_->pap[$next_free]->object_id;
           }
@@ -546,12 +546,15 @@ class sieveManagement extends plugin
               }else{
                 $end[] = $obj;
               }
+              echo $obj->object_id." --> ".$this->add_new_id."<br>";
               if($obj->object_id == $this->add_new_id){
                 $found = true;
+                echo "Jop";
               }
             }
           }
 
+
           /* Only add, if current element could be located */
           if($found){
             $new = array();
@@ -567,6 +570,7 @@ class sieveManagement extends plugin
             $data= $new;
             $this->current_handler->tree_->pap = $data;
             $this->add_new_element = FALSE;
+          }else{
             print_red(_("Something went wrong while adding a new entry."));
           }
         }
@@ -717,52 +721,60 @@ class sieveManagement extends plugin
           }
         }
       }
-      
+
       /* Skip Mode changes and Parse tests 
        *  if we are currently in a subdialog 
        */
-      if(1==1 || !$this->add_new_element && !isset($_POST['Save_Copy']) && !$this->Import_Script &&!isset($_POST['add_type'])) {
-
 
-
-        $Mode = $this->scripts[$this->current_script]['MODE'];
-        $skip_mode_change = false;
-        if(in_array($Mode,array("Source-Only","Source"))){
-          if(isset($_POST['script_contents'])){
-            $sc = stripslashes($_POST['script_contents']);
-            $this->scripts[$this->current_script]['SCRIPT'] = $sc;
-            $p = new My_Parser;
-            if($p -> parse($sc)){
-#              $this->current_handler = $p;
-              $this->Script_Error = "";
-            } else {
-              $this->Script_Error = $p->status_text;
-              $skip_mode_change = TRUE;
-            }
-          }
-        }
-        if(in_array($Mode,array("Structured"))){
-          $this->current_handler->save_object();
-          $sc = $this->current_handler->get_sieve_script();
+      $Mode = $this->scripts[$this->current_script]['MODE'];
+      $skip_mode_change = false;
+      if(in_array($Mode,array("Source-Only","Source"))){
+        if(isset($_POST['script_contents'])){
+          $sc = stripslashes($_POST['script_contents']);
           $this->scripts[$this->current_script]['SCRIPT'] = $sc;
           $p = new My_Parser;
           if($p -> parse($sc)){
- #           $this->current_handler = $p;
             $this->Script_Error = "";
           } else {
             $this->Script_Error = $p->status_text;
             $skip_mode_change = TRUE;
           }
         }
-        if(!$skip_mode_change){
-          if($this->scripts[$this->current_script]['MODE'] != "Source-Only"){
-            if(isset($_POST['View_Source'])){
-              $this->scripts[$this->current_script]['MODE'] = "Source";
-            }
-            if(isset($_POST['View_Structured'])){
-              $this->scripts[$this->current_script]['MODE'] = "Structured";
-            }
+      }
+      if(in_array($Mode,array("Structured"))){
+        $sc = $this->current_handler->get_sieve_script();
+        $this->scripts[$this->current_script]['SCRIPT'] = $sc;
+        $p = new My_Parser;
+        if($p -> parse($sc)){
+          $this->Script_Error = "";
+        } else {
+          $this->Script_Error = $p->status_text;
+          $skip_mode_change = TRUE;
+        }
+      }
+      if(!$skip_mode_change){
+        if($this->scripts[$this->current_script]['MODE'] != "Source-Only"){
+          $old_mode = $this->scripts[$this->current_script]['MODE'];
+          if(isset($_POST['View_Source'])){
+            $this->scripts[$this->current_script]['MODE'] = "Source";
+          }
+          if(isset($_POST['View_Structured'])){
+            $this->scripts[$this->current_script]['MODE'] = "Structured";
           }
+          $new_mode = $this->scripts[$this->current_script]['MODE'];
+
+          if($old_mode != $new_mode){
+
+            $sc = $this->scripts[$this->current_script]['SCRIPT'];
+            $p = new My_Parser;
+
+            if($p -> parse($sc)){
+              $this->current_handler->parse($sc);
+              $this->Script_Error = "";
+            } else {
+              $this->Script_Error = $p->status_text;
+            }
+          } 
         }
       }
       $this->current_handler->save_object();