From 40598e2f739dcd7978937a9332af653ba3f5b84d Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 2 Jan 2008 12:24:38 +0000 Subject: [PATCH] Added get_sub_list function to several management dialogs. -Not completely tested yet git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8172 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_ldap.inc | 2 +- gosa-core/include/functions.inc | 12 +++++++++++- .../applications/class_applicationManagement.inc | 2 +- .../plugins/admin/devices/class_deviceManagement.inc | 3 ++- .../plugins/admin/groups/class_groupManagement.inc | 4 ++-- .../admin/mimetypes/class_mimetypeManagement.inc | 2 +- .../plugins/admin/ogroups/class_ogroupManagement.inc | 4 ++-- .../plugins/admin/systems/class_systemManagement.inc | 6 +++--- .../plugins/admin/users/class_userManagement.inc | 4 ++-- 9 files changed, 25 insertions(+), 14 deletions(-) diff --git a/gosa-core/include/class_ldap.inc b/gosa-core/include/class_ldap.inc index 763db832a..1b39d7925 100644 --- a/gosa-core/include/class_ldap.inc +++ b/gosa-core/include/class_ldap.inc @@ -1364,7 +1364,7 @@ class LDAP{ { if (isset($_SESSION['config'])){ $cfg= $_SESSION['config']; - if (isset($cfg->current['LDAPSTATS']) && preg_match('/true/i', $cfg->current['LDAPSTATS'])){ + if (1 || isset($cfg->current['LDAPSTATS']) && preg_match('/true/i', $cfg->current['LDAPSTATS'])){ syslog (LOG_INFO, $string); } } diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index 55ec06550..e27fc0e65 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -740,6 +740,9 @@ function get_sub_list($filter, $category,$sub_base, $base= "", $attributes= arra $ldap->cd ($base); } + /* Remove , ("ou=1,ou=2.." => "ou=1") */ + $sub_base = preg_replace("/,.*$/","",$sub_base); + /* Check if there is a sub department specified */ if($sub_base == ""){ trigger_error("Please specify a valid sub search base, like 'ou=apps'. Parameter 3"); @@ -1031,13 +1034,20 @@ function get_ou($name) { global $config; + $map = array( "applicationou" => "ou=apps,", + "mimetypeou" => "ou=mime,"); + /* Preset ou... */ if (isset($config->current[$name])){ $ou= $config->current[$name]; + } elseif (isset($map[$name])) { + $ou = $map[$name]; + return($ou); } else { return ""; } - + + if ($ou != ""){ if (!preg_match('/^[^=]+=[^=]+/', $ou)){ return @LDAP::convert("ou=$ou,"); diff --git a/gosa-core/plugins/admin/applications/class_applicationManagement.inc b/gosa-core/plugins/admin/applications/class_applicationManagement.inc index 7736f1963..1089c50e8 100644 --- a/gosa-core/plugins/admin/applications/class_applicationManagement.inc +++ b/gosa-core/plugins/admin/applications/class_applicationManagement.inc @@ -520,7 +520,7 @@ class applicationManagement extends plugin $Flags |= GL_SUBSEARCH; } - $res= get_list($Filter, "application", $use_base, array("cn","description","dn","objectClass"), $Flags); + $res= get_sub_list($Filter, "application",get_ou('applicationou'), $use_base, array("cn","description","dn","objectClass"), $Flags); $tmp2 = array(); foreach ($res as $val){ $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val; diff --git a/gosa-core/plugins/admin/devices/class_deviceManagement.inc b/gosa-core/plugins/admin/devices/class_deviceManagement.inc index 59e702ff4..61ea93afa 100644 --- a/gosa-core/plugins/admin/devices/class_deviceManagement.inc +++ b/gosa-core/plugins/admin/devices/class_deviceManagement.inc @@ -511,7 +511,7 @@ class deviceManagement extends plugin } /* Get results and create index */ - $res= get_list($Filter, "devices", $base, array("cn","description","dn","objectClass"), $Flags); + $res= get_sub_list($Filter,"devices","ou=devices", $base, array("cn","description","dn","objectClass"), $Flags); $tmp2 = array(); foreach ($res as $val){ $tmp2[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']] = strtolower($val['cn'][0]).$val['cn'][0].$val['dn']; @@ -527,6 +527,7 @@ class deviceManagement extends plugin reset ($this->devices); } + function remove_lock() { if (isset($this->devicetabs->dn)){ diff --git a/gosa-core/plugins/admin/groups/class_groupManagement.inc b/gosa-core/plugins/admin/groups/class_groupManagement.inc index f146ad689..dbd073532 100644 --- a/gosa-core/plugins/admin/groups/class_groupManagement.inc +++ b/gosa-core/plugins/admin/groups/class_groupManagement.inc @@ -590,9 +590,9 @@ class groupManagement extends plugin } if ($SubSearch){ - $res= get_list($filter, "groups", $base, $attrs, GL_SIZELIMIT| GL_SUBSEARCH); + $res= get_sub_list($filter, "groups",get_groups_ou(), $base, $attrs, GL_SIZELIMIT| GL_SUBSEARCH); } else { - $res= get_list($filter, "groups", get_groups_ou().$base, $attrs, GL_SIZELIMIT); + $res= get_sub_list($filter, "groups",get_groups_ou(), get_groups_ou().$base, $attrs, GL_SIZELIMIT); } /* Sort values into grouplist*/ diff --git a/gosa-core/plugins/admin/mimetypes/class_mimetypeManagement.inc b/gosa-core/plugins/admin/mimetypes/class_mimetypeManagement.inc index 651110360..6fe119d92 100755 --- a/gosa-core/plugins/admin/mimetypes/class_mimetypeManagement.inc +++ b/gosa-core/plugins/admin/mimetypes/class_mimetypeManagement.inc @@ -526,7 +526,7 @@ class mimetypeManagement extends plugin } /* Get results and create index */ - $res= get_list($Filter, "mimetypes", $use_base, array("cn","description","dn","objectClass"), $Flags); + $res= get_sub_list($Filter, "mimetypes",get_ou('mimetypeou'), $use_base, array("cn","description","dn","objectClass"), $Flags); $tmp2 = array(); foreach ($res as $val){ $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val; diff --git a/gosa-core/plugins/admin/ogroups/class_ogroupManagement.inc b/gosa-core/plugins/admin/ogroups/class_ogroupManagement.inc index 1e66866da..dc0d3188a 100644 --- a/gosa-core/plugins/admin/ogroups/class_ogroupManagement.inc +++ b/gosa-core/plugins/admin/ogroups/class_ogroupManagement.inc @@ -523,9 +523,9 @@ class ogroupManagement extends plugin $filter= "(&(cn=$Regex)(objectClass=gosaGroupOfNames)(|$filter))"; if($this->DivListOGroup->SubSearch){ - $res= get_list($filter, "ogroups", $base, array("cn","objectClass","gosaGroupObjects"), GL_SIZELIMIT | GL_SUBSEARCH); + $res= get_sub_list($filter, "ogroups",get_groups_ou(), $base, array("cn","objectClass","gosaGroupObjects"), GL_SIZELIMIT | GL_SUBSEARCH); }else{ - $res= get_list($filter, "ogroups", get_groups_ou().$base, array("cn","objectClass","gosaGroupObjects"), GL_SIZELIMIT ); + $res= get_sub_list($filter, "ogroups",get_groups_ou(), get_groups_ou().$base, array("cn","objectClass","gosaGroupObjects"), GL_SIZELIMIT ); } $this->ogrouplist= $res; diff --git a/gosa-core/plugins/admin/systems/class_systemManagement.inc b/gosa-core/plugins/admin/systems/class_systemManagement.inc index 03a3b8386..7b0484404 100644 --- a/gosa-core/plugins/admin/systems/class_systemManagement.inc +++ b/gosa-core/plugins/admin/systems/class_systemManagement.inc @@ -1001,7 +1001,7 @@ class systems extends plugin if($this->DivListSystem->SubSearch){ if($oc['CLASS'] != ""){ $filter = "(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex."))"; - $new_res = get_list($filter, $sys_categories , $base,$sys_attrs, GL_NONE | GL_SUBSEARCH | GL_SIZELIMIT); + $new_res = get_sub_list($filter, $sys_categories ,preg_replace("/,.*$/","",$base), $base,$sys_attrs, GL_NONE | GL_SUBSEARCH | GL_SIZELIMIT); /* Remove all objects that are not in the expected sub department */ foreach($new_res as $key => $obj){ @@ -1014,7 +1014,7 @@ class systems extends plugin /* User filter? */ if($oc['CLASS'] != ""){ $filter = "(&".$userregex."(objectClass=".$oc['CLASS'].")(cn=".$this->DivListSystem->Regex."))"; - $res = array_merge($res,get_list($filter,$sys_categories,$oc['TREE'].$base, $sys_attrs, GL_NONE | GL_SIZELIMIT)); + $res = array_merge($res,get_sub_list($filter,$sys_categories,preg_replace("/,.*$/","",$oc['TREE']),$oc['TREE'].$base, $sys_attrs, GL_NONE | GL_SIZELIMIT)); } } } @@ -1022,7 +1022,7 @@ class systems extends plugin /* Search for incoming objects */ $filter = "(|(&".$userregex."(objectClass=goHard)(cn=".$this->DivListSystem->Regex.")))"; - $res = array_merge($res,get_list($filter,$sys_categories,"ou=incoming,".$base,$sys_attrs, GL_NONE | GL_SIZELIMIT)); + $res = array_merge($res,get_list($filter,$sys_categories,"ou=incoming","ou=incoming,".$base,$sys_attrs, GL_NONE | GL_SIZELIMIT)); /* Get all gotoTerminal's */ foreach ($res as $value){ diff --git a/gosa-core/plugins/admin/users/class_userManagement.inc b/gosa-core/plugins/admin/users/class_userManagement.inc index 977a26f6b..0b9e6ffad 100644 --- a/gosa-core/plugins/admin/users/class_userManagement.inc +++ b/gosa-core/plugins/admin/users/class_userManagement.inc @@ -960,11 +960,11 @@ class userManagement extends plugin $ldap= $this->config->get_ldap_link(TRUE); if ($SubSearch){ - $ListTemp = get_list($filter, "users", $base, + $ListTemp = get_sub_list($filter, "users", preg_replace("/,.*$/","",get_people_ou()),$base, array("uid", "givenName", "sn", "objectClass","userPassword"), GL_SUBSEARCH | GL_SIZELIMIT); } else { $base= get_people_ou().$base; - $ListTemp = get_list($filter, "users", $base, + $ListTemp = get_sub_list($filter, "users", preg_replace("/,.*$/","",get_people_ou()),$base, array("uid", "givenName", "sn", "objectClass","userPassword"), GL_SIZELIMIT); } $SortTemp = array(); -- 2.30.2