Code

Added logging to FAI
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 16 May 2007 08:20:20 +0000 (08:20 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 16 May 2007 08:20:20 +0000 (08:20 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6390 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/fai/class_faiHook.inc
plugins/admin/fai/class_faiManagement.inc
plugins/admin/fai/class_faiPackage.inc
plugins/admin/fai/class_faiPartitionTable.inc
plugins/admin/fai/class_faiProfile.inc
plugins/admin/fai/class_faiScript.inc
plugins/admin/fai/class_faiTemplate.inc
plugins/admin/fai/class_faiVariable.inc

index 9fdb2b15de0f1c98dc14f1ceab8470efb0b317e9..1fdbd52ff5a253412cbc9f6f8dd6f5c05fb89e6f 100644 (file)
@@ -82,6 +82,8 @@ class faiHook extends plugin
       }
     }
     $this->ui = get_userinfo();
+
+    @log::log("view","fai/".get_class($this),$this->dn);
   }
 
 
@@ -389,6 +391,8 @@ class faiHook extends plugin
 
     prepare_to_save_FAI_object($use_dn,array(),true);
 
+    @log::log("remove","fai/".get_class($this),$use_dn,$this->attributes);
+
     foreach($this->SubObjects as $name => $obj){
 #      $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $obj['dn']);
       $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $obj['dn']);
@@ -436,6 +440,12 @@ class faiHook extends plugin
     prepare_to_save_FAI_object($this->dn,$this->attrs);
     show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/hook with dn '%s' failed."),$this->dn));
 
+    if($this->initially_was_account){
+      @log::log("modify","fai/".get_class($this),$this->dn,$this->attributes);
+    }else{
+      @log::log("create","fai/".get_class($this),$this->dn,$this->attributes);
+    }
+
     /* Do object tagging */
     $this->handle_object_tagging();
 
index 71914a044b60d81aa981545f010e8f11b550bf84..6934a0cc428cc6fb058fe496856b02b91a42ab04 100644 (file)
@@ -288,44 +288,48 @@ class faiManagement extends plugin
      ****************/
 
                /* Deltetion was confirmed, so delete this entry
-                */
-               if (isset($_POST['delete_terminal_confirm'])){
+     */
+    if (isset($_POST['delete_terminal_confirm'])){
 
-                       /* Some nice guy may send this as POST, so we've to check
-                          for the permissions again. */
+      /* Some nice guy may send this as POST, so we've to check
+         for the permissions again. */
 
       /* Find out more about the object type */
       $ldap      = $this->config->get_ldap_link();
       $ldap->cat($this->dn, array('objectClass'));
-      $attrs   = $ldap->fetch();
-      $type      = $this->get_type($attrs);                    
+      if($ldap->count()){
+        $attrs = $ldap->fetch();
+        $type    = $this->get_type($attrs);                    
 
-      $acl  = $this->ui->get_permissions($this->dn,"fai/".$type[1]);
-      if(preg_match("/d/",$acl)){
+        $acl  = $this->ui->get_permissions($this->dn,"fai/".$type[1]);
+        if(preg_match("/d/",$acl)){
 
-        $this->dialog = new $type[0]($this->config,    $this->config->data['TABS'][$type[2]], $this->dn,"fai");
-        $this->dialog->set_acl_base($this->dn);
-        $this->dialog->by_object[$type[1]]->remove_from_parent ();
-        unset ($this->dialog);
-        gosa_log ("FAI class '".$this->dn."' has been tagged as removed");
-        $this->dialog= NULL;
-        $to_del = clean_up_releases($this->dn);
-        save_release_changes_now();
+          $this->dialog = new $type[0]($this->config,  $this->config->data['TABS'][$type[2]], $this->dn,"fai");
+          $this->dialog->set_acl_base($this->dn);
+          $this->dialog->by_object[$type[1]]->remove_from_parent ();
+          unset ($this->dialog);
+          gosa_log ("FAI class '".$this->dn."' has been tagged as removed");
+          $this->dialog= NULL;
+          $to_del = clean_up_releases($this->dn);
+          save_release_changes_now();
 
-        foreach($to_del as $dn){
-          $ldap->rmdir_recursive($dn);
-          gosa_log(sprintf(_("Release cleanup : Removing object (tagged as remvoed) that is no longer in use '%s'."),$dn));
-        }
+          foreach($to_del as $dn){
+            $ldap->rmdir_recursive($dn);
+            gosa_log(sprintf(_("Release cleanup : Removing object (tagged as remvoed) that is no longer in use '%s'."),$dn));
+          }
 
-      } else {
+        } else {
 
-        /* Normally this shouldn't be reached, send some extra
-           logs to notify the administrator */
-        print_red (_("You are not allowed to delete this component!"));
-        gosa_log ("Warning: '".$this->ui->uid."' tried to trick system ".
-            "deletion.");
-      }
+          /* Normally this shouldn't be reached, send some extra
+             logs to notify the administrator */
+          print_red (_("You are not allowed to delete this component!"));
+          gosa_log ("Warning: '".$this->ui->uid."' tried to trick system ".
+              "deletion.");
+        }
 
+      }else{
+        print_red(sprintf(_("Object could not be deleted '%s', object does not exist."),$this->dn));
+      }
       /* Remove lock file after successfull deletion */
       del_lock ($this->dn);
     }
index 9e45b692ed8751eeea978efbdc4761052d28ed98..37b7f128a08f2c919daea22c5ef331ded99703f5 100644 (file)
@@ -37,7 +37,7 @@ class faiPackage extends plugin
   var $SubObjects       = array();  // All leafobjects of this object
 
   var $FAIdebianRelease          = ""; // The selected release
-  var $FAIdebianSection          = ""; // selected section
+  var $FAIdebianSection          = array(); // selected section
   var $FAIinstallMethod          = "aptitude"; // hard coded
   var $mirror                    = ""; // selected mirror
 
@@ -134,6 +134,7 @@ class faiPackage extends plugin
           $this->ConfiguredPackages[$attr['FAIpackage'][0]][$attr['FAIvariable'][0]]=$tmp;
         }
       }
