Code

Added action install
[gosa.git] / gosa-plugins / opsi / admin / opsi / class_opsigeneric.inc
index 3b8a1165654360e5a897d963cec4c70c6bdf3bd1..d3c2743bf6c21cfb49053c03ac78f014c7ad8974 100644 (file)
@@ -20,6 +20,7 @@ class opsigeneric extends plugin
   private $init_failed = FALSE;
 
   private $parent_mode = TRUE;
+  private $is_installed = FALSE;
 
   public $mac          = "";
   public $note         = "";
@@ -117,7 +118,7 @@ class opsigeneric extends plugin
     if(!preg_match("/\./",$this->hostId)){
       $messages[] = msgPool::invalid(_("Name"),$this->hostId,"",_("The client name must contain a domain part (e.g. '.company.de')."));
     }
-    if(!tests::is_mac($this->mac)){
+    if(!tests::is_mac($this->mac) || empty($this->mac)){
       $messages[] = msgPool::invalid(_("MAC address"),$this->mac,"","00:0C:7F:31:33:F1");
     }
     return($messages);
@@ -144,6 +145,7 @@ class opsigeneric extends plugin
     }
 
     $smarty->assign("parent_mode", $this->parent_mode);
+    $smarty->assign("is_installed", $this->is_installed);
     $smarty->assign("init_failed",FALSE);
     $divSLP = new divSelectBox();
     $divALP = new divSelectBox();
@@ -264,7 +266,13 @@ class opsigeneric extends plugin
   }
 
   public function remove_from_parent()
-  {}
+  {
+    $this->opsi->del_client($this->hostId);
+    if($this->opsi->is_error()){
+      msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
+      return;
+    }
+  }
 
 
   public function save_object()
@@ -294,6 +302,18 @@ class opsigeneric extends plugin
         $this->hostId = get_post('hostId');
       }
 
+      /* Send actions like 'install' or 'wake' to the si server 
+       */
+      if(isset($_POST['opsi_action']) && isset($_POST['opsi_trigger_action']) && $this->parent_mode){
+        $action = $_POST['opsi_action'];
+        if(in_array($action,array("wake","install"))){
+          $this->opsi->send_action($action,$this->hostId,$this->mac);
+          if($this->opsi->is_error()){
+            msg_dialog::display(_("Error"),msgPool::siError($this->opsi->get_error()),ERROR_DIALOG);
+          }
+        }
+      }
+
       if(isset($_POST['opsi_netboot_product'])){
         $SNP = trim($_POST['opsi_netboot_product']);
         if(isset($this->a_availableNetbootProducts[$SNP])){
@@ -328,6 +348,13 @@ class opsigeneric extends plugin
     }
   }
 
+
+  function install_client()
+  {
+
+  }
+
+
   /* Return plugin informations for acl handling */
   static function plInfo()
   {