Code

some speed improvements for grop/posix
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 23 Jan 2006 07:47:41 +0000 (07:47 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 23 Jan 2006 07:47:41 +0000 (07:47 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2539 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/groups/class_groupManagement.inc
plugins/personal/posix/class_posixAccount.inc
plugins/personal/posix/posix_groups.tpl

index 83d6a5ddfc5527dd8ad0823813953b2ce6b9306d..003cb10acda1df598414151f615a10dee715b9c8 100644 (file)
@@ -526,20 +526,11 @@ class groupManagement extends plugin
       }
     }
 
-
-
-
-
-
-
-
     /*
      * We also need to search for the departments
      * So we are able to navigate like in konquerer
      */
 
-    /* Only needed if we are in GroupManagement */
-    if(!$CreatePosixsList){
       $res3 =  get_list2($this->ui->subtreeACL, "(&(|(ou=$regex)(description=$regex))(objectClass=gosaDepartment))",
           FALSE, $base, array("ou", "description"), TRUE);
       $this->departments= array();
@@ -555,7 +546,6 @@ class groupManagement extends plugin
           $this->departments[$value['dn']]= convert_department_dn2($value['dn']);//$value["description"][0];
         }
       }
-    }
     /*  Ende department generation
      */
 
@@ -594,39 +584,16 @@ class groupManagement extends plugin
 
     $tmp=array();
 
-    /* If true ; this result is used for posix tab, group membership selection. */
-    if($CreatePosixsList){
-
-      /* Addd to array */
-      foreach($this->grouplist as $tkey => $val ){
-        $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val;
-      }
-      
-      /* Sort index */
-      ksort($tmp);
-
-      /* Recreate index array[dn]=cn[description]*/
-      $this->grouplist=array();
-      foreach($tmp as $val){
-        if(isset($val['description'])){
-          $this->grouplist[$val['dn']]=$val['cn'][0]."&nbsp;[".$val['description'][0]."]";
-        }else{
-          $this->grouplist[$val['dn']]=$val['cn'][0];
-        }
-      }
-    }else{
-  
-      /* Create result for group management listbox*/
-      foreach($this->grouplist as $tkey => $val ){
-        $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val;
-      }
-      ksort($tmp);
-      $this->grouplist=array();
-      foreach($tmp as $val){
-        $this->grouplist[]=$val;
-      }
-      reset ($this->grouplist);
+    /* Create result for group management listbox*/
+    foreach($this->grouplist as $tkey => $val ){
+      $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val;
+    }
+    ksort($tmp);
+    $this->grouplist=array();
+    foreach($tmp as $val){
+      $this->grouplist[]=$val;
     }
+    reset ($this->grouplist);
   }
 
   function remove_from_parent()
index bbf8b92c38b28587b6fcfc70870717d0ec2192aa..72d5ce1cb57574033e9a92638f97555e53bd313d 100644 (file)
@@ -59,6 +59,8 @@ class posixAccount extends plugin
   var $primaryGroup= 0;
   var $was_trust_account= FALSE;
 
+  var $grouplist  = array();
+  var $ui         = array();
 
   /* attribute list for save action */
   var $attributes= array("homeDirectory", "loginShell", "uidNumber", "gidNumber", "gecos",
@@ -204,6 +206,7 @@ class posixAccount extends plugin
           "regex"           => "*");
       register_global("sysfilter", $sysfilter);
     }
+    $this->ui = get_userinfo();
   }
 
 
@@ -372,7 +375,6 @@ class posixAccount extends plugin
 
     /* Manage group add dialog */
     if ($this->group_dialog){
-      $gd= new groupManagement($this->config, get_userinfo());
 
       /* Save data */
       $groupfilter= get_global("groupfilter");
@@ -402,9 +404,10 @@ class posixAccount extends plugin
       register_global("groupfilter", $groupfilter);
 
       /* Calculate actual groups */
-      $gd->reload(true);
+               
+      $this->reload();
       $glist= array();
-      foreach ($gd->grouplist as $key => $value){
+      foreach ($this->grouplist as $key => $value){
         if (!isset($this->groupMembership[$key])){
           $glist[$key]= $value;
         }
@@ -1067,14 +1070,57 @@ class posixAccount extends plugin
 
   }
 
+ function reload()
+  {
 
+    /* Get config */
+    $groupfilter= get_global('groupfilter');
 
-}
+    /* Set base for all searches */
+    $base= $groupfilter['depselect'];
 
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+    /* Regex filter? */
+    if ($groupfilter['regex'] != ""){
+      $regex= $groupfilter['regex'];
+    } else {
+      $regex= "*";
+    }
+
+    $error = "";
+    $ldap = $this->config->get_ldap_link();    
+
+    $base= get_groups_ou().$base;
+    $res= get_list($this->ui->subtreeACL, "(objectClass=posixGroup)", FALSE, $base, array("cn", "description", "gidNumber"), TRUE);
+    if (preg_match("/size limit/i", $error)){
+      $_SESSION['limit_exceeded']= TRUE;
+    }
 
+    $error = $ldap->error;
+    $this->grouplist = array();
+    foreach ($res as $value){
+        $this->grouplist[$value['gidNumber'][0]]= $value;
+    }
 
+    $tmp=array();
+    foreach($this->grouplist as $tkey => $val ){
+      $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val;
+    }
 
+    /* Sort index */
+    ksort($tmp);
 
+    /* Recreate index array[dn]=cn[description]*/
+    $this->grouplist=array();
+    foreach($tmp as $val){
+      if(isset($val['description'])){
+        $this->grouplist[$val['dn']]=$val['cn'][0]."&nbsp;[".$val['description'][0]."]";
+      }else{
+        $this->grouplist[$val['dn']]=$val['cn'][0];
+      }
+    }
+    reset ($this->grouplist);
+  }
+}
 
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index f7e3207f17a84c1a1539c25ae1c9093d17fce2a2..044ebabce348f2eefa92e455e3667fabd413ea6d 100644 (file)
      <table summary="" style="width:100%;">
       {$alphabet}
      </table>
-    <p class="contentboxb" style="border-top:1px solid #B0B0B0; background-color:#F8F8F8">
-    <input type=checkbox name="primarygroups" value="1" {$primarygroups} onClick="mainform.submit()" title="{t}Select to see groups that are primary groups of users{/t}">{t}Show primary groups{/t}<br>
-    <input type=checkbox name="sambagroups" value="1" {$sambagroups} onClick="mainform.submit()" title="{t}Select to see groups that have samba groups mappings{/t}">{t}Show samba groups{/t}<br>
-    <input type=checkbox name="appgroups" value="1" {$appgroups} onClick="mainform.submit()" title="{t}Select to see groups that have applications configured{/t}">{t}Show application groups{/t}<br>
-    <input type=checkbox name="mailgroups" value="1" {$mailgroups} onClick="mainform.submit()" title="{t}Select to see groups that have mail settings{/t}">{t}Show mail groups{/t}<br>
-    <input type=checkbox name="functionalgroups" value="1" {$functionalgroups} onClick="mainform.submit()" title='{t}Select to see normal groups that have only functional aspects{/t}'>{t}Show functional groups{/t}
- </p>
     <table summary="" width="100%" style="border-top:1px solid #B0B0B0;background-color:#F8F8F8">
                <tr>
                        <td width="50%">