+      @log::log("view","fai/".get_class($this),$this->dn);
     }
 
     if (isset($this->attrs['FAIdebianSection']['count'])){
@@ -338,6 +339,8 @@ class faiPackage extends plugin
 
     prepare_to_save_FAI_object($use_dn,array(),true);
 
+    @log::log("remove","fai/".get_class($this),$use_dn,$this->attributes);
+
     foreach($this->ConfiguredPackages as $pkgname => $attrs){
       foreach($attrs as $name => $attr){
         $pkgdn =  "FAIvariable=".$name.",".$this->dn;
@@ -417,7 +420,8 @@ class faiPackage extends plugin
     return($a_ret);
   }
 
-  function genPkgs(){
+  function genPkgs()
+  {
     /* Generate a list off available packages for this mirror, section and release
      */
     /* Only read this file if it wasn't read before */
@@ -473,6 +477,12 @@ class faiPackage extends plugin
 
     prepare_to_save_FAI_object($this->dn,$this->attrs);
     show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/package list with dn '%s' failed."),$this->dn));
+    
+    if($this->initially_was_account){
+      @log::log("modify","fai/".get_class($this),$this->dn,$this->attributes);
+    }else{
+      @log::log("create","fai/".get_class($this),$this->dn,$this->attributes);
+    }
 
     /* Do object tagging */
     $this->handle_object_tagging();
index 550e719991cc036a9955d983edb24279c90b7179..cb8651c22f4affc24349027df515bf5f589d4274 100644 (file)
@@ -99,6 +99,8 @@ class faiPartitionTable extends plugin
           $this->disks[$name]['partitions'][$partition['FAIpartitionNr']] = $partition; 
         }  
       }
+  
+      @log::log("view","fai/".get_class($this),$this->dn);
     }
     ksort($this->disks);
   }
@@ -342,7 +344,9 @@ class faiPartitionTable extends plugin
     }
 
     prepare_to_save_FAI_object($use_dn,array(),true);
-    
+
+    @log::log("remove","fai/".get_class($this),$use_dn,$this->attributes);   
     foreach($this->disks as $disk){
 
       $disk_dn = "cn=".$disk['cn'].",".$this->dn;
@@ -406,7 +410,13 @@ class faiPartitionTable extends plugin
 
     prepare_to_save_FAI_object($this->dn,$this->attrs);
     show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/partition table with dn '%s' failed."),$this->dn));
-  
+
+    if($this->initially_was_account){
+      @log::log("modify","fai/".get_class($this),$this->dn,$this->attributes);
+    }else{
+      @log::log("create","fai/".get_class($this),$this->dn,$this->attributes);
+    }
     /* Do object tagging */
     $this->handle_object_tagging();
   
index 568d120f2b3e55c9da471de7ae8284cba3cc6a43..52d87d9e46b39fad47069c1660e55998b17f9e18 100644 (file)
@@ -100,6 +100,7 @@ class faiProfile extends plugin
 
     if($dn != "new"){
       $this->dn =$dn;
+      @log::log("view","fai/".get_class($this),$this->dn);
     }
     $this->old_cn   = $this->cn;
   }
@@ -369,6 +370,7 @@ class faiProfile extends plugin
       $use_dn = $this->dn;
     }
 
+    @log::log("remove","fai/".get_class($this),$use_dn,$this->attributes);
     prepare_to_save_FAI_object($use_dn,array(),true);
     $this->handle_post_events("remove");    
   }
@@ -427,7 +429,13 @@ class faiProfile extends plugin
     $this->attrs['FAIclass']=trim($this->FAIclass);
 
     prepare_to_save_FAI_object($this->dn,$this->attrs);
