1 <?php
3 class opsiSoftware extends opsiWare
4 {
5 protected $type = 0;
6 }
8 class opsiHardware extends opsiWare
9 {
10 protected $type = 1;
11 }
14 class opsiWare extends plugin
15 {
16 private $opsi;
17 private $hostId;
18 private $init_failed = FALSE;
19 private $info;
20 protected $type = 0;
22 public function __construct($config,$hostId)
23 {
24 $this->config = $config;
25 $this->opsi = new opsi($config);
26 $this->hostId = preg_replace("/^opsi:=([^,]*),.*$/","\\1",$hostId);
27 $this->init();
28 }
30 private function init()
31 {
32 if($this->type == 0){
33 $this->info = $this->opsi->get_client_hardware($this->hostId);
34 $err = $this->opsi->is_error();
35 }else{
36 $this->info = $this->opsi->get_client_software($this->hostId);
37 $err = $this->opsi->is_error();
38 }
39 $this->init_failed = $err;
40 }
43 public function execute()
44 {
45 plugin::execute();
46 if(isset($_POST['reinit']) && $this->init_failed){
47 $this->init();
48 }
49 $smarty = get_smarty();
50 $smarty->assign("init_failed",$this->init_failed);
51 if($this->init_failed){
52 $smarty->assign("type", $this->type);
53 $smarty->assign("message",$this->opsi->get_error());
54 return($smarty->fetch(get_template_path("opsiware.tpl",TRUE,dirname(__FILE__))));
55 }
56 $smarty->assign("type", $this->type);
57 $smarty->assign("info", $this->info);
58 return($smarty->fetch(get_template_path("opsiware.tpl",TRUE,dirname(__FILE__))));
59 }
60 }
61 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
62 ?>