From 786129696db99ec40b6a073b07dec456221c8f5e Mon Sep 17 00:00:00 2001 From: cajus Date: Mon, 21 Aug 2006 11:52:28 +0000 Subject: [PATCH] Set of fixes for users/acl git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4493 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_MultiSelectWindow.inc | 1 + include/class_userinfo.inc | 56 +++++++++++--------- plugins/admin/users/class_divListUsers.inc | 17 +++--- plugins/admin/users/class_userManagement.inc | 2 +- 4 files changed, 41 insertions(+), 35 deletions(-) diff --git a/include/class_MultiSelectWindow.inc b/include/class_MultiSelectWindow.inc index fd1511f1b..60b11f168 100644 --- a/include/class_MultiSelectWindow.inc +++ b/include/class_MultiSelectWindow.inc @@ -574,6 +574,7 @@ class MultiSelectWindow{ /* Add deps to this dialog object list */ foreach($this->departments as $key=> $val){ + /* Add missing entries ... */ if(!isset($this->config->departments[trim($key)])){ $this->config->departments[trim($key)]=""; diff --git a/include/class_userinfo.inc b/include/class_userinfo.inc index 29d6dc817..6595325b2 100644 --- a/include/class_userinfo.inc +++ b/include/class_userinfo.inc @@ -132,18 +132,19 @@ class userinfo /* No members? This is good for all users... */ if (!count($type['members'])){ $interresting= TRUE; - } + } else { - /* Inspect members... */ - foreach ($type['members'] as $grp => $grpdsc){ - /* Some group inside the members that is relevant for us? */ - if (in_array_ics(preg_replace('/^G:/', '', $grp), $this->groups)){ - $interresting= TRUE; - } + /* Inspect members... */ + foreach ($type['members'] as $grp => $grpdsc){ + /* Some group inside the members that is relevant for us? */ + if (in_array_ics(preg_replace('/^G:/', '', $grp), $this->groups)){ + $interresting= TRUE; + } - /* User inside the members? */ - if (preg_replace('/^U:/', '', $grp) == $this->dn){ - $interresting= TRUE; + /* User inside the members? */ + if (preg_replace('/^U:/', '', $grp) == $this->dn){ + $interresting= TRUE; + } } } @@ -166,7 +167,7 @@ class userinfo $acl= ""; if (isset($this->ocMapping[$category])){ foreach($this->ocMapping[$category] as $oc){ - $acl.= $this->get_permissions($dn, $category."/".$oc, ""); + $acl.= $this->get_permissions($dn, $category."/".$oc); } } @@ -253,6 +254,8 @@ echo "Global $object
"; } + /* Extract all departments that are accessible (direct or 'on the way' to an + accessible department) */ function get_module_departments($module) { global $plist; @@ -278,15 +281,12 @@ echo "Global $object
"; } } - /* Get all gosaDepartments */ - $ldap= $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search('objectClass=gosaDepartment', array('dn')); - while ($attrs= $ldap->fetch()){ + /* For all gosaDepartments */ + foreach ($this->config->departments as $dn){ $acl= array("r" => "", "w" => "", "c" => "", "d" => "", "m" => "", "a" => ""); /* Build dn array */ - $path= split(',', $attrs['dn']); + $path= split(',', $dn); $path= array_reverse($path); /* Walk along the path to evaluate the acl */ @@ -314,28 +314,32 @@ echo "Global $object
"; /* Per object ACL? */ foreach ($objects as $object){ - if (isset($subacl['acl'][$object])){ - foreach($subacl['acl'][$object] as $attribute => $dcl){ - if (isset($subacl['acl'][$object][$attribute])){ - $acl= $this->mergeACL($acl, $subacl['type'], preg_replace('/[cdm]/', '', $subacl['acl'][$object][$attribute])); - } + if (isset($subacl['acl']["$module/$object"])){ + foreach($subacl['acl']["$module/$object"] as $attribute => $dcl){ + $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl']["$module/$object"][$attribute]); } } } /* Global ACL? */ - if (isset($subacl['acl'][0])){ - $acl= $this->mergeACL($acl, $subacl['type'], preg_replace('/[cdm]/', '', $subacl['acl'][0])); + if (isset($subacl['acl']["$module/all"][0])){ + $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl']["$module/all"][0]); + continue; + } + + /* Global ACL? */ + if (isset($subacl['acl']["all"][0])){ + $acl= $this->mergeACL($acl, $subacl['type'], $subacl['acl']["all"][0]); continue; } } } } - /* Add department, if we have (some) permissions for the requred module */ + /* Add department, if we have (some) permissions for the required module */ foreach ($acl as $val){ if ($val != ""){ - $deps[]= $attrs['dn']; + $deps[]= $dn; break; } } diff --git a/plugins/admin/users/class_divListUsers.inc b/plugins/admin/users/class_divListUsers.inc index 94260149d..30423e60c 100644 --- a/plugins/admin/users/class_divListUsers.inc +++ b/plugins/admin/users/class_divListUsers.inc @@ -79,27 +79,28 @@ class divListUsers extends MultiSelectWindow which are shown in the listbox on top of the listbox */ $options= ""; -#print_a($this->config->idepartments); -#$ui= get_userinfo(); -#$t= $ui->get_module_departments("users"); -#print_a($t); - /* Get all departments within this subtree */ $base = $this->config->current['BASE']; $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base, array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH); +$ui= get_userinfo(); +$t= $ui->get_module_departments("users"); +print_a($t); + $ids = $this->config->idepartments; +print_a($ids); + foreach($deps as $dep){ if(isset($ids[$dep['dn']])){ $value = $ids[$dep['dn']]; - if ($this->selectedBase == $dep){ - $options.= ""; + if ($this->selectedBase == $dep['dn']){ + $options.= ""; } else { - $options.= ""; + $options.= ""; } } } diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc index 45a3c6d3d..8b95063a4 100644 --- a/plugins/admin/users/class_userManagement.inc +++ b/plugins/admin/users/class_userManagement.inc @@ -138,7 +138,7 @@ class userManagement extends plugin $this->usertab->current = $s_tab; /* Set ACL and move DN to the headline */ -# $this->usertab->set_acl_base(); + $this->usertab->set_acl_base(); $_SESSION['objectinfo']= $this->dn; } -- 2.30.2