Code

Added more logging, and speed improvements
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 14 Sep 2006 12:37:44 +0000 (12:37 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 14 Sep 2006 12:37:44 +0000 (12:37 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@4663 594d385d-05f5-0310-b6e9-bd551577e9d8

include/class_ldap.inc
include/class_tabs.inc
plugins/admin/groups/tabs_group.inc
plugins/personal/posix/class_posixAccount.inc

index 4f0fd2b455084622930ec08c03439e2b292320be..6473bc74e75623ad1a1877177f466e8553d86608 100644 (file)
@@ -197,6 +197,8 @@ class LDAP{
         }
       }
 
+      $this->log("LDAP operation: time=".get_MicroTimeDiff($start,microtime())." operation=search('".$this->fix($this->basedn)."', '$filter')");
+
       return($this->sr);
     }else{
       $this->error = "Could not connect to LDAP server";
@@ -229,6 +231,8 @@ class LDAP{
         }
       }
 
+      $this->log("LDAP operation: time=".get_MicroTimeDiff($start,microtime())." operation=ls('".$this->fix($basedn)."', '$filter')");
+
       return($this->sr);
     }else{
       $this->error = "Could not connect to LDAP server";
@@ -240,12 +244,14 @@ class LDAP{
   {
     if($this->hascon){
       if ($this->reconnect) $this->connect();
+      $start = microtime();
       $this->clearResult();
       $filter = "(objectclass=*)";
       $this->sr = @ldap_read($this->cid, $this->fix($dn), $filter,$attrs);
       $this->error = @ldap_error($this->cid);
       $this->resetResult();
       $this->hasres=true;
+      $this->log("LDAP operation: time=".get_MicroTimeDiff($start,microtime())." operation=cat('".$this->fix($dn)."')");
       return($this->sr);
     }else{
       $this->error = "Could not connect to LDAP server";
@@ -390,8 +396,10 @@ class LDAP{
   {
     if($this->hascon){
       if ($this->reconnect) $this->connect();
+      $start= microtime();
       $r = @ldap_delete($this->cid, $this->fix($deletedn));
       $this->error = @ldap_error($this->cid);
+      $this->log("LDAP operation: time=".get_MicroTimeDiff($start,microtime())." operation=delete('".$this->fix($delettedn)."')");
       return($r ? $r : 0);
     }else{
       $this->error = "Could not connect to LDAP server";
@@ -621,8 +629,10 @@ class LDAP{
     }
     if($this->hascon){
       if ($this->reconnect) $this->connect();
+      $start= microtime();
       $r = @ldap_modify($this->cid, $this->fix($this->basedn), $attrs);
       $this->error = @ldap_error($this->cid);
+      $this->log("LDAP operation: time=".get_MicroTimeDiff($start,microtime())." operation=modify('$this->basedn')");
       return($r ? $r : 0);
     }else{
       $this->error = "Could not connect to LDAP server";
@@ -634,8 +644,10 @@ class LDAP{
   {
     if($this->hascon){
       if ($this->reconnect) $this->connect();
+      $start= microtime();
       $r = @ldap_add($this->cid, $this->fix($this->basedn), $attrs);
       $this->error = @ldap_error($this->cid);
+      $this->log("LDAP operation: time=".get_MicroTimeDiff($start,microtime())." operation=add('$this->basedn')");
       return($r ? $r : 0);
     }else{
       $this->error = "Could not connect to LDAP server";
@@ -1139,6 +1151,16 @@ function gen_xls ($dn, $filter= "(objectClass=*)", $attributes= array('*'), $rec
          return $objectclasses;
   }
 
+
+  function log($string)
+  {
+    $cfg= $_SESSION['config'];
+    if (isset($cfg->current['LDAPSTATS']) && preg_match('/true/i', $cfg->current['LDAPSTATS'])){
+        syslog (LOG_INFO, $string);
+    }
+  }
+
+
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index e0e8dbe422b0bf555c7fe25940a04bdf3b5aa0bf..5c3204571425c628e8d6118e679ca81ea6d55fa3 100644 (file)
@@ -32,7 +32,7 @@ class tabs
   var $by_object= array();
   var $SubDialog = false;
 
-  function tabs($config, $data, $dn)
+  function tabs($config, $data, $dn, $gui= true)
   {
        /* Save dn */
        $this->dn= $dn;
@@ -40,7 +40,11 @@ class tabs
 
        foreach ($data as $tab){
                $this->by_name[$tab['CLASS']]= $tab['NAME'];
-               $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn);
+               if ($gui){
+                       $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn);
+               } else {
+                       $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, false);
+               }
                $this->by_object[$tab['CLASS']]->parent= &$this;
 
                /* Initialize current */
index a4d0279dbd444368a4ab094b919d4a982f394eea..8357a0e4235685016690ac7b6306ffdd443ed25d 100644 (file)
@@ -3,9 +3,9 @@
 class grouptabs extends tabs
 {
 
-       function grouptabs($config, $data, $dn)
+       function grouptabs($config, $data, $dn, $gui= true)
        {
-               tabs::tabs($config, $data, $dn);
+               tabs::tabs($config, $data, $dn, $gui);
                $baseobject= $this->by_object['group'];
                foreach ($this->by_object as $name => $obj){
                        if(isset($obj->parent)){
index 46c2c299a7404824f3b2c1d8c8df09fad8c8b610..904a11c2467d317af018f187f3dd0fcac2c06d56 100644 (file)
@@ -864,7 +864,7 @@ class posixAccount extends plugin
     /* Take care about groupMembership values: add to groups */
     foreach ($this->groupMembership as $key => $value){
       if (!isset($this->savedGroupMembership[$key])){
-        $g= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $key);
+        $g= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $key, false);
         $g->by_object['group']->addUser($this->uid);
         $g->save();
       }