From a70441e328fa9edc1395503bef48e1d8f0c43c98 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 27 Oct 2006 05:48:26 +0000 Subject: [PATCH] Added some more acls git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4948 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/addons/addressbook/address_edit.tpl | 39 +++++++- .../addons/addressbook/class_addressbook.inc | 96 ++++++++++++++++--- plugins/addons/addressbook/contents.tpl | 8 +- 3 files changed, 125 insertions(+), 18 deletions(-) diff --git a/plugins/addons/addressbook/address_edit.tpl b/plugins/addons/addressbook/address_edit.tpl index dae734146..9a79f3b72 100644 --- a/plugins/addons/addressbook/address_edit.tpl +++ b/plugins/addons/addressbook/address_edit.tpl @@ -33,9 +33,13 @@ {t}First name{/t}{$must} - + +{render acl=$snACL} , +{/render} +{render acl=$givenNameACL} +{/render} @@ -45,7 +49,9 @@ +{render acl=$initialsACL} +{/render} @@ -55,7 +61,9 @@ +{render acl=$titleACL} +{/render} @@ -75,8 +83,10 @@
+{render acl=$homePostalAddressACL} +{/render} @@ -86,7 +96,9 @@ +{render acl=$homePhoneACL} +{/render} @@ -96,7 +108,9 @@ +{render acl=$mobileACL} +{/render} @@ -106,7 +120,9 @@ +{render acl=$mailACL} +{/render} @@ -129,7 +145,9 @@ +{render acl=$oACL} +{/render} @@ -139,7 +157,9 @@ +{render acl=$ouACL} +{/render} @@ -149,7 +169,9 @@ +{render acl=$lACL} +{/render} @@ -159,7 +181,9 @@ +{render acl=$postalCodeACL} +{/render} @@ -169,7 +193,9 @@ +{render acl=$stACL} +{/render} @@ -185,8 +211,10 @@
+{render acl=$postalAddressACL} +{/render} @@ -196,8 +224,10 @@ +{render acl=$telephoneNumberACL} +{/render} @@ -207,8 +237,10 @@ +{render acl=$facsimileTelephoneNumberACL} +{/render} @@ -218,7 +250,9 @@ +{render acl=$pagerACL} +{/render} @@ -238,3 +272,6 @@ + diff --git a/plugins/addons/addressbook/class_addressbook.inc b/plugins/addons/addressbook/class_addressbook.inc index bbb57ac20..baa8f01e6 100644 --- a/plugins/addons/addressbook/class_addressbook.inc +++ b/plugins/addons/addressbook/class_addressbook.inc @@ -127,6 +127,10 @@ class addressbook extends plugin } register_global("phonefilter", $phonefilter); + /* Assign create acl */ + $acl = $this->get_entry_acls($this->abobjectclass.",".$phonefilter['search_base']); + $smarty->assign("internal_createable", preg_match("/c/",$acl)); + $smarty->assign("internal_removeable", preg_match("/d/",$acl)); /* Perform actions with CTI hook */ if (isset($_GET['target']) @@ -188,7 +192,9 @@ class addressbook extends plugin /* Some nice guy may send this as POST, so we've to check for the permissions again. */ - if (chkacl($this->acl, "delete") == ""){ + + $acl = $this->get_entry_acls($this->dn); + if(preg_match("/d/",$acl)){ /* Delete request is permitted, perform LDAP action */ $ldap= $this->config->get_ldap_link(); @@ -288,9 +294,11 @@ class addressbook extends plugin case "remove": $this->dn= $_SESSION['show_info']; $this->load(); + /* Load permissions for selected 'dn' and check if we're allowed to remove this 'dn' */ - if (chkacl($this->acl, "delete") == ""){ + $acl = $this->get_entry_acls($this->dn); + if(preg_match("/d/",$acl)){ /* Check locking, save current plugin in 'back_plugin', so the dialog knows where to return. */ @@ -387,7 +395,8 @@ class addressbook extends plugin } /* Check if at least one attribute is specified */ - $skip = true; + $skip = false; + foreach($must_have_this as $attr) { if(isset($attrs[$attr][0]) && !empty($attrs[$attr][0])){ $skip =false; @@ -398,13 +407,15 @@ class addressbook extends plugin /* Skip all attributes that we are not allowed to read */ $any = false; foreach($attributes as $attr){ - if(!preg_match("/r/",$this->ui->get_permissions($attrs['dn'],"users/user",$attr))){ + + $acls = $this->get_entry_acls($attrs['dn'],$attr); + if(!preg_match("/r/",$acls)){ $attrs[$attr][0] = "Not allowed"; }else{ $any = true; } } - + /* Only show lines that have set any mail or phone informations */ if(!$skip && $any){ @@ -471,25 +482,29 @@ class addressbook extends plugin $output= ""; $mod= 0; -#! hickert - if(!isset($_SESSION['show_info'])) $smarty->assign("show_info", "");; + /* View detailed infos */ + $smarty->assign("show_info", ""); if (isset($_SESSION['show_info'])){ + $range= 4; $smarty->assign("show_info", "1"); $smarty->assign("url", "main.php?plug=".validate($_GET['plug'])."&close=1"); + $tmp = $this->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $smarty->assign($name."ACL",$this->get_entry_acls($this->dn,$name)); + } + switch ($_SESSION['show_info']){ case "ADD": $smarty->assign ('storage_base', $this->storage_base); - $smarty->assign ('address_info', - get_template_path('address_edit.tpl', TRUE)); + $smarty->assign ('address_info', get_template_path('address_edit.tpl', TRUE)); break; default: - $smarty->assign ('address_info', - get_template_path('address_info.tpl', TRUE)); + $smarty->assign ('address_info', get_template_path('address_info.tpl', TRUE)); break; } @@ -657,10 +672,6 @@ class addressbook extends plugin $this->new_dn= $this->dn; } - if ($_SESSION['show_info'] == "ADD" && chkacl($this->acl, "add") != ""){ - $message[]= _("You have no permissions to create or modify a global address book entry."); - } - return ($message); } @@ -708,6 +719,61 @@ class addressbook extends plugin } } + + /* Return entry acls */ + function get_entry_acls($dn,$attr = "") + { + $acls = ""; + + /* Use addressbook acls */ + if(preg_match("/".normalizePreg($this->abobjectclass)."/",$dn)) { + $dn = preg_replace("/".normalizePreg($this->abobjectclass).",/","",$dn); + $acls = $this->ui->get_permissions($dn,"addressbook/addressbook",$attr); + } + + /* Use Organizational Person acls */ + else{ + $acls = $this->ui->get_permissions($dn,"users/user",$attr); + } + + return($acls); + } + + + /* Return plugin informations for acl handling */ + function plInfo() + { + return (array( + "plShortName" => _("Addressbook"), + "plDescription" => _("Addressbook entry acls"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 0, + "plSection" => array("addons" => _("Addons")), + "plCategory" => array("addressbook" => array("objectClass" => "inetOrgPerson", "description" => _("Addressbook"))), + + "plProvidedAcls" => array( + "sn" => _("Surename"), + "givenName" => _("Given name"), + "telephoneNumber" => _("Telefon number"), + "facsimileTelephoneNumber" => _("Fax number"), + "mobile" => _("Mobile number"), + "homePhone" => _("Home phone number"), + "uid" => _("User identification"), + "mail" => _("Mail address"), + "pager" => _("Pgaer"), + "o" => _("Organization"), + "ou" => _("Department"), + "l" => _("Location"), + "postalAddress" => _("Postal address"), + "postalCode" => _("Postal address"), + "st" => _("State"), + "initials" => _("Initials"), + "title" => _("Title"), + "homePostalAddress" => _("Home postal address"), + "cn" => _("Common name")) + )); + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/plugins/addons/addressbook/contents.tpl b/plugins/addons/addressbook/contents.tpl index 3e61376fe..80472c950 100644 --- a/plugins/addons/addressbook/contents.tpl +++ b/plugins/addons/addressbook/contents.tpl @@ -43,13 +43,17 @@

+ {if $internal_createable}   {t}Add entry{/t}
+ {/if} {if $internal eq 0}   {t}Edit entry{/t}
-   - {t}Remove entry{/t}
+ {if $internal_removeable} +   + {t}Remove entry{/t}
+ {/if} {/if}

-- 2.30.2