Code

Updated termDNS
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 21 Feb 2008 09:50:15 +0000 (09:50 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 21 Feb 2008 09:50:15 +0000 (09:50 +0000)
-Class initializes up to 20 times faster now ...

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9006 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/systems/admin/systems/class_systemManagement.inc
gosa-plugins/systems/admin/systems/class_termDNS.inc

index e49653d78523dfdac10151dadcf8c159f7c29edf..5cf90e187f49ac31703e36e61f9d037ae66e006c 100644 (file)
@@ -63,7 +63,7 @@ class systems extends plugin
     /* Call parent execute */
     plugin::execute();
 
-    session::set('LOCK_VARS_TO_USE',array("/^system_edit_/i","/^system_del_/","/^act/","/^id/","/^item_selected/","/^remove_multiple_systems/"));
+    session::set('LOCK_VARS_TO_USE',array("/^system_edit_/i","/^system_del_/","/^act/","/^id/","/^item_selected/","/^remove_multiple_systems/","/^menu_action/"));
 
     /********************
       Check for functional posts, edit|delete|add|... system devices 
@@ -488,11 +488,11 @@ class systems extends plugin
 
         foreach($ids as $id){
           $dn = $this->terminals[$id]['dn'];
-          if (($user= get_lock($dn)) != ""){
-            return(gen_locked_message ($user, $dn));
-          }
           $this->dns[$id] = $dn;
         }
+        if ($user= get_multiple_locks($this->dns)){
+          return(gen_locked_message($user,$this->dns));
+        }
 
         $dns_names = "<br><pre>";
         foreach($this->dns as $dn){
index 81dcc4eccc95e1b86fdea2e681813a218bf4b934..b4a6a7962b89326affc5a3bb9dbb35b1146815fd 100644 (file)
@@ -138,18 +138,42 @@ class termDNS extends plugin
       }
     }
 
-    /* Create a list of used mac and ip addresses */
+    /* Create a list of used mac and ip addresses.
+
+       ! We use this optically huge amount of code to fetch all 
+       Mac and IP addresses, because a simple search for mac and IP
+       over the whole ldap server was 10 to 20 times slower.
+     */
+    $deps  = array();
+    $ou = preg_replace("/,.*$/","",get_ou("systemsou"));
+    $a_ous = array(get_ou("serverou"),
+                  get_ou("terminalou"),
+                  get_ou("workstationou"),
+                  get_ou("printerou"),
+                  get_ou("phoneou"),
+                  get_ou("componentou"));
+  
     $ldap = $this->config->get_ldap_link();
     $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(|(macAddress=*)(ipHostNumber=*))",array("macAddress","ipHostNumber"));
+    $ldap->search("(&(objectClass=organizationalUnit)(".$ou."))",array("dn"));
     while($attrs = $ldap->fetch()){
-      if(isset($attrs['ipHostNumber'][0])){
-        $this->used_ip_mac["ip:".$attrs['ipHostNumber'][0]] = "ip:".$attrs['ipHostNumber'][0];
+      foreach($a_ous as $allowed){
+        $deps[] = $allowed.$attrs['dn'];
       }
-      if(isset($attrs['macAddress'][0])){
-        $this->used_ip_mac["mac:".$attrs['macAddress'][0]] = "mac:".$attrs['macAddress'][0];
-      }
-    } 
+    }
+
+    foreach($deps as $dep){
+      $ldap->cd($dep);
+      $ldap->search("(|(macAddress=*)(ipHostNumber=*))",array("macAddress","ipHostNumber"));
+      while($attrs = $ldap->fetch()){
+        if(isset($attrs['ipHostNumber'][0])){
+          $this->used_ip_mac["ip:".$attrs['ipHostNumber'][0]] = "ip:".$attrs['ipHostNumber'][0];
+        }
+        if(isset($attrs['macAddress'][0])){
+          $this->used_ip_mac["mac:".$attrs['macAddress'][0]] = "mac:".$attrs['macAddress'][0];
+        }
+      } 
+    }
 
     /* Save initial ip and mac values, to be able 
         check if the used values are already in use */