Code

text: tags are allowed now.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 8 Mar 2007 13:54:42 +0000 (13:54 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 8 Mar 2007 13:54:42 +0000 (13:54 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5759 594d385d-05f5-0310-b6e9-bd551577e9d8

include/sieve/class_My_Tree.inc
include/sieve/class_scanner.inc
include/sieve/class_semantics.inc
include/sieve/class_sieveElements.inc
include/sieve/class_sieveManagement.inc
include/sieve/templates/element_reject.tpl

index 28ac518bd9bce6075f48a2356254bce04d4ed3d5..9499fd6416135bd576254eef51f8dda75ea26fc9 100644 (file)
@@ -149,24 +149,32 @@ class My_Tree extends Tree
   {
     $tmp ="";
     if(count($this->pap)){
-      $tmp = "#Generated by GOsa - Gonicus System Administrator\n";
       $buffer = "";    
       foreach($this->pap as $part)  {
         if(get_class($part) == "sieve_block_end"){
           $buffer = substr($buffer,0,strlen($buffer)-(strlen(SIEVE_INDENT_TAB)));
         }
         $tmp2 = $part->get_sieve_script_part();
-        $tmp3 = split("\n",$tmp2);
-        foreach($tmp3 as $str){
-          $str2 = trim($str);
-          if(empty($str2)) continue;
-          $tmp.= $buffer.$str."\n";
+
+        if(get_class($part) == "sieve_reject"){
+          $tmp.=$tmp2;
+        }else{
+
+          $tmp3 = split("\n",$tmp2);
+          foreach($tmp3 as $str){
+            $str2 = trim($str);
+            if(empty($str2)) continue;
+            $tmp.= $buffer.$str."\n";
+          }
         }
         if(get_class($part) == "sieve_block_start"){
           $buffer .= SIEVE_INDENT_TAB;
         }
       }
     }
+    if(!preg_match("/Generated by GOsa - Gonicus System Administrator/",$tmp)){
+      $tmp = "#Generated by GOsa - Gonicus System Administrator \n ".$tmp;
+    }
     return($tmp);
   }
 }
@@ -195,9 +203,19 @@ function sieve_create_strings($data)
       $ret = "[".$ret."]";
     }
   }else{
-    $ret = "\"".$data."\"";
+
+    $Multiline = preg_match("/\n/",$data);
+    $data = preg_replace("/\r/","",$data);;
+
+    if($Multiline){
+      $ret = "text: \r\n".$data."\r\n.\r\n";
+    }else{
+      $ret = "\"".$data."\"";
+    }
   }
   $ret = preg_replace("/\"\"/","\"",$ret);
+  $ret = preg_replace("/\n/","\r\n",$ret);
+  
   return($ret);
 }
 
index 3e22bb1d0ee8c6a3a2aae7b6662fa35da5e54a50..2a7fc37d2e77a0b7aec019bc1cdeeb4293a679d3 100644 (file)
@@ -58,7 +58,6 @@ class Scanner
                                }
                        }
                }
-
                array_push($this->tokens_, array(
                        'class' => 'script-end',
                        'text'  => 'script-end',
@@ -131,10 +130,11 @@ class Scanner
                'quoted-string'  =>  '"(?:\\[\\"]|[^\x00"])*"',
                'number'         =>  '[[:digit:]]+(?:[KMG])?(?=\b)',
                'comment'        =>  '(?:\/\*(?:[^\*]|\*(?=[^\/]))*\*\/|#[^\r\n]*\r?\n)',
-               'multi-line'     =>  'text:[ \t]*(?:#[^\r\n]*)?\r?\n(\.[^\r\n]+\r?\n|[^\.]*\r?\n)*\.\r?\n',
+#              'multi-line'     =>  'text:[ \t]*(?:#[^\r\n]*)?\r?\n(\.[^\r\n]+\r?\n|[^\.]*\r?\n)*\.\r?\n',
+               'multi-line'     =>  'text:[^;]*',
                'identifier'     =>  '[[:alpha:]_][[:alnum:]_]*(?=\b)',
                'unknown token'  =>  '[^ \r\n\t]+'
        );
 }
 
-?>
\ No newline at end of file
+?>
index 80e893ebc9bb6af397d74229fc87ed3ca939f026..e37d5c6313541234afa95c7d207867dbcef42ea4 100644 (file)
@@ -126,7 +126,7 @@ class Semantics
                                'valid_after' => array('require', 'if', 'elsif', 'else', 'reject', 'fileinto', 'redirect', 'stop', 'keep', 'discard'),
                                'arguments' => array(
                                        array('class' => 'string', 'occurrences' => '1', 'values' => array(
-                                               array('occurrences' => '1', 'regex' => '".*"', 'name' => 'reason')
+                                               array('occurrences' => '1', 'regex' => '.*', 'name' => 'reason')
                                        ))
                                )
                        );
index 42ab948f9b8808a7a7d07ad8da3066fad90bbb62..199e03bc7cd8381a82cfa435fa645828c8d85e72 100644 (file)
@@ -147,6 +147,7 @@ class sieve_reject
   var $data = array();
   var $object_id = -1;
 
