Code

Renamed opsi class.
[gosa.git] / gosa-plugins / opsi / admin / opsi / class_opsiware.inc
index 6612ae46a075c88b17dcf182adf70be7232443cc..5f570576bd693c48583e6dfe4242d3162b07b14e 100644 (file)
@@ -1,25 +1,60 @@
 <?php
 
-class opsiware extends plugin
+class opsiWare extends plugin
 {
   private $opsi;
   private $SW_info;
   private $HW_info;
   private $hostId;
+  private $type = 0;
+  private $init_failed = FALSE;
 
   public function __construct($config,$hostId)
   {
     $this->config = $config;
     $this->opsi   = new opsi($config);
     $this->hostId = preg_replace("/^opsi:=([^,]*),.*$/","\\1",$hostId);
+    $this->init();
   }
 
-  public function execute()
+  private function init()
   {
-    print_a($this->opsi->get_client_hardware($this->hostId));
-      
+    $err = FALSE;
+    if(!$err){
+      $this->HW_info = $this->opsi->get_client_hardware($this->hostId);
+      $err |= $this->opsi->is_error(); 
+    }
+    if(!$err){
+      $this->SW_info = $this->opsi->get_client_software($this->hostId);
+      $err |= $this->opsi->is_error(); 
+    }
+    $this->init_failed = $err;
   }
 
+  public function execute()
+  {
+    if(isset($_POST['reinit']) && $this->init_failed){
+      $this->init();
+    }
+    if(isset($_GET['type'])) $this->type = $_GET['type'];
+
+    $smarty = get_smarty();
+    $smarty->assign("init_failed",$this->init_failed);
+    if($this->init_failed){
+      $smarty->assign("type", $this->type);
+      $smarty->assign("message",$this->opsi->get_error());
+      return($smarty->fetch(get_template_path("opsiWare.tpl",TRUE,dirname(__FILE__))));
+    }  
+
+    $smarty->assign("type", $this->type);
+
+    if($this->type == 1){
+      $smarty->assign("info", $this->HW_info);
+    }else{
+      $smarty->assign("info", $this->SW_info);
+    }
+    return($smarty->fetch(get_template_path("opsiWare.tpl",TRUE,dirname(__FILE__))));
+  }
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>