summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f2375aa)
raw | patch | inline | side by side (parent: f2375aa)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 25 Sep 2009 11:41:06 +0000 (11:41 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 25 Sep 2009 11:41:06 +0000 (11:41 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14348 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_licenseGeneric.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_licenseGeneric.inc
index d1048ac17e895e17d74442519900cb9190ef63f1..b2cc4d6e1c6dee04ee35aa4eb5450af89b315eb4 100644 (file)
var $licenseModel = "";
var $licenseKey = array();
+ var $orig_licenseModel = "";
var $licensePoolId = "";
var $boundToHost= array(); // Reserved for Host.
var $usedByHost = array(); // Used by Host.
}
$this->orig_cn = $this->cn;
+ $this->orig_licenseModel = $this->licenseModel;
$this->init_successfull = TRUE;
return;
}
if(isset($_POST['opsiLicensesPosted'])){
plugin::save_object();
+ if(isset($_POST['addLicenseUsage']) && isset($_POST['selectedHostToAdd'])){
+ $host = get_post('selectedHostToAdd');
+ if(!empty($host) &&
+ in_array($host,$this->getHosts()) &&
+ !in_array($host, $this->usedByHost)){
+ $this->usedByHost[] = $host;
+ }
+ }
+
+ if(isset($_POST['removeLicenseUsage']) && isset($_POST['selectedUsedHosts'])){
+ $todel = $_POST['selectedUsedHosts'];
+ foreach($todel as $host){
+ if(isset($this->usedByHost[$host])){
+ unset($this->usedByHost[$host]);
+ }
+ }
+ }
+
// Force licenseKey to be of type array.
- $this->licenseKey = array($this->licenseKey);
+ if(!is_array($this->licenseKey)){
+ $this->licenseKey = array($this->licenseKey);
+ }
// BoundToHost maybe multiple too, later.
- $this->boundToHost = array($this->boundToHost);
+ if(!is_array($this->boundToHost)){
+ $this->boundToHost = array($this->boundToHost);
+ }
if($this->initially_was_account){
$this->cn = $this->orig_cn;
+ $this->licenseModel = $this->orig_licenseModel;
}
}
}
$message[] = msgPool::required(_("Name"));
}
- if(empty($this->licenseKey)){
+ if(empty($this->licenseKey[0])){
$message[] = msgPool::required(_("License key"));
}
return($message);
}
-
/* Removes the object from the opsi database
*/
- function remove_from_parent()
- {
- echo "missing remove.";
-# $this->si->deletePool($this->orig_cn);
-# if($this->si->is_error()){
-# msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
-# }else{
-#
-# // Trigger remove signal
-# $this->handle_post_events("remove");
-# }
-#
-# new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$this->si->get_error());
- }
+ function remove_from_parent() {}
/* Saves object modifications
diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_licensePoolGeneric.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_licensePoolGeneric.inc
index 741ffcb0863c22ba2c31c45681922f3939a2f8d7..1f69db5779ca8c574eda01dde379a95b6b24d4e4 100644 (file)
"HOSTIDS"=> "usedByHost",
"LICENSEPOOLIDS"=> "licensePoolId",
"LICENSETYPE"=> "licenseModel",
- "LICENSEKEY"=> "licenseKey",
+ "LICENSEKEYS"=> "licenseKey",
"MAXINSTALLATIONS"=> "maximumInstallations",
"EXPIRATIONDATE"=> "expirationDate",
"SOFTWARELICENSEID"=> "cn"
}else{
$res = $this->si->getPool($this->cn);
+
if($this->si->is_error()){
$this->init_successfull = FALSE;
return(FALSE);
$entry[$attr] = array($entry[$attr]);
}
}
+ $entry['MODIFIED'] = FALSE;
$this->licenses[$entry['cn']] = $entry;
}
}
msg_dialog::displayChecks($msgs);
}else{
$attrs = $this->dialog->save();
+ $attrs['MODIFIED'] = TRUE;
$this->licenses[$attrs['cn']] = $attrs;
$this->dialog = NULL;
}
}
// Create, remove or update licenses
- $add = array_diff_assoc($this->licenses,$this->orig_licenses);
- $del = array_diff_assoc($this->orig_licenses,$this->licenses);
+ $add = array_diff_assoc($this->licenses,$this->orig_licenses);
+ $del = array_diff_assoc($this->orig_licenses,$this->licenses);
+ $update = array_intersect($this->licenses,$this->orig_licenses);
// Remove licenses
foreach($del as $license){
}
}
- // Add / update licenses
+ // Add licenses
foreach($add as $license){
$this->si->createLicense(
$this->cn, // Pool id
$license['maximumInstallations'],
$license['boundToHost'],
$license['expirationDate']);
+
+ if($this->si->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
+ }
+ }
+
+ // Update licenses
+ foreach($update as $license){
+
+ // Do not save untouched licenses
+ if(!$license['MODIFIED']){
+ continue;
+ }
+
+ $this->si->createLicense(
+ $this->cn, // Pool id
+ $license['cn'],
+ $license['licenseKey'][0],
+ $license['licenseModel'],
+ $license['partner'],
+ $license['conclusionDate'],
+ $license['notificationDate'],
+ $license['description'],
+ $license['cn'],
+ $license['maximumInstallations'],
+ $license['boundToHost'],
+ $license['expirationDate']);
if($this->si->is_error()){
msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
}
diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc
index 2a6f6048d2e8ca5c3f6332f925f973a5d03943c0..284e80799f967406166922d2f58fc2f93fd65828 100644 (file)
* @param boundToHost The name of the client the license is bound to (optional).
* @param expirationDate The date when the license is running down (optional).
*/
- function createLicense($poolId, $licenseId, $licenseKey,$licenseTyp = "",
+ function createLicense($poolId, $licenseId, $licenseKey,$licenseType = "",
$partner = "",
$conclusionDate = "",
$notificationDate ="",
// Append optional attributes
foreach(array("partner","conclusionDate","notificationDate","notes","softwareLicenseId",
- "licenseTyp","maxInstallations","boundToHost","expirationDate") as $attr){
+ "licenseType","maxInstallations","boundToHost","expirationDate") as $attr){
if(!empty($$attr)){
$data[$attr] = $$attr;
}
}
- print_a($data);
-
$res = $this->send_data("gosa_opsi_createLicense",$this->target,$data,TRUE);
if(isset($res['XML'][0]['ANSWER_OPSI_GETSOFTWARELICENSE_HASH'])){
return(TRUE);
diff --git a/gosa-plugins/opsi/admin/opsiLicenses/licenseGeneric.tpl b/gosa-plugins/opsi/admin/opsiLicenses/licenseGeneric.tpl
index 242365b3dde00a2e6a15efa0ddf4f69b5c6fb77d..e7fe63caa2af9e6dfea1e797b8a53f332dc1a342 100644 (file)
{t}Model{/t}
</td>
<td>
- <select name='licenseModel' onChange='document.mainform.submit();'>
- {html_options options=$licenseModels values=$licenseModels selected=$licenseModel}
- </select>
+ {if $initially_was_account}
+ <select name='dummy223' disabled>
+ {html_options options=$licenseModels values=$licenseModels selected=$licenseModel}
+ </select>
+ {else}
+ <select name='licenseModel' onChange='document.mainform.submit();'>
+ {html_options options=$licenseModels values=$licenseModels selected=$licenseModel}
+ </select>
+ {/if}
</td>
</tr>
</table>
<tr>
<td colspan="2">
<b>{t}Used by Host{/t}</b><br>
- <select name='usedByHost[]' multiple size=4 style='width:100%;'>
+ <select name='selectedUsedHosts[]' multiple size=4 style='width:100%;'>
{html_options options=$usedByHost}
</select><br>
<select name='selectedHostToAdd'>