Code

Fixed ACLs for addressbook
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 1 Dec 2005 07:40:49 +0000 (07:40 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 1 Dec 2005 07:40:49 +0000 (07:40 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2165 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/addons/addressbook/address_edit.tpl
plugins/addons/addressbook/class_addressbook.inc

index 8c258ae6d6ccd58b4076aab1a24f7b29c722e512..cd6c27a64daebda455755c069fabd47bb2e77435 100644 (file)
 <table summary="" style="width:100%; vertical-align:top; text-align:left; border:1px solid #B0B0B0;" cellpadding=4 cellspacing=0 border=0>
-<tr style="background-color: #E8E8E8; height:26px;font-weight:bold;">
-<td align=left width="100%">
+       <tr style="background-color: #E8E8E8; height:26px;font-weight:bold;">
+               <td align=left width="100%">
+                       <LABEL for="storage_base">
+                               {$storage_info}
+                       </LABEL>
+                       <select id="storage_base" name="storage_base" size="1" title="{t}Choose the department to store entry in{/t}">
+                               {html_options options=$deplist selected=$storage_base}
+                       </select>
+               </td>
+               <td>
+                       <a href="{$url}">
+                               X
+                       </a>
+               </td>
+       </tr>
+       <tr style="background-color: white">
+               <td colspan=2>
+                       <table summary="" width="100%" cellspacing=2 cellpadding=4>
+                               <tr>
+                                       <td style="width:50%; vertical-align:top; background-color: #F0F0F0">
+                                               <h2>
+                                                       <img alt="" src="{$personal_image}" align=middle>
+                                                               &nbsp;{t}Personal{/t}
+                                               </h2>
+                                               <table summary="" width="100%">
+                                                       <tr>
+                                                               <td>
+                                                                       <LABEL for="sn">
+                                                                               {t}First name{/t}{$must}
+                                                                       </LABEL>, 
+                                                                       <LABEL for="givenName">
+                                                                               {t}Last name{/t}{$must}
+                                                                       </LABEL>
+                                                               </td>
+                                                               <td>    
+                                                                       <input id="sn" name="sn" size=10 maxlength=60 value="{$info_sn}" {$snACL}>, 
+                                                                       <input id="givenName" name="givenName" size=10 maxlength=60 value="{$info_givenName}" {$givenNameACL}>
+                                                               <td>
+                                                       </tr>
+                                                       <tr>
+                                                               <td>
+                                                                       <LABEL for="initials">
+                                                                               {t}Initials{/t}
+                                                                       </LABEL>
+                                                               </td>
+                                                               <td>
+                                                                       <input id="initials" name="initials" size=5 maxlength=20 value="{$info_initials}" {$initialsACL}>
+                                                               </td>
+                                                       </tr>
+                                                       <tr>
+                                                               <td>
+                                                                       <LABEL for="title">
+                                                                               {t}Personal title{/t}
+                                                                       </LABEL>
+                                                               </td>
+                                                               <td>
+                                                                       <input id="title" name="title" size=10 maxlength=20 value="{$info_title}" {$titleACL}>
+                                                               </td>
+                                                       </tr>
+                                               </table>
+                                       </td>
+                                       <td style="width:50%; vertical-align:top;background-color:#E8E8E8">
+                                               <h2>
+                                                       <img alt="" src="{$home_image}" align=middle>
+                                                       &nbsp;{t}Private{/t}
+                                               </h2>
+                                               <table summary="" width="100%">
+                                                       <tr>
+                                                               <td>
+                                                                       <LABEL for="homePostalAddress">
+                                                                               {t}Address{/t}
+                                                                       </LABEL>
+                                                               <br>
+                                                               <br>
+                                                               </td>
+                                                               <td style="vertical-align:top;">
+                                                                       <textarea id="homePostalAddress" name="homePostalAddress" 
+                                                                               rows=1 cols=20 {$homePostalAddressACL}>{$info_homePostalAddress}</textarea>
+                                                               </td>
+                                                       </tr>
+                                                       <tr>
+                                                               <td>
+                                                                       <LABEL for="homePhone">
+                                                                               {t}Phone{/t}
+                                                                       </LABEL>
+                                                               </td>
+                                                               <td>
+                                                                       <input id="homePhone" name="homePhone" size=15 maxlength=60 value="{$info_homePhone}" {$homePhoneACL}>
+                                                               </td>
+                                                       </tr>
+                                                       <tr>
+                                                               <td>
+                                                                       <LABEL for="mobile">
+                                                                               {t}Mobile{/t}
+                                                                       </LABEL>
+                                                               </td>
+                                                               <td>
+                                                                       <input id="mobile" name="mobile" size=15 maxlength=60 value="{$info_mobile}" {$mobileACL}>
+                                                               </td>
+                                                       </tr>
+                                                       <tr>
+                                                               <td>
+                                                                       <LABEL for="mail">
+                                                                               {t}Email{/t}
+                                                                       </LABEL>
+                                                               </td>
+                                                               <td>
+                                                                       <input id="mail" name="mail" size=15 maxlength=60 value="{$info_mail}" {$mailACL}>
+                                                               </td>
+                                                       </tr>
+                                                </table>
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td style="width:100%; vertical-align:top; background-color: #E4E4E4" colspan=2>
+                                               <h2>
+                                                       <img alt="" src="{$company_image}" align=middle>
+                                                       &nbsp;{t}Organizational{/t}
+                                               </h2>
+                                               <table summary="" width="100%">
+                                                       <tr>
+                                                               <td>
+                                                                       <table summary="" width="100%">
+                                                                               <tr>
+                                                                                       <td>
+                                                                                               <LABEL for="">  
+                                                                                                       {t}Company{/t}
+                                                                                               </LABEL>
+                                                                                       </td>
+                                                                                       <td>
+                                                                                               <input id="o" name="o" size=15 maxlength=60 value="{$info_o}" {$oACL}>
+                                                                                       </td>
+                                                                               </tr>
+                                                                               <tr>
+                                                                                       <td>
+                                                                                               <LABEL for="">
+                                                                                                       {t}Department{/t}
+                                                                                               </LABEL>
+                                                                                       </td>
+                                                                                       <td>
+                                                                                               <input id="ou" name="ou" size=15 maxlength=60 value="{$info_ou}" {$ouACL}>
+                                                                                       </td>
+                                                                               </tr>
+                                                                               <tr>
+                                                                                       <td>
+                                                                                               <LABEL for="">
+                                                                                                       {t}City{/t}
+                                                                                               </LABEL>
+                                                                                       </td>
+                                                                                       <td>
+                                                                                               <input id="l" name="l" size=15 maxlength=60 value="{$info_l}" {$lACL}>
+                                                                                       </td>
+                                                                               </tr>
+                                                                               <tr>
+                                                                                       <td>
+                                                                                               <LABEL for="">
+                                                                                                       {t}Postal code{/t}
+                                                                                               </LABEL>
+                                                                                       </td>
+                                                                                       <td>
+                                                                                               <input id="postalCode" name="postalCode" size=15 maxlength=60 value="{$info_postalCode}" {$postalCodeACL}>
+                                                                                       </td>
+                                                                               </tr>
+                                                                               <tr>
+                                                                                       <td>
+                                                                                               <LABEL for="">
+                                                                                                       {t}Country{/t}
+                                                                                               </LABEL>
+                                                                                       </td>
+                                                                                       <td>
+                                                                                               <input id="st" name="st" size=15 maxlength=60 value="{$info_st}" {$stACL}>
+                                                                                       </td>
+                                                                               </tr>
+                                                                       </table>
+                                                                       </td>
+                                                                       <td style="vertical-align:top">
+                                                                       <table summary="" width="100%">
+                                                                               <tr>
+                                                                                       <td>
+                                                                                               <LABEL for="">
+                                                                                                       {t}Address{/t}
+                                                                                               </LABEL>
+                                                                                               <br>
+                                                                                               <br>
+                                                                                       </td>
+                                                                                       <td style="vertical-align:top;">
+                                                                                               <textarea id="postalAddress" name="postalAddress" rows=1 cols=20 
+                                                                                                       {$postalAddressACL}>{$info_postalAddress}</textarea>
+                                                                                       </td>
+                                                                               </tr>
+                                                                               <tr>
+                                                                                       <td>
+                                                                                               <LABEL for="">
+                                                                                                       {t}Phone{/t}    
+                                                                                               </LABEL>
+                                                                                       </td>
+                                                                                       <td>
+                                                                                               <input id="telephoneNumber" name="telephoneNumber" {$telephoneNumberACL}
+                                                                                                       size=15 maxlength=60 value="{$info_telephoneNumber}">
+                                                                                       </td>
+                                                                               </tr>
+                                                                               <tr>
+                                                                                       <td>
+                                                                                               <LABEL for="">
+                                                                                                       {t}FAX{/t}
+                                                                                               </LABEL>
+                                                                                       </td>
+                                                                                       <td>
+                                                                                               <input id="facsimileTelephoneNumber" name="facsimileTelephoneNumber" {$facsimileTelephoneNumberACL}
+                                                                                                       size=15 maxlength=60 value="{$info_facsimileTelephoneNumber}">
+                                                                                       </td>
+                                                                               </tr>
+                                                                               <tr>
+                                                                                       <td>
+                                                                                               <LABEL for="">
+                                                                                                       {t}Pager{/t}
+                                                                                               </LABEL>
+                                                                                       </td>
+                                                                                       <td>
+                                                                                               <input id="pager" name="pager" size=15 maxlength=60 value="{$info_pager}" {$pagerACL}>
+                                                                                       </td>
+                                                                               </tr>
+                                                                       </table>
+                                                               </td>
+                                                       </tr>
+                                               </table>
+                                       </td>
+                               </tr>
+                       </table>
 
-       <LABEL for="storage_base">{$storage_info}</LABEL>
-               
-       <select id="storage_base" name="storage_base" size="1" title="{t}Choose the department to store entry in{/t}">
-               {html_options options=$deplist selected=$storage_base}
-       </select>
-</td>
-<td><a href="{$url}">X</a></td>
-</tr>
-<tr style="background-color: white">
-<td colspan=2>
-<table summary="" width="100%" cellspacing=2 cellpadding=4>
-<tr>
-<td style="width:50%; vertical-align:top; background-color: #F0F0F0">
- <h2><img alt="" src="{$personal_image}" align=middle>&nbsp;{t}Personal{/t}</h2>
- <table summary="" width="100%">
-  <tr>
-   <td><LABEL for="sn">{t}First name{/t}{$must}</LABEL>, <LABEL for="givenName">{t}Last name{/t}{$must}</LABEL></td>
-   <td>        
-               
-               <input id="sn" name="sn" size=10 maxlength=60 value="{$info_sn}">, 
-               <input id="givenName" name="givenName" size=10 maxlength=60 value="{$info_givenName}"><td>
-  </tr>
-  <tr>
-   <td><LABEL for="initials">{t}Initials{/t}</LABEL></td><td><input id="initials" name="initials" size=5 maxlength=20 value="{$info_initials}"></td>
+                       <p align=right>
+                       <input type="submit" name="save" value="{t}Save{/t}">
+                       <input type="submit" name="cancel" value="{t}Cancel{/t}">
+                       </p>
 
-  </tr>
-  <tr>
-   <td><LABEL for="title">{t}Personal title{/t}</LABEL></td><td><input id="title" name="title" size=10 maxlength=20 value="{$info_title}"></td>
-  </tr>
- </table>
-
-</td>
-
-<td style="width:50%; vertical-align:top; background-color: #E8E8E8">
- <h2><img alt="" src="{$home_image}" align=middle>&nbsp;{t}Private{/t}</h2>
-
- <table summary="" width="100%">
-  <tr>
-   <td><LABEL for="homePostalAddress">{t}Address{/t}</LABEL><br><br></td>
-   <td style="vertical-align:top;"><textarea id="homePostalAddress" name="homePostalAddress" rows=1 cols=20>{$info_homePostalAddress}</textarea></td>
-  </tr>
-  <tr>
-   <td><LABEL for="homePhone">{t}Phone{/t}</LABEL></td><td><input id="homePhone" name="homePhone" size=15 maxlength=60 value="{$info_homePhone}"></td>
-  </tr>
-  <tr>
-   <td><LABEL for="mobile">{t}Mobile{/t}</LABEL></td><td><input id="mobile" name="mobile" size=15 maxlength=60 value="{$info_mobile}"></td>
-  </tr>
-  <tr>
-   <td><LABEL for="mail">{t}Email{/t}</LABEL></td><td><input id="mail" name="mail" size=15 maxlength=60 value="{$info_mail}"></td>
-  </tr>
- </table>
-
-</td>
-
-</tr>
-
-<tr>
-<td style="width:100%; vertical-align:top; background-color: #E4E4E4" colspan=2>
- <h2><img alt="" src="{$company_image}" align=middle>&nbsp;{t}Organizational{/t}</h2>
-
- <table summary="" width="100%">
-  <tr>
-   <td>
-  
-    <table summary="" width="100%">
-     <tr>
-      <td><LABEL for="">{t}Company{/t}</LABEL></td><td><input id="o" name="o" size=15 maxlength=60 value="{$info_o}"></td>
-     </tr>
-     <tr>
-      <td><LABEL for="">{t}Department{/t}</LABEL></td><td><input id="ou" name="ou" size=15 maxlength=60 value="{$info_ou}"></td>
-     </tr>
-     <tr>
-      <td><LABEL for="">{t}City{/t}</LABEL></td><td><input id="l" name="l" size=15 maxlength=60 value="{$info_l}"></td>
-     </tr>
-     <tr>
-      <td><LABEL for="">{t}Postal code{/t}</LABEL></td><td><input id="postalCode" name="postalCode" size=15 maxlength=60 value="{$info_postalCode}"></td>
-     </tr>
-     <tr>
-      <td><LABEL for="">{t}Country{/t}</LABEL></td><td><input id="st" name="st" size=15 maxlength=60 value="{$info_st}"></td>
-     </tr>
-    </table>
-   </td>
-   <td style="vertical-align:top">
-
-    <table summary="" width="100%">
-     <tr>
-      <td><LABEL for="">{t}Address{/t}</LABEL><br><br></td><td style="vertical-align:top;"><textarea id="postalAddress" name="postalAddress" rows=1 cols=20>{$info_postalAddress}</textarea></td>
-     </tr>
-     <tr>
-      <td><LABEL for="">{t}Phone{/t}</LABEL></td><td><input id="telephoneNumber" name="telephoneNumber" size=15 maxlength=60 value="{$info_telephoneNumber}"></td>
-     </tr>
-     <tr>
-      <td><LABEL for="">{t}FAX{/t}</LABEL></td><td><input id="facsimileTelephoneNumber" name="facsimileTelephoneNumber" size=15 maxlength=60 value="{$info_facsimileTelephoneNumber}"></td>
-     </tr>
-     <tr>
-      <td><LABEL for="">{t}Pager{/t}</LABEL></td><td><input id="pager" name="pager" size=15 maxlength=60 value="{$info_pager}"></td>
-     </tr>
-    </table>
-   </td>
-  </tr>
- </table>
-
-</td>
-</tr>
-</table>
-
-<p align=right>
-  <input type="submit" name="save" value="{t}Save{/t}">
-  <input type="submit" name="cancel" value="{t}Cancel{/t}">
-</p>
-
-</td>
-</tr>
+               </td>
+       </tr>
 </table>
 
index c6c049c1d7553ccda718bf2caf36d617a26c913a..43cc8dde280e788c5e09f9b70caa84e6d6890022 100644 (file)
@@ -52,11 +52,6 @@ class addressbook extends plugin
                /* Include config object */
                $this->config= $config;
 
-               print $dn;
-
-#FIXME: ACL is set to default for testing
-               $this->acl= "#all#";
-
                /* Get global filter config */
                if (!is_global("phonefilter")){
                        $ui= get_userinfo();
@@ -75,7 +70,12 @@ class addressbook extends plugin
                /* Call parent execute */
                plugin::execute();
 
-               $smarty= get_smarty();
+    $smarty= get_smarty();
+
+    foreach($this->attributes as $attr){
+      $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
+    }
+
 
 #! Hickert
                /*prevent empty variables for smarty*/
@@ -268,10 +268,6 @@ class addressbook extends plugin
                                $this->load();
                                /* Load permissions for selected 'dn' and check if
                                   we're allowed to remove this 'dn' */
-                               $ui= get_userinfo();
-                               $dn= preg_replace("/,dc=addressbook,/", "", $this->dn);
-                               $acl= get_permissions ($dn, $ui->subtreeACL);
-                               $this->acl= get_module_permission($acl, "global-addressbook", $dn);
                                if (chkacl($this->acl, "delete") == ""){
 
                                        /* Check locking, save current plugin in 'back_plugin', so
@@ -281,6 +277,7 @@ class addressbook extends plugin
                                        }
 
                                        /* Lock the current entry, so nobody will edit it during deletion */
+          $ui= get_userinfo();
                                        add_lock ($this->dn, $ui->dn);
                                        $smarty->assign("info", sprintf(_("You're about to delete the entry %s."), $this->dn));
                                        return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
@@ -443,7 +440,6 @@ class addressbook extends plugin
                        }
 
                        /* Fill variables from LDAP */
-# FIXME: Missing ACL support for addressbook yet
                        if ($_SESSION['show_info'] != "ADD"){
                                $ldap->cat($_SESSION['show_info']);
                                $info= $ldap->fetch();
@@ -532,6 +528,15 @@ class addressbook extends plugin
                return($smarty->fetch(get_template_path('contents.tpl', TRUE)));
        }
 
+  function save_object()
+  {
+    plugin::save_object();
+    foreach($this->attributes as $attr){
+      if(isset($_POST[$attr])){
+        $this->$attr = $_POST[$attr];
+      }
+    }
+  }
 
        function check()
        {
@@ -597,11 +602,7 @@ class addressbook extends plugin
                $this->new_dn= $this->dn;
        }
 
-       $ui= get_userinfo();
-       $dn= preg_replace("/,dc=addressbook,/", "", $this->new_dn);
-       $acl= get_permissions ($dn, $ui->subtreeACL);
-       $acl= get_module_permission($acl, "global-addressbook", $this->dn);
-       if ($_SESSION['show_info'] == "ADD" && chkacl($acl, "create") != ""){
+       if ($_SESSION['show_info'] == "ADD" && chkacl($this->acl, "add") != ""){
                $message[]= _("You have no permissions to create or modify a global address book entry.");
        }