+
   function save_object()
   {
     if(isset($_POST['reject_message_'.$this->object_id])){
@@ -161,8 +162,14 @@ class sieve_reject
     $this->object_id = $object_id;
     $str = "";
     foreach($data['ELEMENTS'] as $node ){
-      if(in_array($node['class'],array("quoted-string","text"))){
-        $str .= $node['text'];
+      if(in_array($node['class'],array("quoted-string","text","multi-line"))){
+
+        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'];
+        }
       }
     }
     $this->data = preg_replace("/\"/","",$str);
@@ -170,13 +177,20 @@ class sieve_reject
 
   function get_sieve_script_part()
   {
-    return("reject ".sieve_create_strings($this->data)."\n");
+    return("reject ".sieve_create_strings($this->data).";\n");
   } 
     
   function execute()
   {
+    /* check if this will be a 
+     *   - single string ""
+     *   - or a multi line text: ... ; 
+     */
+    $Multiline = preg_match("/\n/",$this->data);
+
     $smarty = get_smarty();
     $smarty->assign("ID",$this->object_id);
+    $smarty->assign("Multiline",$Multiline);
     $smarty->assign("Message",$this->data);
     return($smarty->fetch(get_template_path("templates/element_reject.tpl",TRUE,dirname(__FILE__))));    
   }
@@ -201,6 +215,7 @@ class sieve_redirect
     }
   }
 
+
   function sieve_redirect($data,$object_id)
   {
     foreach($data['ELEMENTS'] as $node ){
@@ -210,17 +225,19 @@ class sieve_redirect
     }
   }
 
+
   function get_sieve_script_part()
   {
     $tmp = "";
     foreach($this->data as $dat){
       $tmp.= "\"".$dat."\", ";
     }
-    $tmp = "[".preg_replace("/,$/","",trim($tmp))."]";
+    $tmp = preg_replace("/,$/","",trim($tmp));
     $tmp = preg_replace ("/\"\"/","\"",$tmp);
-    return("redirect ".$tmp."\n");
+    return("redirect ".$tmp.";\n");
   } 
-    
+   
   function execute()
   {
     $values = "";
@@ -271,9 +288,9 @@ class sieve_fileinto
     foreach($this->data as $dat){
       $tmp.= "\"".$dat."\", ";
     }
-    $tmp = "[".preg_replace("/,$/","",trim($tmp))."]";
+    $tmp = preg_replace("/,$/","",trim($tmp));
     $tmp = preg_replace ("/\"\"/","\"",$tmp);
-    return("fileinto ".$tmp."\n");
+    return("fileinto ".$tmp.";\n");
   } 
     
   function execute()
@@ -364,8 +381,8 @@ class sieve_vacation
     if($this->mime){
       $str.= ":mime ".sieve_create_strings($this->mime);
     }
-    $str .= " ".sieve_create_strings($this->reason);
-    return($str."\n");
+    $str .= "\n ".sieve_create_strings($this->reason);
+    return($str." ; \n");
   } 
     
   
index 4784011debc98d82186e748fdbf6297acc7882a3..ea355b2e3937a2c08108555cc388d385942807ab 100644 (file)
@@ -94,7 +94,7 @@ class sieveManagement extends plugin
       $ret = $p->parse($script);
       if(!$ret){
         $this->scripts[$key]['MSG']   = "<font color='red'>".$p->status_text."</font>";
-        $this->scripts[$key]['STATUS'] = _("Parse failed");
+        $this->scripts[$key]['STATUS'] = _("Parse failed")."<font color='red'>".$p->status_text."</font>";
       }else{
         $this->scripts[$key]['STATUS'] = _("Parse successful");
       }
@@ -300,7 +300,7 @@ class sieveManagement extends plugin
     foreach($this->scripts as $key => $script){
       if($script['EDITED']){
         $data = $script['PARSER']->get_sieve_script();
-        if(!$this->sieve_handle->sieve_sendscript($script['NAME']."1", $data)){
+        if(!$this->sieve_handle->sieve_sendscript($script['NAME'], $data)){
           gosa_log("Failed to save sieve script named '".$script['NAME']."': ".to_string($this->sieve_handle->error_raw));
           $everything_went_fine = FALSE;
           print_red(to_string($this->sieve_handle->error_raw));
index 28483346f8988b579db87444d01e3cfbd1bccff3..f5cd572a66aa3920ab16481bf51d18a9fd602c63 100644 (file)
@@ -3,11 +3,16 @@
                <td style='width:100%;'>
                        <b>{t}Reject mail{/t}</b>
                        &nbsp;
+                       {if $Multiline}
+                               {t}This will be a multiline text element{/t}
+                       {else}
+                               {t}this will be stored as single string{/t}
+                       {/if}
                </td>
        </tr>
        <tr>
                <td style='padding-left:20px;'>
-                       <textarea name='reject_message_{$ID}' style='width:100%'>{$Message}</textarea>
+                       <textarea name='reject_message_{$ID}' style='width:100%;height:100px;' >{$Message}</textarea>
                </td>
        </tr>
 </table>