Code

Updated mail acls
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 15 Nov 2006 05:45:45 +0000 (05:45 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 15 Nov 2006 05:45:45 +0000 (05:45 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@5115 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index a05356e81b4ec3775c71e828886083300e224174..14ebe54577effe17b15d48c9ee7d65b2ce68edbc 100644 (file)
@@ -502,12 +502,25 @@ class mailAccount extends plugin
     /* Display mail account tab */
 
     $smarty->assign("mailServers", $mailserver);
-    foreach(array("gosaMailServer", "gosaMailQuota", "perms", "mail",
-          "gosaMailAlternateAddress", "gosaMailForwardingAddress",
-          "gosaVacationMessage", "gosaMailDeliveryMode",
-          "gosaMailMaxSize", "gosaSpamSortLevel", "gosaSpamMailbox") as $val){
-
-      $smarty->assign("$val", $this->$val);
+    foreach(array(
+          "gosaMailServer", 
+          "gosaMailQuota", 
+          "perms", 
+          "mail",
+          "gosaMailAlternateAddress", 
+          "gosaMailForwardingAddress",
+
+          // gosaMailDeliveryMode Flags 
+          "drop_own_mails",                       // No local delivery 
+          "gosaMailMaxSize",                      // Enable - Drop mails > max size
+          "gosaSpamSortLevel", "gosaSpamMailbox", // Enable - Spam sort options
+          "gosaVacationMessage",                  // Enable - Vacation message      
+          "custom_sieve",                         // Use custom sieve script
+          "only_local"                            // Send/receive local mails 
+                                        ) as $val){
+      if(isset($this->$val)){
+        $smarty->assign("$val", $this->$val);
+      }
       $smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
     }
 
@@ -683,32 +696,57 @@ class mailAccount extends plugin
          I: Only insider delivery */
 
       $tmp= "";
-      if (!isset($_POST["drop_own_mails"])){
-        $tmp.= "L";
-      }
-      if (isset($_POST["use_mailsize_limit"])){
-        $tmp.= "R";
-      }
-      if (isset($_POST["use_spam_filter"])){
-        $tmp.= "S";
-      }
-      if (isset($_POST["use_vacation"])){
-        $tmp.= "V";
-      }
-      if (isset($_POST["own_script"])){
-        $tmp.= "C";
+      $Flags = array(
+                     "R"  => array("ACL" => "gosaMailMaxSize",    "POST" => "use_mailsize_limit"),
+                     "V"  => array("ACL" => "gosaVacationMessage","POST" => "use_vacation"),
+                     "C"  => array("ACL" => "custom_sieve",       "POST" => "own_script"),
+                     "I"  => array("ACL" => "only_local",         "POST" => "only_local"));
+
+      /* Check acls and set new value if allowed. 
+         If we do not have permission to change the value 
+          check for the old value and use this */
+      foreach($Flags as $flag => $val){
+        $acl  = $val['ACL'];
+        $post = $val['POST'];
+        if(chkacl($this->acl,$acl) ==""){
+          if (isset($_POST[$post])){
+            $tmp.= $flag;
+          }
+        }else{
+          if(preg_match("/".$flag."/",$this->gosaMailDeliveryMode)){
+            $tmp.= $flag ;
+          }
+        }
       }
-      if (isset($_POST["only_local"])){
-        $tmp.= "I";
+
+      /* ! Inverse flag handling for drop_own_mails */
+      if(chkacl($this->acl,"drop_own_mails") == ""){
+        if (!isset($_POST['drop_own_mails'])){
+          $tmp.= "L";
+        }
+      }else{
+        if(preg_match("/L/",$this->gosaMailDeliveryMode)){
+          $tmp.= "L" ;
+        }
       }
-      $tmp= "[$tmp]";
 
-      if (chkacl ($this->acl, "gosaMailDeliveryMode") == ""){
-        if ($this->gosaMailDeliveryMode != $tmp){
-          $this->is_modified= TRUE;
+      /* If one of these acls are given, we are allowed to enable disable the the spam settings */
+      if(chkacl($this->acl,"gosaSpamMailbox") == "" || chkacl($this->acl,"gosaSpamSortLevel") ==""){
+        if (isset($_POST["use_spam_filter"])){
+          $tmp.= "S";
         }
-        $this->gosaMailDeliveryMode= $tmp;
+      }else{
+        if(preg_match("/S/",$this->gosaMailDeliveryMode)){
+          $tmp.= "S" ;
+        }
+      }
+      
+      /* Check if something has changed an assign new gosaMailDeliveryMode */
+      $tmp= "[$tmp]";
+      if ($this->gosaMailDeliveryMode != $tmp){
+        $this->is_modified= TRUE;
       }
+      $this->gosaMailDeliveryMode= $tmp;
     }
   }
 
index 56bd1e9a58484d46e6538ab7fb7573d9fda4c70d..5e291216b975ebb37fbe971051f69b776bb326df 100644 (file)
@@ -1,3 +1,4 @@
+<input type="submit">
 <table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding="0" border="0">
  <tr>
   <td style="width:50%; vertical-align:top;">
@@ -69,7 +70,7 @@
  <tr style="padding-bottom:0px;">
   <td style="width:50%">
    <input type=checkbox name="drop_own_mails" value="1" {$drop_own_mails}
-       {$gosaMailDeliveryModeACL} title="{t}Select if you want to forward mails without getting own copies of them{/t}"> {t}No delivery to own mailbox{/t}
+       {$drop_own_mailsACL} title="{t}Select if you want to forward mails without getting own copies of them{/t}"> {t}No delivery to own mailbox{/t}
    <br>
    <input type=checkbox name="use_vacation" value="1" {$use_vacation}
        {$gosaVacationMessageACL} title="{t}Select to automatically response with the vacation message defined below{/t}"> {t}Activate vacation message{/t}