Code

Added regex to group -> user add dialog
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 24 Apr 2006 12:16:08 +0000 (12:16 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 24 Apr 2006 12:16:08 +0000 (12:16 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3093 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/groups/class_groupGeneric.inc

index e0608fa200c659d587ce02669970aaa8ec825194..cde02bd48ee5d3775fdd2def7a109b92bcbcf325 100644 (file)
@@ -287,6 +287,7 @@ class group extends plugin
       }
       $regex= preg_replace('/[*]/', ".*", $gufilter['regex']);
       register_global("gufilter", $gufilter);
+
       $this->reload();
 
       /* Show dialog */
@@ -424,17 +425,25 @@ class group extends plugin
     $MaxUser = $this->OnlyShowFirstEntries;
 
     $gufilter= get_global("gufilter");
-    //FIXME: Why these multiple cd's? They are senseless.
-    $ldap->cd ($this->config->current['BASE']);
+   
+    /* Fix regex string */ 
+    $regex = normalizeLdap($gufilter['regex']);
+
+    /* Create filter */
+    $filter = "(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(!(uid=*$))(|(uid=".$regex.")(givenName=".$regex.")(sn=".$regex.")))";
+
     if($gufilter['SubSearchGroup']){
+      /* search in subtrees */
       $ldap->cd ($gufilter['dselect']);
-      $ldap->search("(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(!(uid=*$)))",array("uid", "sn","givenName"));
+      $ldap->search($filter, array("uid", "sn","givenName"));
     }else{
+      /* search in currently selected tree only */
       $ldap->cd (get_people_ou().$gufilter['dselect']);
-      $ldap->ls ("(&(objectClass=gosaAccount)(!(objectClass=gosaUserTemplate))(!(uid=*$)))",get_people_ou().$gufilter['dselect'],array("uid", "sn", "givenName"));
+      $ldap->ls ($filter, get_people_ou().$gufilter['dselect'],array("uid", "sn", "givenName"));
     }
+   
+    /* create result array with givenName / sn and sort it  */ 
     $this->allusers= array();
-    
     $i = 0 ;
     while (($attrs= $ldap->fetch()) && ($i < $MaxUser)){
       $i ++;
@@ -445,13 +454,12 @@ class group extends plugin
         $this->allusers[$attrs["uid"][0]]= $attrs['uid'][0];
       }
     }
-  
+    natcasesort ($this->allusers);
+    reset ($this->allusers);
+
     if(($i == $MaxUser)){
       print_red(sprintf(_("Your search method returned more than '%s' users, only '%s' users are shown.") , $MaxUser,$MaxUser));
     }
-    
-    natcasesort ($this->allusers);
-    reset ($this->allusers);
 
     /* Fill memberlist */
     $this->members= array();