Code

Some sieve filter changes
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 15 Mar 2007 09:51:45 +0000 (09:51 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 15 Mar 2007 09:51:45 +0000 (09:51 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5785 594d385d-05f5-0310-b6e9-bd551577e9d8

include/sieve/class_sieveElement_If.inc
include/sieve/class_sieveElement_Reject.inc
include/sieve/class_sieveElement_Vacation.inc
include/sieve/templates/element_vacation.tpl

index d9a70f3b9084bb41fb45d63bbc11c79f23c1bd95..1663fdf4082e6a170803552d1a6024f97f610921 100644 (file)
@@ -106,6 +106,17 @@ class sieve_if
           }
           break;
         }
+
+        /*******************
+         * True / False
+         *******************/
+
+        case "true" :
+        case "fasle" : 
+        {
+          /* Can't fail anyway */
+          break;
+        }
     
         /*******************
          * Default
@@ -115,8 +126,6 @@ class sieve_if
         {
           if(isset($data['LastError']) && !empty($data['LastError'])){
             $ret[] = $data['LastError'];
-      
-            echo "'".$data['LastError']."' ".$key."<br>" ;
           }
         }
       }
index e930456fd8a0dd69c851f410f2629177526756ed..6c0a6f5b6472e79db98467dc77837dfb36886bb7 100644 (file)
@@ -2,7 +2,7 @@
 
 class sieve_reject 
 {
-  var $data = array();
+  var $data = "";
   var $object_id = -1;
 
 
@@ -23,26 +23,37 @@ class sieve_reject
   function sieve_reject($data,$object_id)
   {
     $this->object_id = $object_id;
-    $str = "";
-    foreach($data['ELEMENTS'] as $node ){
-      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'];
+    /* 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{
+
+      /* Get reject text */
+      $str = "";
+      foreach($data['ELEMENTS'] as $node ){
+        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);
     }
-    $this->data = preg_replace("/\"/","",$str);
   }
 
   function get_sieve_script_part()
   {
     return("reject ".sieve_create_strings($this->data).";\n");
   } 
-    
+
   function execute()
   {
     /* check if this will be a 
@@ -61,5 +72,5 @@ class sieve_reject
     return($str);
   }
 }
-
-
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
index ec3250d4842c526a10c69678ea111c037f010c51..f2a562fcaaf518ccc820a70de711c825c734d129 100644 (file)
@@ -69,9 +69,12 @@ class sieve_vacation
     if($this->days){
       $str.= ":days ".$this->days;
     }
-    $str .= ":addresses ".sieve_create_strings($this->addresses);
-    if($this->subject){
-      $str.= ":subject ".sieve_create_strings($this->subject);
+
+    if(count($this->addresses)){
+      $str .= ":addresses ".sieve_create_strings($this->addresses);
+      if($this->subject){
+        $str.= ":subject ".sieve_create_strings($this->subject);
+      }
     }
     if($this->mime){
       $str.= ":mime ".sieve_create_strings($this->mime);
@@ -98,7 +101,10 @@ class sieve_vacation
       $tmp = array();
       $tmp2 = split(",",$vr);
       foreach($tmp2 as $val){
-        $tmp[] = "\"".trim(preg_replace("/\"/","",$val))."\"";
+        $ad = trim(preg_replace("/\"/","",$val));
+        if(!empty($ad)){
+          $tmp[] = "\"".$ad."\"";
+        }
       }
       $this->addresses = $tmp;
     }
@@ -112,7 +118,17 @@ class sieve_vacation
 
   function check()
   {
-    return(array())  ;
+    $msgs = array();
+    $err = FALSE;
+    foreach($this->addresses as $addr){
+      if(!is_email(preg_replace("/\"/","",$addr))){
+        $err = true;
+      }
+    }
+    if($err){
+      $msgs[] = _("Alternative sender addresse must be valid email addresses.");
+    }
+    return($msgs);
   }
 
   function execute()
@@ -124,6 +140,8 @@ class sieve_vacation
     $Addresses = preg_replace("/,$/","",trim($Addresses));
 
     $smarty = get_smarty();
+    $smarty->assign("LastError",$this->check());
+    $smarty->assign("LastErrorCnt",count($this->check()));
     $smarty->assign("Reason",$this->reason);
     $smarty->assign("Addresses",$Addresses);
     $smarty->assign("Subject",$this->subject);
index ed6e2b0727e340bc440ac6085da60676a3a17d5b..837267805c6d2e852501d52bd2170dadcfb42450 100644 (file)
@@ -1,7 +1,22 @@
 
+{if $LastErrorCnt != 0}
+    <table style='width:100%;'>
+        <tr>
+            <td style='width:40px; background-color: #FF0000; text-align:center; border: dotted 3px #ff7c1c'>
+                <img src='images/warning.png' alt='{t}Error{/t}'>
+            </td>
+            <td>
+{/if}
 <table cellspacing=0 cellpadding=2 style='background-color:#EEEEDD;width:100%; border: solid 1px #CCCCCC'>
 
+       {foreach from=$LastError item=val key=key}
+               <tr>
+                       <td colspan=4>
+                               <font color='red'><b>{$LastError[$key]}</b></font>
+                       </td>
+               </tr>
 
+       {/foreach}
        {if $Expert}
        <tr>
                <td style='width:20%'>  
@@ -22,7 +37,7 @@
        </tr>
        <tr>
                <td>
-                       {t}Receiver{/t}
+                       {t}Alternative sender addresses{/t}
                </td>
                <td>
                <textarea name='vacation_receiver_{$ID}' style='width:100%;height:20px;'>{$Addresses}</textarea>
        {/if}
 </table>
 
+{if $LastErrorCnt != 0}
+
+            </td>
+        </tr>
+    </table>
+{/if}
+
+