Code

Added FAIstate update
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 11 Sep 2006 10:42:04 +0000 (10:42 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 11 Sep 2006 10:42:04 +0000 (10:42 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@4640 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/ogroups/class_termgroup.inc

index 855bfadeab90473bc5d25ac673abbaf76abfead2..6b9eb6d7a7e4b37f51ee2189a6661c0ffed3ff20 100644 (file)
@@ -25,6 +25,13 @@ class termgroup extends plugin
                             "memcheck"        => "memcheck",
                             "sysinfo"         => "sysinfo");
 
+  var $mapActions   = array("reboot"          => "localboot",
+                            "instant_update"  => "softupdate",
+                            "update"          => "sceduledupdate",
+                            "reinstall"       => "install",
+                            "rescan"          => "",
+                            "memcheck"        => "memcheck",
+                            "sysinfo"         => "sysinfo");
 
   function termgroup ($config, $dn= NULL)
   {
@@ -131,6 +138,50 @@ class termgroup extends plugin
     $this->handle_post_events("remove");
   }
 
+
+  function update_term_member_FAIstate($act)
+  {
+    /* Get required informations */
+    $og     = $this->parent->by_object['ogroup'];
+    $allobs = $og->allobjects;
+
+    /* Get correct value for FAIstate */
+    $action = $this->mapActions[$act];
+
+    /* Get ldap connection */
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd ($this->config->current['BASE']);
+
+    /* Foreach member of mthis ogroup  ... */
+    foreach($og->mem  as $key ){
+  
+      /* check objectClasses and create attributes array */
+      $attrs = array("FAIstate"=>$action);  
+      for($i = 0; $i < $allobs[$key]['objectClass']['count'] ; $i ++){
+        $attrs['objectClass'][] = $allobs[$key]['objectClass'][$i];
+      }
+      if(($attrs['FAIstate'] != "") && (!in_array("FAIobject",$attrs['objectClass']))){
+        $attrs['objectClass'][] = "FAIobject";
+      }
+      if($attrs['FAIstate'] == ""){
+        $attrs['FAIstate'] = array();
+      }
+
+      /* If this objects is workstation,terminal or server upodate FAIstate */ 
+      if(preg_match("/(w|t|s)/i",$allobs[$key]['type'])){
+        $ldap->cd ($key);
+        $ldap->modify($attrs);
+        show_ldap_error($ldap->get_error(),sprintf(_("Setting action state (FAIstate) failed for object '%s', value was '%s'."),$key,$action));
+        
+        if(!preg_match("/success/i",$ldap->get_error())) {
+          gosa_log("FAILED !! Updating FAIstate to '".$action."' : ".$key);
+        }else{
+          gosa_log("OK.  Updating FAIstate to '".$action."' : ".$key);
+        }
+      }
+    }
+  }
+
   function execute()
   {
     /* Call parent execute */
@@ -151,6 +202,10 @@ class termgroup extends plugin
       }
 
       if (isset($_POST['action'])){
+  
+        /* Update members fai state */
+        $this->update_term_member_FAIstate(trim($_POST['saction']));
+
         $cmd= search_config($this->config->data['TABS'], "workgeneric", "ACTIONCMD");
 
         if ($cmd == ""){