-    
+   
+    if($this->initially_was_account){
+      @log::log("modify","fai/".get_class($this),$this->dn,$this->attributes);
+    }else{
+      @log::log("create","fai/".get_class($this),$this->dn,$this->attributes);
+    }
     show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/profile with dn '%s' failed."),$this->dn));
 
     /* Do object tagging */
index c130a568d6cba899f26716d82ed72edf824ce727..edb3a03c8f25c5a2dd521abfc325d9f6559ed1af 100644 (file)
@@ -84,6 +84,8 @@ class faiScript extends plugin
         $objects                = $this->get_object_attributes($objects,$this->subAttributes);
         $this->SubObjects[$objects['cn']] = $objects;
       }
+    
+      @log::log("view","fai/".get_class($this),$this->dn);
     }
     $this->ui = get_userinfo();
   }
@@ -383,7 +385,9 @@ class faiScript extends plugin
       if($_SESSION['faifilter']['branch'] == "main"){
         $use_dn = $this->dn;
       }
-    
+   
+      @log::log("remove","fai/".get_class($this),$use_dn,$this->attributes);
       prepare_to_save_FAI_object($use_dn,array(),true);
       
       foreach($this->SubObjects as $name => $obj){
@@ -433,6 +437,12 @@ class faiScript extends plugin
     prepare_to_save_FAI_object($this->dn,$this->attrs);
     show_ldap_error($ldap->get_error(), sprintf(_("Creating of FAI/script with dn '%s' failed."),$this->dn));
 
+    if($this->initially_was_account){
+      @log::log("modify","fai/".get_class($this),$this->dn,$this->attributes);
+    }else{
+      @log::log("create","fai/".get_class($this),$this->dn,$this->attributes);
+    }
+
     /* Do object tagging */
     $this->handle_object_tagging();
 
index 83d556da9e6dcd4bb35f1892e8cd9dc24ea57071..8de436e3a7a23ad1b1d037305a8b40c6a43ccf8f 100644 (file)
@@ -82,6 +82,8 @@ class faiTemplate extends plugin
         $objects                = $this->get_object_attributes($objects,$this->subAttributes);
         $this->SubObjects[$objects['cn']] = $objects;
       }
+  
+      @log::log("view","fai/".get_class($this),$this->dn);
     }
     $this->ui = get_userinfo();
   }
@@ -371,6 +373,7 @@ class faiTemplate extends plugin
     }
 
     prepare_to_save_FAI_object($use_dn,array(),true);
+    @log::log("remove","fai/".get_class($this),$use_dn,$this->attributes);
 
     foreach($this->SubObjects as $name => $obj){
 #      $use_dn = str_ireplace( get_release_dn($this->dn), $_SESSION['faifilter']['branch'], $obj['dn']);
@@ -414,6 +417,12 @@ class faiTemplate extends plugin
     prepare_to_save_FAI_object($this->dn,$this->attrs);
     show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/template with dn '%s' failed."),$this->dn));
 
+    if($this->initially_was_account){
+      @log::log("modify","fai/".get_class($this),$this->dn,$this->attributes);
+    }else{
+      @log::log("create","fai/".get_class($this),$this->dn,$this->attributes);
+    }
+
     /* Do object tagging */
     $this->handle_object_tagging();
 
index 60baec911497eab02a7b911977eeb5fda39d0c57..18d4c0368c634d6517081e70b9ff0e67d3be119c 100644 (file)
@@ -85,6 +85,8 @@ class faiVariable extends plugin
         $this->SubObjects[$object['cn'][0]]['status']      = "edited";
         $this->SubObjects[$object['cn'][0]]['dn']          = $object['dn'];
       }
+
+      @log::log("view","fai/".get_class($this),$this->dn);
     }
     $this->ui = get_userinfo();
   }
@@ -280,8 +282,9 @@ class faiVariable extends plugin
       if($_SESSION['faifilter']['branch'] == "main"){
         $use_dn = $this->dn;
       }
-
+  
       prepare_to_save_FAI_object($use_dn,array(),true);
+      @log::log("remove","fai/".get_class($this),$use_dn,$this->attributes);
 
       foreach($this->SubObjects as $name => $obj){
         $use_dn = preg_replace("/".normalizePreg(get_release_dn($this->dn))."/i", $_SESSION['faifilter']['branch'], $obj['dn']);
@@ -328,6 +331,12 @@ class faiVariable extends plugin
     $ldap = $this->config->get_ldap_link();
     prepare_to_save_FAI_object($this->dn,$this->attrs);
     show_ldap_error($ldap->get_error(), sprintf(_("Saving of FAI/variable with dn '%s' failed."),$this->dn));
+
+    if($this->initially_was_account){
+      @log::log("modify","fai/".get_class($this),$this->dn,$this->attributes);
+    }else{
+      @log::log("create","fai/".get_class($this),$this->dn,$this->attributes);
+    }
  
     /* Do object tagging */
     $this->handle_object_tagging();