summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5c280a2)
raw | patch | inline | side by side (parent: 5c280a2)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 25 Sep 2009 15:08:48 +0000 (15:08 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 25 Sep 2009 15:08:48 +0000 (15:08 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14353 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/opsi/admin/opsiLicenses/class_licenseUsageByHost.inc | patch | blob | history | |
gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc | patch | blob | history |
diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_licenseUsageByHost.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_licenseUsageByHost.inc
index 866d6f28d6665b7fdf925165237f3bad73c54d97..4618df364ef36fac0139f2a198c11476d46e45a0 100644 (file)
{
$this->licenseUses = array();
$this->reservedLicenses = array();
+ $this->init_reservedLicenses = array();
if(!$this->initially_was_account){
$this->init_successfull = TRUE;
}else{
+ // Get license usage
$res = $this->si->getLicenseUsage($this->cn);
if($this->si->is_error()){
$this->init_successfull = FALSE;
}
$this->licenseUses = $res;
+ // Get reservations
$res = $this->si->getReservedLicensesForHost($this->cn);
if($this->si->is_error()){
$this->init_successfull = FALSE;
return;
}
- $this->reservedLicenses = $res;
- $this->init_reservedLicenses = $res;
+ foreach($res as $pool){
+ $this->reservedLicenses[] = $pool['licensePoolId'][0];
+ }
+ $this->init_reservedLicenses = $this->reservedLicenses;
+
+ // Get list of license pools
+ $res = $this->si->listPools();
+ if($this->si->is_error()){
+ $this->init_successfull = FALSE;
+ return;
+ }
+ $this->availableLicenses = array();
+ foreach($res as $pool){
+ $this->availableLicenses[] = $pool['cn'][0];
+ }
+
$this->init_successfull = TRUE;
}
-
- $this->availableLicenses = array("Dummy","Schinken");
}
foreach($this->reservedLicenses as $key => $license){
$action = "<input class='center' type='image' src='images/lists/trash.png'
name='removeReservation_{$key}'>";
- $f1 = array("string" => $license['licensePoolId'][0]);
-# $f2 = array("string" => $license['licenseKey'][0]);
- $f3 = array("string" => $license['softwareLicenseId'][0]);
+ $f1 = array("string" => $license);
$f4 = array("string" => $action,
- "attach" => "style='border-right:0px;'");
-# $list2->addEntry(array($f1,$f2,$f3, $f4));
- $list2->addEntry(array($f1,$f3, $f4));
+ "attach" => "style='border-right:0px; width:16px;'");
+ $list2->addEntry(array($f1,$f4));
}
$smarty = get_smarty();
$smarty->assign("licenseUses", $list->DrawList());
$smarty->assign("licenseReserved", $list2->DrawList());
$smarty->assign("init_successfull", $this->init_successfull);
- $smarty->assign("availableLicenses", $this->availableLicenses);
+ $smarty->assign("availableLicenses", array_diff($this->availableLicenses, $this->reservedLicenses));
$smarty->assign("initially_was_account", $this->initially_was_account);
return($smarty->fetch(get_template_path('licenseUsageByHost.tpl',TRUE,dirname(__FILE__))));
}
// Check if we've to add reservations
if(isset($_POST['availableLicense']) && isset($_POST['addReservation'])){
- echo get_post('availableLicense');
+ $id = get_post('availableLicense');
+ if(isset($this->availableLicenses[$id])){
+ $this->reservedLicenses[] = $this->availableLicenses[$id];
+ }
}
}
}
}
- function save(){ }
+ function save()
+ {
+ $del = array_diff($this->init_reservedLicenses, $this->reservedLicenses);
+ $add = array_diff($this->reservedLicenses, $this->init_reservedLicenses);
+
+ foreach($del as $pool){
+ $this->si->removeLicenseFromHost($pool, $this->cn);
+ if($this->si->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
+ }
+ }
+
+ foreach($add as $pool){
+ $this->si->addLicenseToHost($pool, $this->cn);
+ if($this->si->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
+ }
+ }
+ }
+
+
function remove_from_parent(){ }
diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc
index c900136981fa841a4f2990557f04c2608444f010..0a99b22231b74706b3259315a2593525f0e887ec 100644 (file)
{
$data= array();
$data['licensePoolId'] = htmlentities($licensePoolId);
- $data['hostId'] = htmlentities($hostid);
+ $data['hostId'] = htmlentities($hostId);
$res = $this->send_data("gosa_opsi_unassignSoftwareLicenseFromHost",$this->target,$data,TRUE);
if(isset($res['XML'][0]['ANSWER_OPSI_UNASSIGNSOFTWARELICENSEFROMHOST'])){
return(TRUE);