Code

Added get_sub_list function to several management dialogs.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 2 Jan 2008 12:24:38 +0000 (12:24 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 2 Jan 2008 12:24:38 +0000 (12:24 +0000)
-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
gosa-core/include/functions.inc
gosa-core/plugins/admin/applications/class_applicationManagement.inc
gosa-core/plugins/admin/devices/class_deviceManagement.inc
gosa-core/plugins/admin/groups/class_groupManagement.inc
gosa-core/plugins/admin/mimetypes/class_mimetypeManagement.inc
gosa-core/plugins/admin/ogroups/class_ogroupManagement.inc
gosa-core/plugins/admin/systems/class_systemManagement.inc
gosa-core/plugins/admin/users/class_userManagement.inc

index 763db832a0ccb88418a9d8f17d6beb3008a7d78b..1b39d79252f99116e2e8d907c9faabd1efaae0b1 100644 (file)
@@ -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);
       }
     }
index 55ec06550e62382c6a1d1dce58c9c140e1270eec..e27fc0e65cead6050302359d62d49ac67bd2c65e 100644 (file)
@@ -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,");
index 7736f1963c3ab76b8f278409c6afc46173a0eb63..1089c50e8a1d9f0cb9a4c027af8dc3e44a6458f9 100644 (file)
@@ -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;
index 59e702ff481eb9bb3f66f89168f12fc32168f24c..61ea93afaa0a2a0d513f135e81ff8c4d4b508eda 100644 (file)
@@ -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)){
index f146ad689b672c320b67afd6b2eb3490d7dda58c..dbd073532ffe1a0961e61df3889a86f6917caf1b 100644 (file)
@@ -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*/
index 6511103600da18e892c4a054d999ba7c22aa4515..6fe119d92cb2075f59889d62177bcbbd331fa851 100755 (executable)
@@ -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;
index 1e66866da642e4d1102580ea81cc25852a1a3537..dc0d3188a229560931fb6a37ef62efc4d88c7e78 100644 (file)
@@ -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;
index 03a3b83866754de78f1534565259b22105a28320..7b04844043762abcf7a8a8078b375f465babfead 100644 (file)
@@ -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){
index 977a26f6b1db3fdaa98c823b6004bf540be707b9..0b9e6ffad70c6e6451c0831fbedaaa17a87f38ad 100644 (file)
@@ -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();