Code

Re-imlemented default sieve settings.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 23 Mar 2007 14:08:21 +0000 (14:08 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 23 Mar 2007 14:08:21 +0000 (14:08 +0000)
Added js disable/enable if user_own_script is set.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5874 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/personal/mail/class_mailAccount.inc
plugins/personal/mail/generic.tpl

index 8112406bd8772bd567c9464a1d7e825660e2c1a6..b5ce37d8cc857cfcb2344a3e91e0234b2b510829 100644 (file)
@@ -239,7 +239,7 @@ class mailAccount extends plugin
     /* 
      * Sieve Management 
      */
-    if(isset($_POST['sieveManagement'])) {
+    if(isset($_POST['sieveManagement']) && !preg_match("/C/",$this->gosaMailDeliveryMode)) {
       $this->dialog = new sieveManagement($this->config,$this->dn,$this);
     }
    
@@ -672,56 +672,68 @@ class mailAccount extends plugin
   function save_object()
   {
     if (isset($_POST['mailTab'])){
+
       /* Save ldap attributes */
       plugin::save_object();
 
-      /* Assemble mail delivery mode
-         The mode field in ldap consists of values between braces, this must
-         be called when 'mail' is set, because checkboxes may not be set when
-         we're in some other dialog.
 
-         Example for gosaMailDeliveryMode [LR        ]
-         L: Local delivery
-         R: Reject when exceeding mailsize limit
-         S: Use spam filter
-         V: Use vacation message
-         C: Use custm sieve script
-         I: Only insider delivery */
+      if(isset($_POST['own_script'])){
+
+        if(!preg_match("/C/",$this->gosaMailDeliveryMode)){
+          $str= preg_replace("/[\[\]]/","",$this->gosaMailDeliveryMode);
+          $this->gosaMailDeliveryMode = "[".$str."C]";
+        }
+
+      }else{
+
+        /* Assemble mail delivery mode
+           The mode field in ldap consists of values between braces, this must
+           be called when 'mail' is set, because checkboxes may not be set when
+           we're in some other dialog.
+
+          Example for gosaMailDeliveryMode [LR        ]
+          L: Local delivery
+          R: Reject when exceeding mailsize limit
+          S: Use spam filter
+          V: Use vacation message
+          C: Use custm sieve script
+          I: Only insider delivery */
 
-      $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode);
+        $tmp= preg_replace("/[^a-z]/i","",$this->gosaMailDeliveryMode);
 
 
-      /* Handle delivery flags */
-      if($this->acl_is_writeable("gosaMailDeliveryModeL")){
-        if(!preg_match("/L/",$tmp) && !isset($_POST['only_local'])){
-          $tmp.="L";
-        }elseif(preg_match("/L/",$tmp) && isset($_POST['only_local'])){
-          $tmp = preg_replace("/L/","",$tmp);
+        /* Handle delivery flags */
+        if($this->acl_is_writeable("gosaMailDeliveryModeL")){
+          if(!preg_match("/L/",$tmp) && !isset($_POST['only_local'])){
+            $tmp.="L";
+          }elseif(preg_match("/L/",$tmp) && isset($_POST['only_local'])){
+            $tmp = preg_replace("/L/","",$tmp);
+          }
         }
-      }
 
-      $opts = array(     
-          "R"   => "use_mailsize_limit",
-          "S"   => "use_spam_filter",
-          "V"   => "use_vacation",
-          "C"   => "own_script",
-          "I"   => "drop_own_mails");
-
-      foreach($opts as $flag => $post){
-        if($this->acl_is_writeable("gosaMailDeliveryMode".$flag)){
-          if(!preg_match("/".$flag."/",$tmp) && isset($_POST[$post])){
-            $tmp.= $flag;
-          }elseif(preg_match("/".$flag."/",$tmp) && !isset($_POST[$post])){
-            $tmp = preg_replace("/".$flag."/","",$tmp);
+        $opts = array(     
+            "R"   => "use_mailsize_limit",
+            "S"   => "use_spam_filter",
+            "V"   => "use_vacation",
+            "C"   => "own_script",
+            "I"   => "drop_own_mails");
+
+        foreach($opts as $flag => $post){
+          if($this->acl_is_writeable("gosaMailDeliveryMode".$flag)){
+            if(!preg_match("/".$flag."/",$tmp) && isset($_POST[$post])){
+              $tmp.= $flag;
+            }elseif(preg_match("/".$flag."/",$tmp) && !isset($_POST[$post])){
+              $tmp = preg_replace("/".$flag."/","",$tmp);
+            }
           }
         }
-      }
 
-      $tmp= "[$tmp]";
-      if ($this->gosaMailDeliveryMode != $tmp){
-        $this->is_modified= TRUE;
+        $tmp= "[$tmp]";
+        if ($this->gosaMailDeliveryMode != $tmp){
+          $this->is_modified= TRUE;
+        }
+        $this->gosaMailDeliveryMode= $tmp;
       }
-      $this->gosaMailDeliveryMode= $tmp;
     }
   }
 
index 1116201be02a4235592e3163f3f55635dbc9613b..238e3628d37440ce8bd93a87e63c53a7cba0f8a6 100644 (file)
   </td>
  </tr>
 </table>
-
+<!-- SIEVE -->
 <p class="seperator">&nbsp;</p>
 <h2><img class="center" alt="" align="middle" src="images/envelope.png" />&nbsp;{t}Mail options{/t}</h2>
-<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4 border=0>
+<table summary="" style="vertical-align:top; text-align:left;" cellpadding=4 border=0>
+ <tr>
+  <td>
+{render acl=$gosaMailDeliveryModeCACL}
+   <input type=checkbox name="own_script" value="1" {$own_script} 
+               onClick="       
+                       changeState('sieveManagement');
+                       changeState('drop_own_mails');
+                       changeState('use_vacation');
+                       changeState('use_spam_filter');
+                       changeState('use_mailsize_limit');
+                       changeState('import_vacation');
+                       changeState('forward_address');
+                       changeState('add_forwarder');
+                       changeState('add_local_forwarder');
+                       changeState('delete_forwarder');
+                       changeState('only_local');
+                       changeState('gosaVacationMessage');
+                       changeState('gosaSpamSortLevel');
+                       changeState('gosaSpamMailbox');
+                       changeState('gosaMailMaxSize');
+                       
+               "
+
+> {t}Use custom sieve script{/t} <b>({t}disables all Mail options!{/t})</b>
+{/render}
+  </td>
+ </tr>
  <tr>
   <td> 
-   <input type='submit' name='sieveManagement' value='{t}Sieve Management{/t}'>
+   <input {if $own_script == ""} disabled {/if} id='sieveManagement' type='submit' name='sieveManagement' value='{t}Sieve Management{/t}'>
   </td>
  </tr>
 </table>
+
+
+<p class="seperator">&nbsp;</p>
 <table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4 border=0>
  <tr style="padding-bottom:0px;">
   <td style="width:50%">
 {render acl=$gosaMailDeliveryModeIACL}
-   <input type=checkbox name="drop_own_mails" value="1" {$drop_own_mails} title="{t}Select if you want to forward mails without getting own copies of them{/t}"> {t}No delivery to own mailbox{/t}
+   <input {if $own_script != ""} disabled {/if} id='drop_own_mails' type=checkbox name="drop_own_mails" value="1" {$drop_own_mails} title="{t}Select if you want to forward mails without getting own copies of them{/t}"> {t}No delivery to own mailbox{/t}
 {/render}
    <br>
 {render acl=$gosaMailDeliveryModeVACL}
-   <input type=checkbox name="use_vacation" value="1" {$use_vacation} title="{t}Select to automatically response with the vacation message defined below{/t}"> {t}Activate vacation message{/t}
+   <input {if $own_script != ""} disabled {/if} id='use_vacation' type=checkbox name="use_vacation" value="1" {$use_vacation} title="{t}Select to automatically response with the vacation message defined below{/t}"> {t}Activate vacation message{/t}
 {/render}
   </td>
    <td rowspan=2 style="border-left:1px solid #A0A0A0">
   </td>
   <td style="vertical-align:top;">
 {render acl=$gosaMailDeliveryModeSACL}
-   <input type=checkbox name="use_spam_filter" value="1" {$use_spam_filter} title="{t}Select if you want to filter this mails through spamassassin{/t}">
+   <input {if $own_script != ""} disabled {/if} id='use_spam_filter' type=checkbox name="use_spam_filter" value="1" {$use_spam_filter} title="{t}Select if you want to filter this mails through spamassassin{/t}">
 {/render}
  <label for="gosaSpamSortLevel">{t}Move mails tagged with spam level greater than{/t}</label>
        
 {render acl=$gosaSpamSortLevelACL}
-   <select id="gosaSpamSortLevel" size="1" name="gosaSpamSortLevel" title="{t}Choose spam level - smaller values are more sensitive{/t}">
+   <select {if $own_script != ""} disabled {/if} id="gosaSpamSortLevel" size="1" name="gosaSpamSortLevel" title="{t}Choose spam level - smaller values are more sensitive{/t}">
         {html_options values=$spamlevel output=$spamlevel selected=$gosaSpamSortLevel}
    </select>
 {/render}
    <label for="gosaSpamMailbox">{t}to folder{/t}</label>
 {render acl=$gosaSpamMailboxACL}
-   <select size="1" id="gosaSpamMailbox" name="gosaSpamMailbox">
+   <select {if $own_script != ""} disabled {/if} size="1" id="gosaSpamMailbox" name="gosaSpamMailbox">
                {html_options values=$spambox output=$spambox selected=$gosaSpamMailbox}
                        <option disabled>&nbsp;</option>
    </select>
 {/render}
    <br>
 {render acl=$gosaMailDeliveryModeRACL}
-   <input type=checkbox name="use_mailsize_limit" value="1" {$use_mailsize_limit} >
+   <input {if $own_script != ""} disabled {/if} id='use_mailsize_limit' type=checkbox name="use_mailsize_limit" value="1" {$use_mailsize_limit} >
 {/render}
        <label for="gosaMailMaxSize">{t}Reject mails bigger than{/t}</label> 
 {render acl=$gosaMailMaxSizeACL}
-   <input id="gosaMailMaxSize" name="gosaMailMaxSize" size="6" align="middle" maxlength="30" value="{$gosaMailMaxSize}"> {t}MB{/t}
+   <input {if $own_script != ""} disabled {/if} id="gosaMailMaxSize" name="gosaMailMaxSize" size="6" align="middle" maxlength="30" value="{$gosaMailMaxSize}"> {t}MB{/t}
 {/render}
   </td>
  </tr>
     <b><label for="gosaVacationMessage">{t}Vacation message{/t}</label></b>
    </p>
 {render acl=$gosaVacationMessageACL}
-   <textarea id="gosaVacationMessage" style="width:99%; height:100px;" name="gosaVacationMessage" rows="4" cols="512">{$gosaVacationMessage}</textarea>
+   <textarea {if $own_script != ""} disabled {/if} id="gosaVacationMessage" style="width:99%; height:100px;" name="gosaVacationMessage" rows="4" cols="512">{$gosaVacationMessage}</textarea>
 {/render}
    <br>
 
    {if $show_templates eq "true"}
 {render acl=$gosaVacationMessageACL}
-   <select name="vacation_template">
+   <select name="vacation_template" {if $own_script != ""} disabled {/if}>
                {html_options options=$vacationtemplates selected=$template}
                <option disabled>&nbsp;</option>
    </select>
 {/render}
 {render acl=$gosaVacationMessageACL}
-   <input type="submit" value="{t}Import{/t}" name="import_vacation">
+   <input {if $own_script != ""} disabled {/if} id='import_vacation' type="submit" value="{t}Import{/t}" name="import_vacation">
 {/render}
    {/if}
   </td>
     <b><label for="forwarder_list">{t}Forward messages to{/t}</label></b>
    </p>
 {render acl=$gosaMailForwardingAddressACL}
-   <select id="gosaMailForwardingAddress" style="width:100%; height:100px;" name="forwarder_list[]" size=15 multiple >
+   <select id="gosaMailForwardingAddress" style="width:100%; height:100px;" name="forwarder_list[]" size=15 multiple {if $own_script != ""} disabled {/if}>
                        {html_options values=$gosaMailForwardingAddress output=$gosaMailForwardingAddress selected=$template}        
                        <option disabled>&nbsp;</option>
    </select>
 {/render}
    <br>
 {render acl=$gosaMailForwardingAddressACL}
-   <input name="forward_address" size=20 align="middle" maxlength=65 value="">
+   <input {if $own_script != ""} disabled {/if} id='forward_address' name="forward_address" size=20 align="middle" maxlength=65 value="">
 {/render}
 {render acl=$gosaMailForwardingAddressACL}
-   <input type="submit" value="{t}Add{/t}" name="add_forwarder" >&nbsp;
+   <input {if $own_script != ""} disabled {/if} id='add_forwarder' type="submit" value="{t}Add{/t}" name="add_forwarder" >&nbsp;
 {/render}
 {render acl=$gosaMailForwardingAddressACL}
-   <input type="submit" value="{t}Add local{/t}" name="add_local_forwarder" >&nbsp;
+   <input {if $own_script != ""} disabled {/if} id='add_local_forwarder' type="submit" value="{t}Add local{/t}" name="add_local_forwarder" >&nbsp;
 {/render}
 {render acl=$gosaMailForwardingAddressACL}
-   <input type="submit" value="{t}Delete{/t}" name="delete_forwarder">
+   <input {if $own_script != ""} disabled {/if} id='delete_forwarder' type="submit" value="{t}Delete{/t}" name="delete_forwarder">
 {/render}
   </td>
  </tr>
  <tr>
   <td>
 {render acl=$gosaMailDeliveryModeLACL}
-   <input type=checkbox name="only_local" value="1" {$only_local} title="{t}Select if user can only send and receive inside his own domain{/t}">
+   <input {if $own_script != ""} disabled {/if} id='only_local' type=checkbox name="only_local" value="1" {$only_local} title="{t}Select if user can only send and receive inside his own domain{/t}">
 {/render}
    {t}User is only allowed to send and receive local mails{/t}
   </td>
   <td style="border-left:1px solid #A0A0A0">
    &nbsp;
   </td>
-  <td>
-
-{render acl=$gosaMailDeliveryModeCACL}
-   <input type=checkbox name="own_script" value="1" {$own_script}> {t}Use custom sieve script{/t} <b>({t}disables all Mail options!{/t})</b>
-{/render}
-  </td>
  </tr>
 </table>