From aa84e6096bd697abf762785552f262fc6c7f9cf0 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 23 Sep 2009 09:16:21 +0000 Subject: [PATCH] Added license usage dialog git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14328 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../admin/opsiLicenses/class_licenceUsage.inc | 30 +++++++++++++++++-- .../opsiLicenses/class_opsiLicenseHandler.inc | 23 +++++++++++++- .../opsi/admin/opsiLicenses/licenseUsage.tpl | 20 ++----------- 3 files changed, 53 insertions(+), 20 deletions(-) diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_licenceUsage.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_licenceUsage.inc index 76776725d..c4fde8e69 100644 --- a/gosa-plugins/opsi/admin/opsiLicenses/class_licenceUsage.inc +++ b/gosa-plugins/opsi/admin/opsiLicenses/class_licenceUsage.inc @@ -25,7 +25,7 @@ class licenseUsage extends plugin { var $cn = ""; - + var $licenseUses = array(); var $init_successfull = FALSE; @@ -50,7 +50,20 @@ class licenseUsage extends plugin function init() { - $this->init_successfull = TRUE; + $this->licenseUses = array(); + if(!$this->initially_was_account){ + $this->init_successfull = TRUE; + }else{ + + $res = $this->si->getLicenseUsage("", $this->cn); + if($this->si->is_error()){ + $this->init_successfull = FALSE; + return; + } + + $this->licenseUses = $res; + $this->init_successfull = TRUE; + } } @@ -63,6 +76,18 @@ class licenseUsage extends plugin $smarty->assign("init_successfull", $this->init_successfull); return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__)))); } + + // Create usage list + $list = new divSelectBox("licenseUsage"); + foreach($this->licenseUses as $license){ + + $f1 = array("string" => $license['hostId'][0]); + $f2 = array("string" => $license['licenseKey'][0]); + $f3 = array("string" => $license['licensePoolId'][0]); + $f4 = array("string" => $license['softwareLicenseId'][0], + "attach" => "style='border-right:0px;'"); + $list->addEntry(array($f1,$f2,$f3,$f4)); + } $smarty = get_smarty(); @@ -75,6 +100,7 @@ class licenseUsage extends plugin $smarty->assign($attr,$this->$attr); } + $smarty->assign("licenseUses", $list->DrawList()); $smarty->assign("init_successfull", $this->init_successfull); $smarty->assign("initially_was_account", $this->initially_was_account); return($smarty->fetch(get_template_path('licenseUsage.tpl',TRUE,dirname(__FILE__)))); diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc index fa75d84a1..d7055cd55 100644 --- a/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc +++ b/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc @@ -214,7 +214,28 @@ class opsiLicenceHandler extends opsi { $res = $this->send_data("gosa_opsi_getSoftwareLicenseUsages_listOfHashes",$this->target,$data,TRUE); if(isset($res['XML'][0]['ANSWER_OPSI_GETSOFTWARELICENSEUSAGES_LISTOFHASHES'])){ - return($res['XML'][0]['RESULT']); + + $items = array(); + foreach($res['XML'][0]['RESULT'][0]['HIT'] as $entry){ + $item = array(); + foreach(array( + "HOSTID" => "hostId", + "LICENSEKEY" => "licenseKey", + "LICENSEPOOLID" => "licensePoolId", + "NOTES" => "notes", + "SOFTWARELICENSEID" => "softwareLicenseId") as $source => $target){ + if(isset($entry[$source])){ + + $item[$target] = array('count' => 0); + foreach($entry[$source] as $data){ + $item[$target][] = $data['VALUE']; + } + $item[$target]['count'] = count($item[$target]) -1 ; + } + } + $items[] = $item; + } + return($items); } return(FALSE); } diff --git a/gosa-plugins/opsi/admin/opsiLicenses/licenseUsage.tpl b/gosa-plugins/opsi/admin/opsiLicenses/licenseUsage.tpl index 3790766d7..443d2f4f4 100644 --- a/gosa-plugins/opsi/admin/opsiLicenses/licenseUsage.tpl +++ b/gosa-plugins/opsi/admin/opsiLicenses/licenseUsage.tpl @@ -7,24 +7,10 @@
{else} + +

{t}License usage{/t}

- - - - -
+{$licenseUses} - -

{t}Generic{/t}

- - - - - -
{t}Name{/t} - TESTER -
- -
{/if} -- 2.30.2