Code

Added Log to glpi extension
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 15 May 2007 06:40:38 +0000 (06:40 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 15 May 2007 06:40:38 +0000 (06:40 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6373 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_componentGeneric.inc
plugins/admin/systems/class_glpiAccount.inc
plugins/admin/systems/class_glpiPrinterAccount.inc

index 2e6f7029814a0d49e6628220ee64de668b5fb49d..be0a560125f0c3640cc1686b7b5b4c76c3b2b43c 100644 (file)
@@ -37,6 +37,10 @@ class componentGeneric extends plugin
     $this->netConfigDNS = new termDNS($this->config,$this->dn,$this->objectclasses, true);
     /* Save dn for later references */
     $this->orig_dn= $this->dn;
+
+    if($this->is_account){
+      @log::log("view","component/".get_class($this),$this->dn);
+    }
   }
 
   function execute()
@@ -122,6 +126,9 @@ class componentGeneric extends plugin
     $ldap= $this->config->get_ldap_link();
     $this->netConfigDNS->remove_from_parent();
     $ldap->rmdir($this->dn);
+    
+    @log::log("remove","component/".get_class($this),$this->dn,$this->attributes,$ldap->get_error());
+
     show_ldap_error($ldap->get_error(), sprintf(_("Removing of system component/generic with dn '%s' failed."),$this->dn));
     $this->handle_post_events("remove");
 
@@ -230,7 +237,9 @@ class componentGeneric extends plugin
       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
       $ldap->cd($this->dn);
       $ldap->add($this->attrs);
+      @log::log("create","component/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
       $this->handle_post_events("add");
+      
     } else {
       if ($this->orig_dn != $this->dn){
         $this->move($this->orig_dn, $this->dn);
@@ -239,7 +248,7 @@ class componentGeneric extends plugin
       $ldap->cd($this->dn);
       $this->cleanup();
       $ldap->modify ($this->attrs); 
-
+      @log::log("modify","component/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
       $this->handle_post_events("modify");
     }
 
index 12e677ba6cd337070c02f8cdbd82bd5ab39ca631..937323083d3a6aa346e565916c11ffd54955e831 100644 (file)
@@ -44,7 +44,7 @@ class glpiAccount extends plugin
   var $objectclasses= array("whatever");
 
   /* Used to remember if this was an account (simply: is this an edited entry) */
-  var $initialy_was_account = false;
+  var $initially_was_account = false;
 
   /* Remember current dialog */
   var $edit_type            = false;
@@ -110,9 +110,11 @@ class glpiAccount extends plugin
     /* set defaults */
     $this->name                 = $this->dn;
     $this->orig_dn              = $this->dn;
-    $this->initialy_was_account = $this->is_account;
-
+    $this->initially_was_account = $this->is_account;
 
+    if($this->is_account){
+      @log::log("view","undefined/".get_class($this),$this->dn);
+    }
   }
 
   function execute()
@@ -667,11 +669,13 @@ class glpiAccount extends plugin
     }
     if(function_exists("mysql_pconnect")){
       $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
-      if($this->initialy_was_account){
+      if($this->initially_was_account){
         $this->handle->removeComputerInformations($this->dn); 
+        @log::log("remove","undefined/".get_class($this),$this->dn);
       }
     }else{
       print_red(_("Can't remove glpi account, while mysql extension is missing."));
+      @log::log("remove","undefined/".get_class($this),$this->dn,array(),_("Can't remove glpi account, while mysql extension is missing."));
     }
   
   }
@@ -714,6 +718,7 @@ class glpiAccount extends plugin
     return ($message);
   }
 
+
   /* Save to LDAP */
   function save()
   {
@@ -728,16 +733,19 @@ class glpiAccount extends plugin
       $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
 
       /* check if we have to update, add */
-      if($this->initialy_was_account&&$this->is_account){
+      if($this->initially_was_account&&$this->is_account){
         $this->handle->updateComputerInformations($attrs,$this->orig_dn);
+        @log::log("modify","undefined/".get_class($this),$this->dn);
       }elseif($this->is_account){
         $this->handle->addComputerInformations($attrs,$this->dn);
+        @log::log("create","undefined/".get_class($this),$this->dn);
       }
       $tmp = $this->handle->getComputerInformations($this->dn);
       $this->handle->addDevicesToComputer($this->usedDevices,$tmp[0]['ID']);
     }
   }
 
+
   /* Return used attachments */
   function getUsedAttachments($divlist = false)
   {
index 68232a83267eab8e001a2cacd886db3237861f51..fb8ce7e49ac8acbeb2b17e9e5ccf35c24fa7efa1 100644 (file)
@@ -125,6 +125,10 @@ class glpiPrinterAccount extends plugin
     $this->name                 = $this->dn;
     $this->orig_dn              = $this->dn;
     $this->initially_was_account = $this->is_account;
+
+    if($this->is_account){
+      @log::log("view","printer/".get_class($this),$this->dn); 
+    }
   }
 
   function execute()
@@ -648,7 +652,8 @@ class glpiPrinterAccount extends plugin
   {
     $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
     if($this->initially_was_account){
-      $this->handle->removePrinterInformations($this->dn); 
+      $this->handle->removePrinterInformations($this->dn);
+      @log::log("remove","printer/".get_class($this),$this->dn); 
     }
   }
 
@@ -709,8 +714,10 @@ class glpiPrinterAccount extends plugin
       $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
       if($this->initially_was_account&&$this->is_account){
         $this->handle->updatePrinterInformations($attrs,$this->dn);
+        @log::log("modify","printer/".get_class($this),$this->dn); 
       }elseif($this->is_account){
         $this->handle->addPrinterInformations($attrs,$this->dn);
+        @log::log("create","printer/".get_class($this),$this->dn); 
       }
       $tmp = $this->handle->getPrinterInformations($this->dn);
       $this->handle->addAttachmentsToPrinter($this->usedAttachments,$tmp[0]['ID']);