Code

Added speed improvements
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 30 Jan 2006 16:02:31 +0000 (16:02 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 30 Jan 2006 16:02:31 +0000 (16:02 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2600 594d385d-05f5-0310-b6e9-bd551577e9d8

html/main.php
plugins/admin/departments/class_departmentManagement.inc
plugins/admin/groups/class_groupManagement.inc
plugins/admin/systems/class_selectUserToPrinterDialog.inc

index 958d826417d8decabce122496c9b9bca1772d49a..dd02c0f7a215657231d1df21072c5ebc691872ac 100644 (file)
@@ -229,7 +229,10 @@ if ($_SERVER["REQUEST_METHOD"] == "POST"){
 /* Load department list when plugin has changed. That is some kind of
    compromise between speed and beeing up to date */
 if (isset($_GET['reset'])){
-  $config->departments= get_departments();
+  if (!isset($_SESSION['cached_departments'])){
+    $_SESSION['cached_departments']= get_departments();
+  }
+  $config->departments= $_SESSION['cached_departments'];
   $config->make_idepartments ();
   if (isset($_SESSION['objectinfo'])){
     unset ($_SESSION['objectinfo']);
index 39c5eb93c860eeb24bc7028727470367a3d1484d..2a1e2e523a85bdc5efbe9d061dff3a96d6cc2b7f 100644 (file)
@@ -414,6 +414,9 @@ class departmentManagement extends plugin
                }
                natcasesort ($this->departments);
                reset ($this->departments);
+
+               /* Unset global department list */
+               unset($_SESSION['cached_departments']);
        }
 
        function remove_from_parent()
index 5ce272b32f181f4eca2f30a1241109dff2fe294d..84e7eda1ecf50bf2a84f9fcf715af18d3562d343 100644 (file)
@@ -492,11 +492,13 @@ class groupManagement extends plugin
     /* What are primary groups? */
     $primaries= array();
     $ldap= $this->config->get_ldap_link();
-    $ldap->cd($base);
-    $ldap->search("(&(uid=$regex)(!(uid=*$))(objectClass=posixAccount)(gidNumber=*))", array("gidNumber", "cn"));
-    show_ldap_error($ldap->get_error());
-    while ($attrs= $ldap->fetch()){
-      $primaries[$attrs['gidNumber'][0]]= $attrs['cn'][0];
+    if (!isset($this->config->data['MAIN']['NOPRIMARYGROUP'])){
+      $ldap->cd($base);
+      $ldap->search("(&(uid=$regex)(!(uid=*$))(objectClass=posixAccount)(gidNumber=*))", array("gidNumber", "cn"));
+      show_ldap_error($ldap->get_error());
+      while ($attrs= $ldap->fetch()){
+        $primaries[$attrs['gidNumber'][0]]= $attrs['cn'][0];
+      }
     }
 
     /* Set filter depending on selection */
index 20ee7ea22ac972993098a51637bf3c9c10fe59cc..923f9454f0f84bc628fb896f73941d35a51a454d 100644 (file)
@@ -18,6 +18,7 @@ class selectUserToPrinterDialog extends plugin
   var $searchObjects        = "";
   var $searchAttrs          = "";
   var $searchAppend         = "";
+  var $baseAddition         = "";
   var $type                 = "";
   
   function selectUserToPrinterDialog ($config, $dn= NULL,$type=false )
@@ -30,21 +31,25 @@ class selectUserToPrinterDialog extends plugin
         $this->searchObjects = "(objectClass=gosaAccount)(!(uid=*$))";
         $this->searchAttrs   = array("cn","uid");
         $this->searchAppend  = "uid"; 
+        $this->baseAddition  = get_people_ou(); 
           ;break;
       case "AddGroup" :
         $this->searchObjects = "(objectClass=posixGroup)";
         $this->searchAttrs   = array("cn","description");
         $this->searchAppend  = "cn"; 
+        $this->baseAddition  = get_groups_ou(); 
           ;break;
       case "AddAdminUser" : 
         $this->searchObjects = "(objectClass=gosaAccount)(!(uid=*$))";
         $this->searchAttrs   = array("cn","uid");
         $this->searchAppend  = "uid"; 
+        $this->baseAddition  = get_people_ou(); 
           ;break;
       case "AddAdminGroup" :
         $this->searchObjects = "(objectClass=posixGroup)";
         $this->searchAttrs   = array("cn","description");
         $this->searchAppend  = "cn"; 
+        $this->baseAddition  = get_groups_ou(); 
           ;break;
     }
     $this->type = $type;
@@ -70,11 +75,12 @@ class selectUserToPrinterDialog extends plugin
       $this->regex=preg_replace("/\*\*/","*",$this->regex);
     }
 
+    $tmp_printers= $this->getPrinter();
     $smarty->assign("regexPrinter"        , $this->regex);
     $smarty->assign("deplistPrinter"      , $this->config->idepartments);//deplist);
     $smarty->assign("depselectPrinter"    , $this->depselect);
-    $smarty->assign("gotoPrinters"        , $this->getPrinter());
-    $smarty->assign("gotoPrinterKeys"     , array_flip($this->getPrinter()));
+    $smarty->assign("gotoPrinters"        , $tmp_printers);
+    $smarty->assign("gotoPrinterKeys"     , array_flip($tmp_printers));
     $smarty->assign("apply"               , apply_filter());
     $smarty->assign("alphabet"            , generate_alphabet());
     $smarty->assign("search_image"        , get_template_path('images/search.png'));
@@ -115,7 +121,8 @@ class selectUserToPrinterDialog extends plugin
     $a_return=array();
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->depselect);
-    $ldap->search("(&".$this->searchObjects."(cn=".$this->regex."))",$this->searchAttrs);
+    #$ldap->search("(&".$this->searchObjects."(cn=".$this->regex."))", $this->depselect, $this->searchAttrs);
+    $ldap->ls("(&".$this->searchObjects."(cn=".$this->regex."))", $this->baseAddition.$this->depselect, $this->searchAttrs);
     while($printer = $ldap->fetch()){
       if(($detailed ==true)){
         if(isset($printer[$this->searchAppend])){
@@ -135,9 +142,5 @@ class selectUserToPrinterDialog extends plugin
   }
 }
 
-
-
-
-
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>