1 <?php
3 class filterGroupLDAP {
5 static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "")
6 {
7 $result= array();
8 $menu= array();
9 $dn2index= array();
10 $config= session::global_get('config');
11 $ldap= $config->get_ldap_link(TRUE);
12 $flag= ($scope == "sub")?GL_SUBSEARCH:0;
13 $tmp= filterGroupLDAP::get_list($base, $filter, $attributes, $category, $objectStorage, $flag | GL_SIZELIMIT);
15 // Sort out menu entries, but save info
16 $index= 0;
17 foreach ($tmp as $entry) {
18 if (in_array_ics("posixGroup", $entry['objectClass'])) {
19 $result[$index]= $entry;
20 $dn2index[$entry['dn']]= $index;
21 $index++;
22 } else {
23 foreach ($objectStorage as $storage) {
24 $group= preg_replace("/^.*,([^,]+),".preg_quote("$storage$base")."$/", '$1', $entry['dn']);
25 $group= "$group,$storage$base";
27 // The current group implementation has no multiple storage settings - so break here
28 break;
29 }
30 $menu[$group]= true;
31 }
32 }
34 // Move menu information to menu
35 foreach ($menu as $dn => $dummy) {
36 if(isset($dn2index[$dn])){
37 $result[$dn2index[$dn]]["objectClass"][]= "gotoMenuGroup";
38 }
39 }
41 return $result;
42 }
45 static function get_list($base, $filter, $attributes, $category, $objectStorage, $flags= GL_SUBSEARCH)
46 {
47 $filter= "(|(|(objectClass=gotoMenuEntry)(objectClass=gotoSubmenuEntry))$filter)";
48 return filterLDAP::get_list($base, $filter, $attributes, $category, $objectStorage, $flags);
49 }
52 }
54 ?>