Code

Don't automatically add quotes to match values.
[gosa.git] / include / sieve / class_sieveElement_Reject.inc
index e930456fd8a0dd69c851f410f2629177526756ed..398f6ed3644c511f295ca5096c8e4f42e6853ece 100644 (file)
@@ -2,15 +2,14 @@
 
 class sieve_reject 
 {
-  var $data = array();
+  var $data = "";
   var $object_id = -1;
-
+  var $parent = NULL;
 
   function save_object()
   {
     if(isset($_POST['reject_message_'.$this->object_id])){
       $msg = stripslashes($_POST['reject_message_'.$this->object_id]);
-
       $this->data = $msg;
     }
   }
@@ -20,29 +19,35 @@ class sieve_reject
     return(array());
   }
 
-  function sieve_reject($data,$object_id)
+  function sieve_reject($data,$object_id,$parent)
   {
     $this->object_id = $object_id;
-    $str = "";
-    foreach($data['ELEMENTS'] as $node ){
-      if(in_array($node['class'],array("quoted-string","text","multi-line"))){
+    $this->parent = $parent;
+    $this->parent->add_require("reject");
+
+    /* If the given data is emtpy 
+     *  (This is the case when we add new elements in the ui) 
+     * Set a default text. 
+     */
+    if($data == NULL){
+      $this->data = _("Your reject text here");
+    }else{
 
-        if($node['class'] == "multi-line"){
-          $str .= preg_replace("/^text:[ \n\r]*/","",$node['text']);
-          $str =  preg_replace("/[  \n\r]*\.[  \n\r]*$/","",$str);
-        }else{
-          $str .= $node['text'];
+      for($i = 0 ; $i < count($data['ELEMENTS']) ; $i++){
+        $tmp = sieve_get_strings($data['ELEMENTS'],$i);
+        $i  = $i + $tmp['OFFSET'];
+        foreach($tmp['STRINGS'] as $str){
+          $this->data .= $str;
         }
       }
     }
-    $this->data = preg_replace("/\"/","",$str);
   }
 
   function get_sieve_script_part()
   {
-    return("reject ".sieve_create_strings($this->data).";\n");
+    return("reject ".sieve_create_strings($this->data).";");
   } 
-    
+
   function execute()
   {
     /* check if this will be a 
@@ -57,9 +62,9 @@ class sieve_reject
     $smarty->assign("Multiline",$Multiline);
     $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
     $object= $smarty->fetch(get_template_path("templates/element_reject.tpl",TRUE,dirname(__FILE__)));
-    $str = preg_replace("/%%OBJECT_CONTENT%%/",$object,$object_container);
+    $str = preg_replace("/%%OBJECT_CONTENT%%/",addcslashes($object,"\\"),$object_container);
     return($str);
   }
 }
-
-
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>