Code

Initial ACL fixes for group/mail, not finished yet
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 30 Aug 2006 08:02:10 +0000 (08:02 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 30 Aug 2006 08:02:10 +0000 (08:02 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4540 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/groups/class_groupMail.inc
plugins/admin/groups/mail.tpl

index 9d6797aaa59f20515537ea1831226a92b6382e92..e79a7d71ff92502e31e0ffcbd99f6fccaceb1c25 100644 (file)
@@ -295,6 +295,15 @@ class mailgroup extends plugin
 
     /* Load templating engine */
     $smarty= get_smarty();
+
+    /* Assign acls */
+    $tmp = $this->plInfo();
+    foreach($tmp['plProvidedAcls'] as $name => $translation) {
+      $smarty->assign($name."ACL",$this->getacl($name));
+    }
+
+
+
     if ($_SESSION['js']==FALSE){
       $smarty->assign("javascript", "false");
     } else {
@@ -350,8 +359,7 @@ class mailgroup extends plugin
 
     /* Finished adding of locals? */
     if (isset($_POST['add_locals_finish'])){
-      if (count ($_POST['local_list']) &&
-          chkacl ($this->acl, "gosaMailForwardingAddress") == ""){
+      if (count ($_POST['local_list']) && $this->acl_is_writeable("gosaMailForwardingAddress")){
 
         /* Walk through list of forwarders, ignore own addresses */
         foreach ($_POST['local_list'] as $val){
@@ -385,7 +393,7 @@ class mailgroup extends plugin
         } else {
 
           /* Add it */
-          if (chkacl ($this->acl, "gosaMailForwardingAddress") == ""){
+          if ($this->acl_is_writeable("gosaMailForwardingAddress")){
             $this->addForwarder ($address);
           }
 
@@ -395,8 +403,7 @@ class mailgroup extends plugin
 
     /* Delete forward email addresses */
     if (isset($_POST['delete_forwarder'])){
-      if (count($_POST['forwarder_list'])
-          && chkacl ($this->acl, "gosaMailForwardingAddress") == ""){
+      if (count($_POST['forwarder_list'])&& $this->acl_is_writeable("gosaMailForwardingAddress")){
 
         $this->delForwarder ($_POST['forwarder_list']);
       }
@@ -404,8 +411,7 @@ class mailgroup extends plugin
 
     /* Add alternate email addresses */
     if (isset($_POST['add_alternate'])){
-      if ($_POST['alternate_address'] != "" &&
-          chkacl ($this->acl, "gosaMailAlternateAddress") == ""){
+      if ($_POST['alternate_address'] != "" && $this->acl_is_writeable("gosaMailAlternateAddress")){
 
         if (!is_email($_POST['alternate_address'])){
           print_red (_("You're trying to add an invalid email address to the list of alternate addresses."));
@@ -421,8 +427,7 @@ class mailgroup extends plugin
 
     /* Delete alternate email addresses */
     if (isset($_POST['delete_alternate']) && isset ($_POST['alternates_list'])){
-      if (count($_POST['alternates_list']) &&
-          chkacl ($this->acl, "gosaMailAlternateAddress") == ""){
+      if (count($_POST['alternates_list']) && $this->acl_is_writeable("gosaMailAlternateAddress")){
 
         $this->delAlternate ($_POST['alternates_list']);
       }
@@ -507,7 +512,6 @@ class mailgroup extends plugin
     }
 
     /* Assemble normal permissions */
-    $smarty->assign("permissionsACL", chkacl($this->acl, "permissions"));
     if (isset($this->imapacl['anyone'])){
       $smarty->assign("default_permissions", $this->imapacl['anyone']);
     }
@@ -517,31 +521,54 @@ class mailgroup extends plugin
     }
 
     /* Assemble extra attributes */
-    $perm= chkacl($this->acl, "permissions");
+    $perm= $this->getacl( "permissions");
     $tmp= "";
     $nr= 0;
     $count= count($this->imapacl);
     $this->indexed_user= array();
     $this->indexed_acl= array();
     foreach($this->imapacl as $user => $acl){
+
+      /* Add additional acl settings */
       if ($user != "anyone" && $user != "%members%"){
-        $tmp.= "<tr><td><input name=\"user_$nr\" size=20 maxlength=60 ".
-          "value=\"$user\" $perm></td><td><select size=\"1\" name=\"perm_$nr\" $perm>";
-        foreach ($this->perms as $key => $value){
-          if ($acl == $key){
-            $tmp.= "<option value=$key selected>$value</option>";
-          } else {
-            $tmp.= "<option value=$key>$value</option>";
+
+        $Dis  = "";
+        if(!preg_match("/w/",$perm)){
+          $Dis = " disabled ";
+        }
+  
+        $tmp.= "<tr>  
+                 <td>
+                  <input name=\"user_$nr\" size=20 maxlength=60 value=\"$user\" ".$Dis.">
+                 </td>
+                 <td>
+                 <select size=\"1\" name=\"perm_$nr\" ".$Dis.">";
+
+        /* Add acl options for this additional acl setting */
+        if(preg_match("/r/",$perm)){
+          foreach ($this->perms as $key => $value){
+            if ($acl == $key){
+              $tmp.= "<option value=$key selected>$value</option>";
+            } else {
+              $tmp.= "<option value=$key>$value</option>";
+            }
           }
         }
         $tmp.= "</select>&nbsp;";
+
+
+        
         if ($nr == $count - 1){
-          $tmp.= "<input type=submit value=\""._("Add")."\" ".
-            "name=\"add_$nr\" $perm>";
+          if($this->acl_is_writeable("acl")){
+            $tmp.= "<input type=submit value=\""._("Add")."\" ".
+              "name=\"add_$nr\" $perm>";
+          }
         }
         if ($count > 3){
-          $tmp.= "<input type=submit value=\""._("Remove")."\" ".
-            "name=\"del_$nr\" $perm></td></tr>";
+          if($this->acl_is_writeable("acl")){
+            $tmp.= "<input type=submit value=\""._("Remove")."\" ".
+              "name=\"del_$nr\" $perm></td></tr>";        
+          }
         }
       }
       $this->indexed_user[$nr]= $user;
@@ -558,11 +585,15 @@ class mailgroup extends plugin
     foreach(array("gosaMailServer", "gosaMailQuota", "perms", "mail",
           "gosaMailAlternateAddress", "gosaMailForwardingAddress") as $val){
       $smarty->assign("$val", $this->$val);
-      $smarty->assign("$val"."ACL", chkacl($this->acl, "$val"));
     }
     if (is_numeric($this->gosaMailQuota) && $this->gosaMailQuota != 0){
-      $smarty->assign("quotausage", progressbar(round(($this->quotaUsage * 100)/ $this->gosaMailQuota),100,15,true));
-      $smarty->assign("quotadefined", "true");
+      if($this->acl_is_readable("gosaMailQuota")){
+        $smarty->assign("quotausage", progressbar(round(($this->quotaUsage * 100)/ $this->gosaMailQuota),100,15,true));
+        $smarty->assign("quotadefined", "true");
+      }else{
+        $smarty->assign("quotadefined", "true");
+        $smarty->assign("quotausage", "-");
+      }
     } else {
       $smarty->assign("quotadefined", "false");
     }
@@ -657,12 +688,12 @@ I: Only insider delivery */
       }
       $tmp= "[$tmp]";
 
-      if (chkacl ($this->acl, "gosaMailDeliveryMode") == ""){
+      if ($this->getacl("gosaMailDeliveryMode")){
         $this->gosaMailDeliveryMode= $tmp;
       }
 
       /* Collect data and re-assign it to the imapacl array */
-      if (chkacl($this->acl, "permissions") == ""){
+      if ($this->acl_is_writeable("permissions")){
         $this->imapacl= array();
         $this->imapacl['%members%']= $_POST['member_permissions'];
         $this->imapacl['anyone']= $_POST['default_permissions'];
@@ -812,7 +843,7 @@ I: Only insider delivery */
     }
   
     /* Check quota */
-    if ($this->gosaMailQuota != '' && chkacl ($this->acl, "gosaMailQuota") == ""){
+    if ($this->gosaMailQuota != '' && $this->acl_is_writeable("gosaMailQuota")){
       if (!is_numeric($this->gosaMailQuota)) {
         $message[]= _("Value in 'Quota size' is not valid.");
       } else {
@@ -821,7 +852,7 @@ I: Only insider delivery */
     }
 
     /* Check rejectsize for integer */
-    if ($this->gosaMailMaxSize != '' && chkacl ($this->acl, "gosaMailQuota") == ""){
+    if ($this->gosaMailMaxSize != '' && $this->acl_is_writeable("gosaMailQuota")){
       if (!is_numeric($this->gosaMailMaxSize)){
         $message[]= _("Please specify a vaild mail size for mails to be rejected.");
       } else {
index f7347f5ec8c6d5452b8ef584f0cf67ebfbc58020..243601e9b535586309d1690b56cd803bc85057fd 100644 (file)
@@ -8,15 +8,21 @@
    <table summary="">
     <tr>
      <td><LABEL for="mail">{t}Primary address{/t}</LABEL>{$must}</td>
-     <td><input id="mail" name="mail" size="25" maxlength="65" {$mailACL} value="{$mail}" title="{t}Primary mail address for this shared folder{/t}"></td>
+     <td>
+{render acl=$mailACL}
+       <input id="mail" name="mail" size="25" maxlength="65" value="{$mail}" title="{t}Primary mail address for this shared folder{/t}">
+{/render}
+     </td>
     </tr>
     <tr>
      <td><LABEL for="gosaMailServer">{t}Server{/t}</LABEL></td>
      <td>
-      <select size="1" name="gosaMailServer" {$gosaMailServerACL} title="{t}Select mail server to place user on{/t}">
+{render acl=$gosaMailServerACL}
+      <select size="1" name="gosaMailServer" title="{t}Select mail server to place user on{/t}">
        {html_options values=$mailServers output=$mailServers selected=$gosaMailServer}
           <option disabled>&nbsp;</option>
       </select>
+{/render}
      </td>
     </tr>
     <tr>
      </td>
      <td>
       <br>
-      {if $quotadefined eq "true"}
-      {$quotausage}
-      {else}
-      {t}not defined{/t}
-      {/if}
+{if $quotadefined eq "true"}
+       {$quotausage}
+{else}
+       {t}not defined{/t}
+{/if}
      </td>
     </tr>
     <tr>
      <td>{t}Quota size{/t}</td>
-     <td><input id="gosaMailQuota" name="gosaMailQuota" size="6" align=middle maxlength="30" {$gosaMailQuotaACL} value="{$gosaMailQuota}"> MB</td>
+     <td>
+{render acl=$gosaMailQuotaACL}
+       <input id="gosaMailQuota" name="gosaMailQuota" size="6" align=middle maxlength="30" value="{$gosaMailQuota}">
+{/render}
+ {t}MB{/t}
+</td>
     </tr>
    </table>
      
   </td>
   <td style="vertical-align:top;padding-left:2px;">
    <h2><img class="center" alt="" align="middle" src="images/alternatemail.png"> {t}Alternative addresses{/t}</h2>
+
+{render acl=$gosaMailAlternateAddressACL}
    <select style="width:100%;" name="alternates_list[]" size=10 multiple title="{t}List of alternative mail addresses{/t}">
     {html_options values=$gosaMailAlternateAddress output=$gosaMailAlternateAddress}
        <option disabled>&nbsp;</option>
    </select>
+{/render}
+
    <br>
-   <input name="alternate_address" size="30" align=middle maxlength="60" {$gosaMailAlternateAddressACL} value="">
-   <input type=submit value="{t}Add{/t}" name="add_alternate" {$gosaMailAlternateAddressACL}>&nbsp;
-   <input type=submit value="{t}Delete{/t}" name="delete_alternate" {$gosaMailAlternateAddressACL}>
+
+{render acl=$gosaMailAlternateAddressACL}
+   <input name="alternate_address" size="30" align=middle maxlength="60" value="">
+{/render}
+
+{render acl=$gosaMailAlternateAddressACL}
+   <input type=submit value="{t}Add{/t}" name="add_alternate">&nbsp;
+{/render}
+
+{render acl=$gosaMailAlternateAddressACL}
+   <input type=submit value="{t}Delete{/t}" name="delete_alternate">
+{/render}
+
   </td>
  </tr>
 
     <tr>
      <td><LABEL for="default_permissions">{t}Default permission{/t}</LABEL></td>
      <td>
-      <select size="1" id="default_permissions" name="default_permissions" {$permissionsACL}>
+{render acl=$aclACL}
+      <select size="1" id="default_permissions" name="default_permissions">
        {html_options options=$perms selected=$default_permissions}
           <option disabled>&nbsp;</option>
       </select>
+{/render}
      </td>
     </tr>
     <tr>
      <td><LABEL for="member_permissions">{t}Member permission{/t}</LABEL></td>
      <td>
-      <select id="member_permissions" size="1" name="member_permissions" {$permissionsACL}>
+{render acl=$aclACL}
+      <select id="member_permissions" size="1" name="member_permissions">
        {html_options options=$perms selected=$member_permissions}
       </select>
+{/render}
      </td>
     </tr>
        {$plusattributes}
       
   </td>
   <td style="vertical-align:top;width:50%">
-   <h2><img class="center" alt="" align="middle" src="images/envelope.png"> {t}Forward messages to non group members{/t}</h2>
+   <h2>
+       <img class="center" alt="" align="middle" src="images/envelope.png">
+       {t}Forward messages to non group members{/t}
+   </h2>
+
+{render acl=$gosaMailForwardingAddressACL}
    <select style="width:100%;" name="forwarder_list[]" size=10 multiple>
     {html_options values=$gosaMailForwardingAddress output=$gosaMailForwardingAddress}
        <option disabled>&nbsp;</option>
    </select>
+{/render}
+
    <br>
-   <input name="forward_address" size=20 align=middle maxlength=65 {$gosaMailForwardingAddressACL} value="">
-   <input type=submit value="{t}Add{/t}" name="add_forwarder" {$gosaMailForwardingAddressACL}>&nbsp;
-   <input type=submit value="{t}Add local{/t}" name="add_local_forwarder" {$gosaMailForwardingAddressACL}>&nbsp;
-   <input type=submit value="{t}Delete{/t}" name="delete_forwarder" {$gosaMailForwardingAddressACL}>
+
+{render acl=$gosaMailForwardingAddressACL}
+   <input 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;
+{/render}
+{render acl=$gosaMailForwardingAddressACL}
+   <input 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">
+{/render}
   </td>
  </tr>
 </table>