Code

Added "multiple action checkboxes" to object group list.
[gosa.git] / plugins / admin / ogroups / class_termgroup.inc
index 2d3d5e94217b6958006577bbf2ad962b33eb835a..3d9a69b5603c6b336972758f9925f25318a577a9 100644 (file)
@@ -3,9 +3,6 @@
 class termgroup extends plugin
 {
   /* attribute list for save action */
-  var $attributes= array("gotoMode","gotoSyslogServer", "gotoNtpServer");
-  var $objectclasses= array("gotoWorkstationTemplate");
-
   var $members= array();
 
   var $gotoMode           = "locked";
@@ -17,7 +14,7 @@ class termgroup extends plugin
   var $is_account                    = true; 
   var $orig_dn            = "";
   var $didAction          = FALSE;
-  var $mapActions         = array("reboot"          => "",
+  var $mapActions   = array("reboot"          => "localboot",
                             "instant_update"  => "softupdate",
                             "update"          => "sceduledupdate",
                             "reinstall"       => "install",
@@ -25,14 +22,17 @@ class termgroup extends plugin
                             "memcheck"        => "memcheck",
                             "sysinfo"         => "sysinfo");
 
+  var $attributes     = array("gotoMode","gotoSyslogServer", "gotoNtpServer");
+  var $objectclasses  = array("gotoWorkstationTemplate");
+  var $CopyPasteVars  = array("gotoNtpServers","modes","inheritTimeServer","members");
 
-  function termgroup ($config, $dn= NULL)
+  function termgroup ($config, $dn= NULL, $parent= NULL)
   {
     /***************
       Some  initialisations
      ***************/
 
-    plugin::plugin($config, $dn);
+    plugin::plugin($config, $dn, $parent);
 
     $ldap= $config->get_ldap_link();
 
@@ -104,7 +104,7 @@ class termgroup extends plugin
      /* Call common method to give check the hook */
     $message= plugin::check();
 
-    if ($this->acl_is_createable()){
+    if (!$this->acl_is_createable() && $this->dn == "new"){
       $message[]= _("You have no permissions to create a workstation on this 'Base'.");
     }
 
@@ -131,6 +131,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->objcache;
+
+    /* 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->member  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 +195,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 == ""){
@@ -335,7 +383,7 @@ class termgroup extends plugin
           "plDescription" => _("System group"),
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 0,
+          "plPriority"    => 5,
           "plSection"     => array("administration"),
           "plCategory"    => array("ogroups"),
           "plProvidedAcls"=> array(