summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6cf237d)
raw | patch | inline | side by side (parent: 6cf237d)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 23 Jul 2010 14:07:27 +0000 (14:07 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 23 Jul 2010 14:07:27 +0000 (14:07 +0000) |
-updated code indentation
-Fixed post handling
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19090 594d385d-05f5-0310-b6e9-bd551577e9d8
-Fixed post handling
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@19090 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_filterOpsiLicense.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_filterOpsiLicense.inc
index 13c5bfde1b1772e0ba038deae129ce93d876fdb0..4f7f9240bde9e952813ee3cec82ccd5a2e27cb97 100644 (file)
class filterOpsiLicense {
- static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "")
- {
+ static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "")
+ {
- if(!class_available('opsi')) return(array());
+ if(!class_available('opsi')) return(array());
- $config= session::global_get('config');
- $ldap= $config->get_ldap_link(TRUE);
- $flag= ($scope == "sub")?GL_SUBSEARCH:0;
- $result= filterOpsiLicense::get_list($base, $filter, $attributes, $category, $objectStorage, $flag);
+ $config= session::global_get('config');
+ $ldap= $config->get_ldap_link(TRUE);
+ $flag= ($scope == "sub")?GL_SUBSEARCH:0;
+ $result= filterOpsiLicense::get_list($base, $filter, $attributes, $category, $objectStorage, $flag);
- // Prepare filter and split it into attribute and value to search for
- $filter=preg_replace("/\*/","",$filter);
- $attr = $value = "";
- if(!empty($filter) && preg_match("/=/", $filter)){
- list($attr,$value) = preg_split("/=/", $filter);
- }
+ // Prepare filter and split it into attribute and value to search for
+ $filter=preg_replace("/\*/","",$filter);
+ $attr = $value = "";
+ if(!empty($filter) && preg_match("/=/", $filter)){
+ list($attr,$value) = preg_split("/=/", $filter);
+ }
- // Simple filtering
- if(!empty($attr)){
- foreach($result as $key => $entry){
- if(!preg_match("/".$value."/i", $entry[$attr][0])){
- unset($result[$key]);
+ // Simple filtering
+ if(!empty($attr)){
+ foreach($result as $key => $entry){
+ if(!preg_match("/".$value."/i", $entry[$attr][0])){
+ unset($result[$key]);
+ }
+ }
}
- }
- }
- return(filterACL::unifyResult($result));
- }
+ return(filterACL::unifyResult($result));
+ }
- static function get_list($base, $filter, $attributes, $category, $objectStorage, $flags= GL_SUBSEARCH)
- {
- $config= session::global_get('config');
- $si = new opsiLicenceHandler($config);
+ static function get_list($base, $filter, $attributes, $category, $objectStorage, $flags= GL_SUBSEARCH)
+ {
+ $config= session::global_get('config');
+ $si = new opsiLicenceHandler($config);
- if(!$si->enabled()) return(array());
+ if(!$si->enabled()) return(array());
- $res = $si->listPools();
- $result = array();
- if($si->is_error() || !is_array($res)){
- $this->init_successfull = FALSE;
- msg_dialog::display(_("Error"),msgPool::siError($si->get_error()),ERROR_DIALOG);
- return;
- }else{
+ $res = $si->listPools();
+ $result = array();
+ if($si->is_error() || !is_array($res)){
+ $this->init_successfull = FALSE;
+ msg_dialog::display(_("Error"),msgPool::siError($si->get_error()),ERROR_DIALOG);
+ return;
+ }else{
- // Reset the list of licenses
- foreach($res as $item){
+ // Reset the list of licenses
+ foreach($res as $item){
- $item['objectClass'] = array('fake_opsiLicense');
+ $item['objectClass'] = array('fake_opsiLicense');
- // Fake an ldap entry, this enables ACL checks.
- $entry = array();
- $entry['dn'] = "opsi:cn=".$item['cn'][0].",".$config->current['BASE'];
- foreach($item as $name => $value){
- $entry[] = $name;
- $entry[$name] = $value;
+ // Fake an ldap entry, this enables ACL checks.
+ $entry = array();
+ $entry['dn'] = "opsi:cn=".$item['cn'][0].",".$config->current['BASE'];
+ foreach($item as $name => $value){
+ $entry[] = $name;
+ $entry[$name] = $value;
+ }
+ $entry['count'] = count($item);
+ $result[] = $entry;
+ }
}
- $entry['count'] = count($item);
- $result[] = $entry;
- }
+ return($result);
}
- return($result);
- }
- static function unifyResult($result)
- {
- $res=array();
- foreach($result as $entry){
- if(!isset($res[$entry['dn']])){
- $res[$entry['dn']]=$entry;
- }
+ static function unifyResult($result)
+ {
+ $res=array();
+ foreach($result as $entry){
+ if(!isset($res[$entry['dn']])){
+ $res[$entry['dn']]=$entry;
+ }
+ }
+ return(array_values($res));
}
- return(array_values($res));
- }
}
?>
diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_licenseByProduct.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_licenseByProduct.inc
index bc9de9733f2866dc375b7a60b5ed65c400a7d3d3..463939cc7f6e6ee3863da601a24a61e108fa94e6 100644 (file)
<?php
/*
-* This code is part of GOsa (http://www.gosa-project.org)
-* Copyright (C) 2003-2008 GONICUS GmbH
-*
-* ID: $$Id: class_opsiLicenses.inc 13520 2009-03-09 14:54:13Z hickert $$
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id: class_opsiLicenses.inc 13520 2009-03-09 14:54:13Z hickert $$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
class licenseByProduct extends plugin
{
- var $cn = "";
- var $licenseUses = array();
- var $init_successfull = FALSE;
-
-
- function __construct(&$config,$dn)
- {
- $this->config = $config;
- $this->dn = $this->orig_dn = $dn;
- $this->si = new opsiLicenceHandler($this->config);
-
- // Is this a new object?
- $this->is_account=TRUE;
- if($this->dn == "new"){
- $this->initially_was_account = FALSE;
- }else{
- $this->initially_was_account = TRUE;
-
- // Extract pool name out of the fake dn.
- $this->cn = $this->orig_cn = preg_replace("/^opsi:cn=([^,]*),.*$/","\\1",$dn);
+ var $cn = "";
+ var $licenseUses = array();
+ var $init_successfull = FALSE;
+
+
+ function __construct(&$config,$dn)
+ {
+ $this->config = $config;
+ $this->dn = $this->orig_dn = $dn;
+ $this->si = new opsiLicenceHandler($this->config);
+
+ // Is this a new object?
+ $this->is_account=TRUE;
+ if($this->dn == "new"){
+ $this->initially_was_account = FALSE;
+ }else{
+ $this->initially_was_account = TRUE;
+
+ // Extract pool name out of the fake dn.
+ $this->cn = $this->orig_cn = preg_replace("/^opsi:cn=([^,]*),.*$/","\\1",$dn);
+ }
+
+ $this->init();
+
+ // Prepare lists
+ $this->usageList = new sortableListing();
+ $this->usageList->setDeleteable(false);
+ $this->usageList->setEditable(false);
+ $this->usageList->setWidth("100%");
+ $this->usageList->setHeight("300px");
+ $this->usageList->setHeader(array(_("Host"),_("Key"),_("Pool"), _("License")));
+ $this->usageList->setDefaultSortColumn(1);
}
- $this->init();
-
- // Prepare lists
- $this->usageList = new sortableListing();
- $this->usageList->setDeleteable(false);
- $this->usageList->setEditable(false);
- $this->usageList->setWidth("100%");
- $this->usageList->setHeight("300px");
- $this->usageList->setHeader(array(_("Host"),_("Key"),_("Pool"), _("License")));
- $this->usageList->setDefaultSortColumn(1);
- }
-
-
- function init()
- {
- $this->licenseUses = array();
- if(!$this->initially_was_account){
- $this->init_successfull = TRUE;
- }else{
-
- // Get license information for the current product.
- $res = $this->si->getLicensesForProduct($this->cn);
- if($this->si->is_error()){
- $this->init_successfull = FALSE;
- msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
- return;
- }
-
- $this->licenseUses = $res;
- $this->init_successfull = TRUE;
+
+ function init()
+ {
+ $this->licenseUses = array();
+ if(!$this->initially_was_account){
+ $this->init_successfull = TRUE;
+ }else{
+
+ // Get license information for the current product.
+ $res = $this->si->getLicensesForProduct($this->cn);
+ if($this->si->is_error()){
+ $this->init_successfull = FALSE;
+ msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
+ return;
+ }
+
+ $this->licenseUses = $res;
+ $this->init_successfull = TRUE;
+ }
+ }
+
+
+ function execute()
+ {
+ plugin::execute();
+ // Handle initialization failures.
+ if(isset($_POST['retry_init'])) $this->init();
+ if(!$this->init_successfull){
+ $smarty = get_smarty();
+ $smarty->assign("init_successfull", $this->init_successfull);
+ return($smarty->fetch(get_template_path('licenseByProduct.tpl',TRUE,dirname(__FILE__))));
+ }
+
+ $ui = get_userinfo();
+ $readable = $ui->get_permissions($this->config->current['BASE'], "opsi/licenseByProduct","");
+ $data = array();
+ $this->usageList->setAcl($readable);
+ foreach($this->licenseUses as $license){
+ $data[] = array('data'=> array($license['HOSTID'][0]['VALUE'],
+ $license['SOFTWARELICENSEID'][0]['VALUE'],
+ $license['LICENSEPOOLID'][0]['VALUE']));
+ }
+ $this->usageList->setListData($data,$data);
+ $this->usageList->update();
+
+
+ $smarty = get_smarty();
+
+ // Assign ACls
+ $plInfo = $this->plInfo();
+ $smarty->assign("licenseUses", $this->usageList->render());
+ $smarty->assign("init_successfull", $this->init_successfull);
+ $smarty->assign("initially_was_account", $this->initially_was_account);
+ return($smarty->fetch(get_template_path('licenseByProduct.tpl',TRUE,dirname(__FILE__))));
}
- }
-
-
- function execute()
- {
- plugin::execute();
- // Handle initialization failures.
- if(isset($_POST['retry_init'])) $this->init();
- if(!$this->init_successfull){
- $smarty = get_smarty();
- $smarty->assign("init_successfull", $this->init_successfull);
- return($smarty->fetch(get_template_path('licenseByProduct.tpl',TRUE,dirname(__FILE__))));
+
+
+ /* Save HTML inputs
+ */
+ function save_object()
+ {
+ if(isset($_POST['opsiLicenseUsagePosted'])){
+ plugin::save_object();
+ }
+ }
+
+
+ /* Check user input and return a list of 'invalid input' messages.
+ */
+ function check()
+ {
+ $message = plugin::check();
+ return($message);
}
-
- $ui = get_userinfo();
- $readable = $ui->get_permissions($this->config->current['BASE'], "opsi/licenseByProduct","");
- $data = array();
- $this->usageList->setAcl($readable);
- foreach($this->licenseUses as $license){
- $data[] = array('data'=> array($license['HOSTID'][0]['VALUE'],
- $license['SOFTWARELICENSEID'][0]['VALUE'],
- $license['LICENSEPOOLID'][0]['VALUE']));
- }
- $this->usageList->setListData($data,$data);
- $this->usageList->update();
-
-
- $smarty = get_smarty();
-
- // Assign ACls
- $plInfo = $this->plInfo();
- $smarty->assign("licenseUses", $this->usageList->render());
- $smarty->assign("init_successfull", $this->init_successfull);
- $smarty->assign("initially_was_account", $this->initially_was_account);
- return($smarty->fetch(get_template_path('licenseByProduct.tpl',TRUE,dirname(__FILE__))));
- }
-
-
- /* Save HTML inputs
- */
- function save_object()
- {
- if(isset($_POST['opsiLicenseUsagePosted'])){
- plugin::save_object();
+
+
+ function save( ){}
+ function remove_from_parent(){ }
+
+
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Usage by product"),
+ "plDescription" => _("License usage by product"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 12,
+ "plSection" => array("administration"),
+ "plCategory" => array("opsi"),
+ "plProvidedAcls"=> array()));
}
- }
-
-
- /* Check user input and return a list of 'invalid input' messages.
- */
- function check()
- {
- $message = plugin::check();
- return($message);
- }
-
-
- function save( ){}
- function remove_from_parent(){ }
-
-
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Usage by product"),
- "plDescription" => _("License usage by product"),
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 12,
- "plSection" => array("administration"),
- "plCategory" => array("opsi"),
- "plProvidedAcls"=> array()));
- }
}
diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_licenseGeneric.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_licenseGeneric.inc
index dca2b539722ed4e048a8ceea03569852f065c516..b2c8edefbb86b70ca286c1cc770ae45a3162c57b 100644 (file)
<?php
/*
-* This code is part of GOsa (http://www.gosa-project.org)
-* Copyright (C) 2003-2008 GONICUS GmbH
-*
-* ID: $$Id: class_opsiLicenses.inc 13520 2009-03-09 14:54:13Z hickert $$
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id: class_opsiLicenses.inc 13520 2009-03-09 14:54:13Z hickert $$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
class licenseGeneric extends plugin
{
- // License attributes
- var $si = NULL;
- var $data = array();
- var $cn = "";
- var $orig_cn = "";
- var $description = "";
- var $partner = "";
-
- // Date attributes
- var $conclusionDate = "";
- var $expirationDate = "";
- var $notificationDate = "";
-
- // License model related attribues
- var $licenseModel = "";
- var $licenseKey = array();
- var $orig_licenseModel = "";
- var $licensePoolId = "";
- var $boundToHost= array(); // Reserved for Host.
- var $usedByHost = array(); // Used by Host.
-
- var $maximumInstallations = 0;
- var $opsiHosts;
-
- var $attributes = array(
- "cn","description","partner","conclusionDate","expirationDate",
- "notificationDate","licenseModel","licenseKey","maximumInstallations",
- "licensePoolId", "usedByHost","boundToHost");
-
- function __construct(&$config, $dn, $license, $hosts = array())
- {
-
- $this->config = $config;
- $this->data = $license;
- $this->dn = $dn;
- $this->si = new opsiLicenceHandler($this->config);
- $this->opsiHosts = $hosts;
-
- // Detect account state.
- if(count($this->data) == 0){
- $this->initially_was_account = FALSE;
- }else{
- $this->initially_was_account = TRUE;
- }
- $this->is_account = TRUE;
-
- // Extract pool name out of the fake dn.
- $this->init();
- }
-
-
- function init()
- {
- // Extract license information out of the license object ($this->data)
- $this->boundToHost = array('0'=>"");
- $this->usedByHost = array('0'=>"");
- $this->licenseKey = array('0'=>"");
- if($this->initially_was_account){
- foreach($this->attributes as $attr){
- $this->$attr = $this->data[$attr];
- }
-
- // Fix dates
- foreach(array("notificationDate","expirationDate","conclusionDate") as $date) {
- if(!empty($this->$date)){
- $this->$date = date("d.m.Y",strtotime($this->$date));
+ // License attributes
+ var $si = NULL;
+ var $data = array();
+ var $cn = "";
+ var $orig_cn = "";
+ var $description = "";
+ var $partner = "";
+
+ // Date attributes
+ var $conclusionDate = "";
+ var $expirationDate = "";
+ var $notificationDate = "";
+
+ // License model related attribues
+ var $licenseModel = "";
+ var $licenseKey = array();
+ var $orig_licenseModel = "";
+ var $licensePoolId = "";
+ var $boundToHost= array(); // Reserved for Host.
+ var $usedByHost = array(); // Used by Host.
+
+ var $maximumInstallations = 0;
+ var $opsiHosts;
+
+ var $attributes = array(
+ "cn","description","partner","conclusionDate","expirationDate",
+ "notificationDate","licenseModel","licenseKey","maximumInstallations",
+ "licensePoolId", "usedByHost","boundToHost");
+
+ function __construct(&$config, $dn, $license, $hosts = array())
+ {
+
+ $this->config = $config;
+ $this->data = $license;
+ $this->dn = $dn;
+ $this->si = new opsiLicenceHandler($this->config);
+ $this->opsiHosts = $hosts;
+
+ // Detect account state.
+ if(count($this->data) == 0){
+ $this->initially_was_account = FALSE;
+ }else{
+ $this->initially_was_account = TRUE;
}
- }
- }
+ $this->is_account = TRUE;
- $this->orig_cn = $this->cn;
- $this->orig_licenseModel = $this->licenseModel;
- $this->init_successfull = TRUE;
- return;
- }
-
-
- function execute()
- {
- plugin::execute();
- // Handle initialization failures.
- if(isset($_POST['retry_init'])) $this->init();
- if(!$this->init_successfull){
- $smarty = get_smarty();
- $smarty->assign("init_successfull", $this->init_successfull);
- return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__))));
+ // Extract pool name out of the fake dn.
+ $this->init();
}
- $smarty = get_smarty();
- // Assign attributes and its ACls
- $plInfo = $this->plInfo();
- foreach($plInfo['plProvidedAcls'] as $name => $desc){
- $smarty->assign("{$name}ACL",$this->getacl($name));
- }
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
+ function init()
+ {
+ // Extract license information out of the license object ($this->data)
+ $this->boundToHost = array('0'=>"");
+ $this->usedByHost = array('0'=>"");
+ $this->licenseKey = array('0'=>"");
+ if($this->initially_was_account){
+ foreach($this->attributes as $attr){
+ $this->$attr = $this->data[$attr];
+ }
+
+ // Fix dates
+ foreach(array("notificationDate","expirationDate","conclusionDate") as $date) {
+ if(!empty($this->$date)){
+ $this->$date = date("d.m.Y",strtotime($this->$date));
+ }
+ }
+ }
+
+ $this->orig_cn = $this->cn;
+ $this->orig_licenseModel = $this->licenseModel;
+ $this->init_successfull = TRUE;
+ return;
}
- // Assign list of available license models
- $smarty->assign("licenseModels",array(
- "RETAIL" => _("Retail"),
- "OEM"=>_("OEM"),
- "VOLUME" => _("Volume")));
+ function execute()
+ {
+ plugin::execute();
+ // Handle initialization failures.
+ if(isset($_POST['retry_init'])) $this->init();
+ if(!$this->init_successfull){
+ $smarty = get_smarty();
+ $smarty->assign("init_successfull", $this->init_successfull);
+ return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__))));
+ }
+
+ $smarty = get_smarty();
- $smarty->assign("init_successfull", $this->init_successfull);
- $smarty->assign("initially_was_account", $this->initially_was_account);
- $smarty->assign("hosts", $this->getHosts());
+ // Assign attributes and its ACls
+ $plInfo = $this->plInfo();
+ foreach($plInfo['plProvidedAcls'] as $name => $desc){
+ $smarty->assign("{$name}ACL",$this->getacl($name));
+ }
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,set_post($this->$attr));
+ }
- $ui = get_userinfo();
- $acl_base = $this->dn;
- if($acl_base == "new"){
- $acl_base = $this->config->current['BASE'];
+ // Assign list of available license models
+ $smarty->assign("licenseModels",array(
+ "RETAIL" => _("Retail"),
+ "OEM"=>_("OEM"),
+ "VOLUME" => _("Volume")));
+
+
+ $smarty->assign("init_successfull", $this->init_successfull);
+ $smarty->assign("initially_was_account", $this->initially_was_account);
+ $smarty->assign("hosts", $this->getHosts());
+
+ $ui = get_userinfo();
+ $acl_base = $this->dn;
+ if($acl_base == "new"){
+ $acl_base = $this->config->current['BASE'];
+ }
+ $smarty->assign("licenseACL", $ui->get_permissions($acl_base,"opsi/licensePoolGeneric","licenses"));
+ $smarty->assign("writeable", preg_match("/w/",$ui->get_permissions($acl_base,"opsi/licensePoolGeneric","licenses")));
+ $smarty->assign("notUsedHosts", array_diff($this->getHosts(), $this->usedByHost));
+ $smarty->assign("boundToHost", set_post($this->boundToHost[0]));
+ $smarty->assign("licenseKey", set_post($this->licenseKey[0]));
+
+ // w3c fix, do not show empty options.
+ $tmp = $this->usedByHost;
+ if(isset($tmp[0]) && empty($tmp[0])) unset($tmp[0]);
+ $smarty->assign('usedByHost', $tmp);
+
+ foreach(array("notificationDate","expirationDate","conclusionDate") as $date) {
+ $smarty->assign($date."Writeable", $this->acl_is_writeable($date));
+ }
+
+ return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__))));
}
- $smarty->assign("licenseACL", $ui->get_permissions($acl_base,"opsi/licensePoolGeneric","licenses"));
- $smarty->assign("writeable", preg_match("/w/",$ui->get_permissions($acl_base,"opsi/licensePoolGeneric","licenses")));
- $smarty->assign("notUsedHosts", array_diff($this->getHosts(), $this->usedByHost));
- $smarty->assign("boundToHost", $this->boundToHost[0]);
- $smarty->assign("licenseKey", $this->licenseKey[0]);
-
- // w3c fix, do not show empty options.
- $tmp = $this->usedByHost;
- if(isset($tmp[0]) && empty($tmp[0])) unset($tmp[0]);
- $smarty->assign('usedByHost', $tmp);
-
- foreach(array("notificationDate","expirationDate","conclusionDate") as $date) {
- $smarty->assign($date."Writeable", $this->acl_is_writeable($date));
+
+
+ function getHosts()
+ {
+ $ret = array();
+ foreach($this->opsiHosts as $host){
+ $cn = $host['NAME'][0]['VALUE'];
+ $ret[$cn] = $cn;
+ }
+ return($ret);
}
- return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__))));
- }
- function getHosts()
- {
- $ret = array();
- foreach($this->opsiHosts as $host){
- $cn = $host['NAME'][0]['VALUE'];
- $ret[$cn] = $cn;
- }
- return($ret);
- }
+ /* Save HTML inputs
+ */
+ function save_object()
+ {
+
+ 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 = get_post('selectedUsedHosts');
+ foreach($todel as $host){
+ if(isset($this->usedByHost[$host])){
+ unset($this->usedByHost[$host]);
+ }
+ }
+ }
+
+ // Force licenseKey to be of type array.
+ if(!is_array($this->licenseKey)){
+ $this->licenseKey = array($this->licenseKey);
+ }
+
+ // BoundToHost maybe multiple too, later.
+ 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;
+ }
+ }
+ }
-
- /* Save HTML inputs
- */
- function save_object()
- {
+ /* Check user input and return a list of 'invalid input' messages.
+ */
+ function check()
+ {
+ $message = plugin::check();
- if(isset($_POST['opsiLicensesPosted'])){
- plugin::save_object();
+ // Very simple date input checks
+ if(!empty($this->expirationDate) &&
+ !preg_match("/^[0-9]{2}\.[0-9]{2}\.[0-9]{4}$/",$this->expirationDate)){
+ $message[] = msgPool::invalid(_("Expiration date"),$this->expirationDate,"","23.02.2009");
+ }
+ if(!empty($this->conclusionDate) &&
+ !preg_match("/^[0-9]{2}\.[0-9]{2}\.[0-9]{4}$/",$this->conclusionDate)){
+ $message[] = msgPool::invalid(_("Expiration date"),$this->conclusionDate,"","23.02.2009");
+ }
+ if(!empty($this->notificationDate) &&
+ !preg_match("/^[0-9]{2}\.[0-9]{2}\.[0-9]{4}$/",$this->notificationDate)){
+ $message[] = msgPool::invalid(_("Expiration date"),$this->notificationDate,"","23.02.2009");
+ }
- 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(empty($this->cn)){
+ $message[] = msgPool::required(_("Name"));
}
- }
-
- if(isset($_POST['removeLicenseUsage']) && isset($_POST['selectedUsedHosts'])){
- $todel = $_POST['selectedUsedHosts'];
- foreach($todel as $host){
- if(isset($this->usedByHost[$host])){
- unset($this->usedByHost[$host]);
- }
+
+ if(empty($this->licenseKey[0])){
+ $message[] = msgPool::required(_("License key"));
}
- }
-
- // Force licenseKey to be of type array.
- if(!is_array($this->licenseKey)){
- $this->licenseKey = array($this->licenseKey);
- }
-
- // BoundToHost maybe multiple too, later.
- 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;
- }
+
+ return($message);
}
- }
- /* Check user input and return a list of 'invalid input' messages.
- */
- function check()
- {
- $message = plugin::check();
+ /* Removes the object from the opsi database
+ */
+ function remove_from_parent() {}
- // Very simple date input checks
- if(!empty($this->expirationDate) &&
- !preg_match("/^[0-9]{2}\.[0-9]{2}\.[0-9]{4}$/",$this->expirationDate)){
- $message[] = msgPool::invalid(_("Expiration date"),$this->expirationDate,"","23.02.2009");
- }
- if(!empty($this->conclusionDate) &&
- !preg_match("/^[0-9]{2}\.[0-9]{2}\.[0-9]{4}$/",$this->conclusionDate)){
- $message[] = msgPool::invalid(_("Expiration date"),$this->conclusionDate,"","23.02.2009");
- }
- if(!empty($this->notificationDate) &&
- !preg_match("/^[0-9]{2}\.[0-9]{2}\.[0-9]{4}$/",$this->notificationDate)){
- $message[] = msgPool::invalid(_("Expiration date"),$this->notificationDate,"","23.02.2009");
- }
- if(empty($this->cn)){
- $message[] = msgPool::required(_("Name"));
- }
+ /* Saves object modifications
+ */
+ function save()
+ {
+ $data = array();
+ foreach($this->attributes as $target){
+ $data[$target] = $this->$target;
+ }
- if(empty($this->licenseKey[0])){
- $message[] = msgPool::required(_("License key"));
- }
+ // Return opsi like dates.
+ foreach(array("notificationDate","expirationDate","conclusionDate") as $date) {
+ if(!empty($this->$date)){
+ $data[$date] = date("Y-m-d",strtotime($this->$date));
+ }
+ }
- return($message);
- }
-
-
- /* Removes the object from the opsi database
- */
- function remove_from_parent() {}
-
-
- /* Saves object modifications
- */
- function save()
- {
- $data = array();
- foreach($this->attributes as $target){
- $data[$target] = $this->$target;
- }
-
- // Return opsi like dates.
- foreach(array("notificationDate","expirationDate","conclusionDate") as $date) {
- if(!empty($this->$date)){
- $data[$date] = date("Y-m-d",strtotime($this->$date));
- }
+ return($data);
}
- return($data);
- }
-
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Generic"),
- "plDescription" => _("License generic"),
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 8,
- "plSection" => array("administration"),
- "plCategory" => array("opsi"),
- "plProvidedAcls"=> array(
- "cn" => _("Name"),
- "partner" => _("Partner"),
- "licenseKey" => _("License key"),
- "licenseModel" => _("License model"),
- "licensePoolId" => _("License pool id"),
- "maximumInstallations"=> _("Maximum installations"),
- "boundToHost" => _("Reserved for host"),
- "usedByHost" => _("Usage"),
- "notificationDate" => _("Notification date"),
- "conclusionDate" => _("Conclusion date"),
- "expirationDate" => _("Expiration date"),
- "description" => _("Description"))
- ));
- }
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Generic"),
+ "plDescription" => _("License generic"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 8,
+ "plSection" => array("administration"),
+ "plCategory" => array("opsi"),
+ "plProvidedAcls"=> array(
+ "cn" => _("Name"),
+ "partner" => _("Partner"),
+ "licenseKey" => _("License key"),
+ "licenseModel" => _("License model"),
+ "licensePoolId" => _("License pool id"),
+ "maximumInstallations"=> _("Maximum installations"),
+ "boundToHost" => _("Reserved for host"),
+ "usedByHost" => _("Usage"),
+ "notificationDate" => _("Notification date"),
+ "conclusionDate" => _("Conclusion date"),
+ "expirationDate" => _("Expiration date"),
+ "description" => _("Description"))
+ ));
+ }
}
diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_licensePoolGeneric.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_licensePoolGeneric.inc
index 1eea95508b7cf07409b057c96ecc2abc82d40c27..b394b5dfd2529e7b8dad8aae373adc522ba16146 100644 (file)
<?php
/*
-* This code is part of GOsa (http://www.gosa-project.org)
-* Copyright (C) 2003-2008 GONICUS GmbH
-*
-* ID: $$Id: class_opsiLicenses.inc 13520 2009-03-09 14:54:13Z hickert $$
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id: class_opsiLicenses.inc 13520 2009-03-09 14:54:13Z hickert $$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
class licensePoolGeneric extends plugin
{
- var $cn = "";
- var $orig_cn = "";
- var $description = "";
- var $orig_dn = "";
-
- var $data = array();
- var $orig_data = array();
- var $productIds = array();
- var $softwareIds= array();
- var $licenses = array();
- var $orig_licenses = array();
-
- var $availableProductIds = array();
- var $attributes =array("cn","description");
- var $si = NULL;
-
- var $opsiHosts = array();
-
- var $licenseMap = array(
- "BOUNDTOHOST"=> "boundToHost",
- "HOSTIDS"=> "usedByHost",
- "LICENSEPOOLIDS"=> "licensePoolId",
- "LICENSETYPE"=> "licenseModel",
- "LICENSEKEYS"=> "licenseKey",
- "MAXINSTALLATIONS"=> "maximumInstallations",
- "EXPIRATIONDATE"=> "expirationDate",
- "SOFTWARELICENSEID"=> "cn"
- );
-
- var $licenseContractMap = array(
- "CONCLUSIONDATE"=> "conclusionDate",
- "NOTIFICATIONDATE"=> "notificationDate",
- "NOTES"=> "description",
- "PARTNER"=> "partner"
- );
-
- function __construct(&$config,$dn)
- {
- $this->config = $config;
- $this->dn = $this->orig_dn = $dn;
-
- // initialize gosa-si handle for opsi licenses
- $this->si = new opsiLicenceHandler($this->config);
-
- // Detect if this is a new or existings license
- $this->is_account=TRUE;
- if($this->dn == "new"){
- $this->initially_was_account = FALSE;
- }else{
- $this->initially_was_account = TRUE;
-
- // Extract pool name out of the fake dn.
- $this->cn = $this->orig_cn = preg_replace("/^opsi:cn=([^,]*),.*$/","\\1",$dn);
- }
+ var $cn = "";
+ var $orig_cn = "";
+ var $description = "";
+ var $orig_dn = "";
+
+ var $data = array();
+ var $orig_data = array();
+ var $productIds = array();
+ var $softwareIds= array();
+ var $licenses = array();
+ var $orig_licenses = array();
+
+ var $availableProductIds = array();
+ var $attributes =array("cn","description");
+ var $si = NULL;
+
+ var $opsiHosts = array();
+
+ var $licenseMap = array(
+ "BOUNDTOHOST"=> "boundToHost",
+ "HOSTIDS"=> "usedByHost",
+ "LICENSEPOOLIDS"=> "licensePoolId",
+ "LICENSETYPE"=> "licenseModel",
+ "LICENSEKEYS"=> "licenseKey",
+ "MAXINSTALLATIONS"=> "maximumInstallations",
+ "EXPIRATIONDATE"=> "expirationDate",
+ "SOFTWARELICENSEID"=> "cn"
+ );
+
+ var $licenseContractMap = array(
+ "CONCLUSIONDATE"=> "conclusionDate",
+ "NOTIFICATIONDATE"=> "notificationDate",
+ "NOTES"=> "description",
+ "PARTNER"=> "partner"
+ );
+
+ function __construct(&$config,$dn)
+ {
+ $this->config = $config;
+ $this->dn = $this->orig_dn = $dn;
+
+ // initialize gosa-si handle for opsi licenses
+ $this->si = new opsiLicenceHandler($this->config);
+
+ // Detect if this is a new or existings license
+ $this->is_account=TRUE;
+ if($this->dn == "new"){
+ $this->initially_was_account = FALSE;
+ }else{
+ $this->initially_was_account = TRUE;
- $this->init();
-
- // Prepare lists
- $this->licenseList = new sortableListing();
- $this->licenseList->setDeleteable(true);
- $this->licenseList->setEditable(true);
- $this->licenseList->setWidth("100%");
- $this->licenseList->setHeight("120px");
- $this->licenseList->setColspecs(array('200px','*'));
- $this->licenseList->setHeader(array(_("Section"),_("Description")));
- $this->licenseList->setDefaultSortColumn(1);
-
- }
-
-
- function init()
- {
- // Load local Boot Products
- $res = $this->si->get_local_products();
- $this->availableProductIds=array();
- if($this->si->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
- $this->init_successfull = FALSE;
- return(FALSE);
- }
- $this->availableProductIds=array_keys($res);
-
- // Load opsi hosts
- $res = $this->si->list_clients();
- $this->opsiHosts=array();
- if($this->si->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
- $this->init_successfull = FALSE;
- return(FALSE);
- }
- $this->opsiHosts=$res;
-
- // Load Pool
- if(!$this->initially_was_account){
- $this->init_successfull = TRUE;
- }else{
- $res = $this->si->getPool($this->cn);
- if($this->si->is_error()){
- $this->init_successfull = FALSE;
- msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
- return(FALSE);
- }else{
- $this->data = $this->orig_data = $res;
- $this->description = $this->data['description'][0];
-
- // Load software IDs
- $this->softwareIds = array();
- if(isset($this->data['softwareId'])){
- for($i = 0; $i < $this->data['softwareId']['count']; $i++){
- $this->softwareIds[] = $this->data['softwareId'][$i];
- }
+ // Extract pool name out of the fake dn.
+ $this->cn = $this->orig_cn = preg_replace("/^opsi:cn=([^,]*),.*$/","\\1",$dn);
}
- // Load product IDs
- $this->productIds = array();
- if(isset($this->data['productId'])){
- for($i = 0; $i < $this->data['productId']['count']; $i++){
- $this->productIds[] = $this->data['productId'][$i];
- }
- }
+ $this->init();
- // Load Licences
- $this->licenses = array();
- if(isset($this->data['licenses'])){
- for($i =0; $i< $this->data['licenses']['count']; $i++){
- $license = $this->data['licenses'][$i];
+ // Prepare lists
+ $this->licenseList = new sortableListing();
+ $this->licenseList->setDeleteable(true);
+ $this->licenseList->setEditable(true);
+ $this->licenseList->setWidth("100%");
+ $this->licenseList->setHeight("120px");
+ $this->licenseList->setColspecs(array('200px','*'));
+ $this->licenseList->setHeader(array(_("Section"),_("Description")));
+ $this->licenseList->setDefaultSortColumn(1);
- // Do not parse invalid licenses
- if(!is_array($license) || !isset($license['LICENSEPOOLIDS'])){
- continue;
- }
+ }
+
+
+ function init()
+ {
+ // Load local Boot Products
+ $res = $this->si->get_local_products();
+ $this->availableProductIds=array();
+ if($this->si->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
+ $this->init_successfull = FALSE;
+ return(FALSE);
+ }
+ $this->availableProductIds=array_keys($res);
+
+ // Load opsi hosts
+ $res = $this->si->list_clients();
+ $this->opsiHosts=array();
+ if($this->si->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
+ $this->init_successfull = FALSE;
+ return(FALSE);
+ }
+ $this->opsiHosts=$res;
- // Prepare Software License Key(s)
- $upper = strtoupper($license['LICENSEPOOLIDS'][0]['VALUE']);
- $license['LICENSEKEYS'] = $license['LICENSEKEYS'][0][$upper];
-
- // Map license attributes to a useable format
- $entry = array();
- foreach($this->licenseMap as $source => $target){
- $entry[$target] = "";
- if(isset($license[$source])){
- if(count($license[$source]) >= 2){
- $entry[$target] = array();
- foreach($license[$source] as $sub){
- $entry[$target][] = $sub['VALUE'];
- }
- }elseif(isset($license[$source][0]['VALUE'])){
- $entry[$target] = $license[$source][0]['VALUE'];
+ // Load Pool
+ if(!$this->initially_was_account){
+ $this->init_successfull = TRUE;
+ }else{
+ $res = $this->si->getPool($this->cn);
+ if($this->si->is_error()){
+ $this->init_successfull = FALSE;
+ msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
+ return(FALSE);
+ }else{
+ $this->data = $this->orig_data = $res;
+ $this->description = $this->data['description'][0];
+
+ // Load software IDs
+ $this->softwareIds = array();
+ if(isset($this->data['softwareId'])){
+ for($i = 0; $i < $this->data['softwareId']['count']; $i++){
+ $this->softwareIds[] = $this->data['softwareId'][$i];
+ }
}
- }
- }
- // Extract contract data
- $lData= $license['LICENSECONTRACTDATA'][0];
- foreach($this->licenseContractMap as $source => $target){
- if(isset($lData[$source])){
- if(count($lData[$source]) >= 2){
- $entry[$target] = array();
- foreach($lData[$source] as $sub){
- $entry[$target][] = $sub['VALUE'];
- }
- }elseif(isset($lData[$source][0]['VALUE'])){
- $entry[$target] = $lData[$source][0]['VALUE'];
+ // Load product IDs
+ $this->productIds = array();
+ if(isset($this->data['productId'])){
+ for($i = 0; $i < $this->data['productId']['count']; $i++){
+ $this->productIds[] = $this->data['productId'][$i];
+ }
}
- }
- }
- // There are some multi value attributes - force them to be of type array.
- foreach(array("boundToHost","usedByHost","licenseKey") as $attr){
- if(!is_array($entry[$attr])){
- $entry[$attr] = array($entry[$attr]);
- }
+ // Load Licences
+ $this->licenses = array();
+ if(isset($this->data['licenses'])){
+ for($i =0; $i< $this->data['licenses']['count']; $i++){
+ $license = $this->data['licenses'][$i];
+
+ // Do not parse invalid licenses
+ if(!is_array($license) || !isset($license['LICENSEPOOLIDS'])){
+ continue;
+ }
+
+ // Prepare Software License Key(s)
+ $upper = strtoupper($license['LICENSEPOOLIDS'][0]['VALUE']);
+ $license['LICENSEKEYS'] = $license['LICENSEKEYS'][0][$upper];
+
+ // Map license attributes to a useable format
+ $entry = array();
+ foreach($this->licenseMap as $source => $target){
+ $entry[$target] = "";
+ if(isset($license[$source])){
+ if(count($license[$source]) >= 2){
+ $entry[$target] = array();
+ foreach($license[$source] as $sub){
+ $entry[$target][] = $sub['VALUE'];
+ }
+ }elseif(isset($license[$source][0]['VALUE'])){
+ $entry[$target] = $license[$source][0]['VALUE'];
+ }
+ }
+ }
+
+ // Extract contract data
+ $lData= $license['LICENSECONTRACTDATA'][0];
+ foreach($this->licenseContractMap as $source => $target){
+ if(isset($lData[$source])){
+ if(count($lData[$source]) >= 2){
+ $entry[$target] = array();
+ foreach($lData[$source] as $sub){
+ $entry[$target][] = $sub['VALUE'];
+ }
+ }elseif(isset($lData[$source][0]['VALUE'])){
+ $entry[$target] = $lData[$source][0]['VALUE'];
+ }
+ }
+ }
+
+ // There are some multi value attributes - force them to be of type array.
+ foreach(array("boundToHost","usedByHost","licenseKey") as $attr){
+ if(!is_array($entry[$attr])){
+ $entry[$attr] = array($entry[$attr]);
+ }
+ }
+ $entry['MODIFIED'] = FALSE;
+ $this->licenses[$entry['cn']] = $entry;
+ }
+ }
+
+ $this->orig_licenses = $this->licenses;
+ $this->init_successfull = TRUE;
+ return;
}
- $entry['MODIFIED'] = FALSE;
- $this->licenses[$entry['cn']] = $entry;
- }
}
-
- $this->orig_licenses = $this->licenses;
- $this->init_successfull = TRUE;
- return;
- }
}
- }
- function execute()
- {
- plugin::execute();
+ function execute()
+ {
+ plugin::execute();
- $this->licenseList->setAcl($this->getacl('licenses'));
+ $this->licenseList->setAcl($this->getacl('licenses'));
- // Handle initialization failures.
- if(isset($_POST['retry_init'])) $this->init();
- if(!$this->init_successfull){
- $smarty = get_smarty();
- $smarty->assign("init_successfull", $this->init_successfull);
- return($smarty->fetch(get_template_path('licensePoolGeneric.tpl',TRUE,dirname(__FILE__))));
- }
-
- // Display dialogs!
- if($this->dialog instanceOf plugin){
- $this->dialog->save_object();
- $display = $this->dialog->execute();
- $display.= "<hr><div class='plugin-actions'>";
- if($this->acl_is_writeable("licenses")){
- $display.="<button type='submit' name='license_finish'>".msgPool::okButton()."</button>";
- }
- $display.="<button type='submit' name='license_cancel'>".msgPool::cancelButton()."</button>";
- $display.="</div>";
- return($display);
- }
-
- $smarty = get_smarty();
+ // Handle initialization failures.
+ if(isset($_POST['retry_init'])) $this->init();
+ if(!$this->init_successfull){
+ $smarty = get_smarty();
+ $smarty->assign("init_successfull", $this->init_successfull);
+ return($smarty->fetch(get_template_path('licensePoolGeneric.tpl',TRUE,dirname(__FILE__))));
+ }
- // Assign ACls
- $plInfo = $this->plInfo();
- foreach($plInfo['plProvidedAcls'] as $name => $desc){
- $smarty->assign("{$name}ACL",$this->getacl($name));
- }
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
- }
- $smarty->assign("init_successfull", $this->init_successfull);
- $smarty->assign("availableProductIds", array_diff( $this->availableProductIds, $this->productIds));
- $smarty->assign("productIds", $this->productIds);
- $smarty->assign("softwareIds", $this->softwareIds);
- $smarty->assign("licenses", $this->getLicenseList());
- $smarty->assign("initially_was_account", $this->initially_was_account);
- return($smarty->fetch(get_template_path('licensePoolGeneric.tpl',TRUE,dirname(__FILE__))));
- }
-
-
- function getLicenseList()
- {
- $data = $lData = array();
- if($this->acl_is_readable("licenses")){
- foreach($this->licenses as $i => $license){
- $maxInst = "";
- if($license['maximumInstallations'] == 0){
- $maxInst = _("unlimited");
- }else{
- $maxInst = $license['maximumInstallations'];
+ // Display dialogs!
+ if($this->dialog instanceOf plugin){
+ $this->dialog->save_object();
+ $display = $this->dialog->execute();
+ $display.= "<hr><div class='plugin-actions'>";
+ if($this->acl_is_writeable("licenses")){
+ $display.="<button type='submit' name='license_finish'>".msgPool::okButton()."</button>";
+ }
+ $display.="<button type='submit' name='license_cancel'>".msgPool::cancelButton()."</button>";
+ $display.="</div>";
+ return($display);
}
- $map = array(
- "VOLUME" => sprintf(_("Volume license (#%s)"), $maxInst),
- "OEM"=>_("OEM"),
- "RETAIL"=>_("Retail"),
- "CONCURRENT"=>_("Concurrent"));
+ $smarty = get_smarty();
- $data[$license['cn']] = $license['cn'];
- $lData[$license['cn']] = array('data' => array($license['cn'],$map[$license['licenseModel']]));
- }
- }
- $this->licenseList->setListData($data,$lData);
- return($this->licenseList->render());
- }
-
-
- /* Save HTML inputs
- */
- function save_object()
- {
-
- $this->licenseList->save_object();
- $tmp = $this->licenseList->getAction();
-
- // Allow license edit via href links
- if($tmp['action'] == 'edit'){
- $id = $this->licenseList->getKey($tmp['targets'][0]);
- if(isset($this->licenses[$id])){
- $this->dialog = new licenseGeneric($this->config,$this->dn,$this->licenses[$id], $this->opsiHosts);
- $this->dialog->set_acl_category('opsi');
- $this->dialog->set_acl_base($this->config->current['BASE']);
+ // Assign ACls
+ $plInfo = $this->plInfo();
+ foreach($plInfo['plProvidedAcls'] as $name => $desc){
+ $smarty->assign("{$name}ACL",$this->getacl($name));
}
- }
- if($tmp['action'] == 'delete'){
- $id = $this->licenseList->getKey($tmp['targets'][0]);
- if(isset($this->licenses[$id])){
- unset($this->licenses[$id]);
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,set_post($this->$attr));
}
+ $smarty->assign("init_successfull", $this->init_successfull);
+ $smarty->assign("availableProductIds", array_diff( $this->availableProductIds, $this->productIds));
+ $smarty->assign("productIds", $this->productIds);
+ $smarty->assign("softwareIds", $this->softwareIds);
+ $smarty->assign("licenses", $this->getLicenseList());
+ $smarty->assign("initially_was_account", $this->initially_was_account);
+ return($smarty->fetch(get_template_path('licensePoolGeneric.tpl',TRUE,dirname(__FILE__))));
}
- // Close license edit dialogs.
- if($this->dialog instanceOf plugin && isset($_POST['license_cancel'])){
- $this->dialog = NULL;
- return;
- }
- // Save license modifications
- if($this->dialog instanceOf plugin && isset($_POST['license_finish'])){
- $this->dialog->save_object();
- $msgs = $this->dialog->check();
- if(count($msgs)){
- msg_dialog::displayChecks($msgs);
- }else{
- $attrs = $this->dialog->save();
- $attrs['MODIFIED'] = TRUE;
- $this->licenses[$attrs['cn']] = $attrs;
- $this->dialog = NULL;
- }
- return;
+ function getLicenseList()
+ {
+ $data = $lData = array();
+ if($this->acl_is_readable("licenses")){
+ foreach($this->licenses as $i => $license){
+ $maxInst = "";
+ if($license['maximumInstallations'] == 0){
+ $maxInst = _("unlimited");
+ }else{
+ $maxInst = $license['maximumInstallations'];
+ }
+
+ $map = array(
+ "VOLUME" => sprintf(_("Volume license (#%s)"), $maxInst),
+ "OEM"=>_("OEM"),
+ "RETAIL"=>_("Retail"),
+ "CONCURRENT"=>_("Concurrent"));
+
+ $data[$license['cn']] = $license['cn'];
+ $lData[$license['cn']] = array('data' => array($license['cn'],$map[$license['licenseModel']]));
+ }
+ }
+ $this->licenseList->setListData($data,$lData);
+ return($this->licenseList->render());
}
- if(isset($_POST['opsiLicensePoolPosted'])){
- plugin::save_object();
- // Restore license cn, to avoid creating a copy...
- if($this->initially_was_account) $this->cn = $this->orig_cn;
+ /* Save HTML inputs
+ */
+ function save_object()
+ {
+
+ $this->licenseList->save_object();
+ $tmp = $this->licenseList->getAction();
- // We've to add prodcuts here
- if(preg_match("/w/",$this->getacl("productIds"))){
- if(isset($_POST['availableProduct']) && isset($_POST['addProduct'])){
- $pro = get_post('availableProduct');
- if(isset($this->availableProductIds[$pro]) && !in_array($this->availableProductIds[$pro], $this->productIds)){
- $this->productIds[] =$this->availableProductIds[$pro];
- }
+ // Allow license edit via href links
+ if($tmp['action'] == 'edit'){
+ $id = $this->licenseList->getKey($tmp['targets'][0]);
+ if(isset($this->licenses[$id])){
+ $this->dialog = new licenseGeneric($this->config,$this->dn,$this->licenses[$id], $this->opsiHosts);
+ $this->dialog->set_acl_category('opsi');
+ $this->dialog->set_acl_base($this->config->current['BASE']);
+ }
}
- }
-
- // We've to remove products here
- if(preg_match("/w/",$this->getacl("productIds"))){
- if(isset($_POST['productIds']) && isset($_POST['removeProduct'])){
- foreach($_POST['productIds'] as $key){
- if(isset($this->productIds[$key])){
- unset($this->productIds[$key]);
+ if($tmp['action'] == 'delete'){
+ $id = $this->licenseList->getKey($tmp['targets'][0]);
+ if(isset($this->licenses[$id])){
+ unset($this->licenses[$id]);
}
- }
}
- }
-
- // We've to add software here
- if(preg_match("/w/",$this->getacl("windowsSoftwareIds"))){
- if(isset($_POST['newSoftwareId']) && isset($_POST['addSoftware'])){
- $soft = trim(get_post('newSoftwareId'));
- if(!empty($soft) && !in_array($soft, $this->softwareIds)){
- $this->softwareIds[] = $soft;
- }
+
+ // Close license edit dialogs.
+ if($this->dialog instanceOf plugin && isset($_POST['license_cancel'])){
+ $this->dialog = NULL;
+ return;
}
- }
-
- // We've to remove software Ids here
- if(preg_match("/w/",$this->getacl("windowsSoftwareIds"))){
- if(isset($_POST['softwareIds']) && isset($_POST['removeSoftware'])){
- foreach($_POST['softwareIds'] as $key){
- if(isset($this->softwareIds[$key])){
- unset($this->softwareIds[$key]);
+
+ // Save license modifications
+ if($this->dialog instanceOf plugin && isset($_POST['license_finish'])){
+ $this->dialog->save_object();
+ $msgs = $this->dialog->check();
+ if(count($msgs)){
+ msg_dialog::displayChecks($msgs);
+ }else{
+ $attrs = $this->dialog->save();
+ $attrs['MODIFIED'] = TRUE;
+ $this->licenses[$attrs['cn']] = $attrs;
+ $this->dialog = NULL;
}
- }
+ return;
}
- }
-
- // We've to create a new license
- if(preg_match("/w/",$this->getacl("licenses"))){
- if(isset($_POST['addLicense'])){
- $this->dialog = new licenseGeneric($this->config,$this->dn,array(), $this->opsiHosts);
- $this->dialog->set_acl_category('opsi');
- $this->dialog->set_acl_base($this->config->current['BASE']);
+
+ if(isset($_POST['opsiLicensePoolPosted'])){
+ plugin::save_object();
+
+ // Restore license cn, to avoid creating a copy...
+ if($this->initially_was_account) $this->cn = $this->orig_cn;
+
+ // We've to add prodcuts here
+ if(preg_match("/w/",$this->getacl("productIds"))){
+ if(isset($_POST['availableProduct']) && isset($_POST['addProduct'])){
+ $pro = get_post('availableProduct');
+ if(isset($this->availableProductIds[$pro]) && !in_array($this->availableProductIds[$pro], $this->productIds)){
+ $this->productIds[] =$this->availableProductIds[$pro];
+ }
+ }
+ }
+
+ // We've to remove products here
+ if(preg_match("/w/",$this->getacl("productIds"))){
+ if(isset($_POST['productIds']) && isset($_POST['removeProduct'])){
+ foreach($_POST['productIds'] as $key){
+ if(isset($this->productIds[$key])){
+ unset($this->productIds[$key]);
+ }
+ }
+ }
+ }
+
+ // We've to add software here
+ if(preg_match("/w/",$this->getacl("windowsSoftwareIds"))){
+ if(isset($_POST['newSoftwareId']) && isset($_POST['addSoftware'])){
+ $soft = trim(get_post('newSoftwareId'));
+ if(!empty($soft) && !in_array($soft, $this->softwareIds)){
+ $this->softwareIds[] = $soft;
+ }
+ }
+ }
+
+ // We've to remove software Ids here
+ if(preg_match("/w/",$this->getacl("windowsSoftwareIds"))){
+ if(isset($_POST['softwareIds']) && isset($_POST['removeSoftware'])){
+ foreach($_POST['softwareIds'] as $key){
+ if(isset($this->softwareIds[$key])){
+ unset($this->softwareIds[$key]);
+ }
+ }
+ }
+ }
+
+ // We've to create a new license
+ if(preg_match("/w/",$this->getacl("licenses"))){
+ if(isset($_POST['addLicense'])){
+ $this->dialog = new licenseGeneric($this->config,$this->dn,array(), $this->opsiHosts);
+ $this->dialog->set_acl_category('opsi');
+ $this->dialog->set_acl_base($this->config->current['BASE']);
+ }
+ }
}
- }
- }
- }
-
-
- /* Check user input and return a list of 'invalid input' messages.
- */
- function check()
- {
- $message = plugin::check();
- return($message);
- }
-
-
-
- /* Removes the object from the opsi database
- */
- function remove_from_parent()
- {
- $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");
+ }
+
+
+ /* Check user input and return a list of 'invalid input' messages.
+ */
+ function check()
+ {
+ $message = plugin::check();
+ return($message);
}
- new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$this->si->get_error());
- }
- /* Saves object modifications
- */
- function save()
- {
- plugin::save();
+ /* Removes the object from the opsi database
+ */
+ function remove_from_parent()
+ {
+ $this->si->deletePool($this->orig_cn);
+ if($this->si->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
+ }else{
- // Send modify/add events
- $mode = "modify";
- if($this->orig_dn == "new"){
- $mode = "add";
- }
+ // Trigger remove signal
+ $this->handle_post_events("remove");
+ }
- // Create or update the pool
- $this->si->createPool($this->cn, $this->description,$this->productIds,$this->softwareIds);#
- if($this->si->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
- }else{
- $this->handle_post_events($mode);
+ new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$this->si->get_error());
}
- // Create, remove or update 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){
- $this->si->removeLicenseFromPool($this->cn, $license['cn']);
- if($this->si->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
- }
- }
-
- // Add licenses
- foreach($add as $license){
- $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);
- }
- }
- // 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);
- }
- }
+ /* Saves object modifications
+ */
+ function save()
+ {
+ plugin::save();
- // Log action
- if($mode == "modify"){
- new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$this->si->get_error());
- }else{
- new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$this->si->get_error());
+ // Send modify/add events
+ $mode = "modify";
+ if($this->orig_dn == "new"){
+ $mode = "add";
+ }
+
+ // Create or update the pool
+ $this->si->createPool($this->cn, $this->description,$this->productIds,$this->softwareIds);#
+ if($this->si->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
+ }else{
+ $this->handle_post_events($mode);
+ }
+
+ // Create, remove or update 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){
+ $this->si->removeLicenseFromPool($this->cn, $license['cn']);
+ if($this->si->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
+ }
+ }
+
+ // Add licenses
+ foreach($add as $license){
+ $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);
+ }
+ }
+
+ // 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);
+ }
+ }
+
+ // Log action
+ if($mode == "modify"){
+ new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$this->si->get_error());
+ }else{
+ new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$this->si->get_error());
+ }
+
+ return 0;
}
- return 0;
- }
-
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Pool generic"),
- "plDescription" => _("License pool generic"),
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 7,
- "plSection" => array("administration"),
- "plCategory" => array("opsi"),
- "plProvidedAcls"=> array(
- "cn" => _("Name"),
- "description" => _("Description"),
- "productIds" => _("Applications"),
- "windowsSoftwareIds" => _("Windows software IDs"),
- "licenses" => _("Licenses"))
- ));
- }
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Pool generic"),
+ "plDescription" => _("License pool generic"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 7,
+ "plSection" => array("administration"),
+ "plCategory" => array("opsi"),
+ "plProvidedAcls"=> array(
+ "cn" => _("Name"),
+ "description" => _("Description"),
+ "productIds" => _("Applications"),
+ "windowsSoftwareIds" => _("Windows software IDs"),
+ "licenses" => _("Licenses"))
+ ));
+ }
}
diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_licenseUsage.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_licenseUsage.inc
index 83a283568cd3b9e7edca3d2e4bdf420fdad9797d..06e00d45070fc9b1311f5ae9fcd5dc032cdf3aa9 100644 (file)
<?php
/*
-* This code is part of GOsa (http://www.gosa-project.org)
-* Copyright (C) 2003-2008 GONICUS GmbH
-*
-* ID: $$Id: class_opsiLicenses.inc 13520 2009-03-09 14:54:13Z hickert $$
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id: class_opsiLicenses.inc 13520 2009-03-09 14:54:13Z hickert $$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
class licenseUsage extends plugin
{
- var $cn = "";
- var $licenseUses = array();
- var $init_successfull = FALSE;
+ var $cn = "";
+ var $licenseUses = array();
+ var $init_successfull = FALSE;
+
+
+ function __construct(&$config,$dn)
+ {
+ $this->config = $config;
+ $this->dn = $this->orig_dn = $dn;
+ $this->si = new opsiLicenceHandler($this->config);
+
+ $this->is_account=TRUE;
+ if($this->dn == "new"){
+ $this->initially_was_account = FALSE;
+ }else{
+ $this->initially_was_account = TRUE;
+ $this->cn = $this->orig_cn = preg_replace("/^opsi:cn=([^,]*),.*$/","\\1",$dn);
+ }
+
+ // Extract pool name out of the fake dn.
+ $this->init();
+
+ // Prepare lists
+ $this->usageList = new sortableListing();
+ $this->usageList->setDeleteable(false);
+ $this->usageList->setEditable(false);
+ $this->usageList->setWidth("100%");
+ $this->usageList->setHeight("300px");
+ $this->usageList->setHeader(array(_("Host"),_("Key"),_("Pool"), _("License")));
+ $this->usageList->setDefaultSortColumn(1);
+ }
+
+ function init()
+ {
+ $this->licenseUses = array();
+ if(!$this->initially_was_account){
+ $this->init_successfull = TRUE;
+ }else{
- function __construct(&$config,$dn)
- {
- $this->config = $config;
- $this->dn = $this->orig_dn = $dn;
- $this->si = new opsiLicenceHandler($this->config);
+ $res = $this->si->getLicenseUsage("", $this->cn);
+ if($this->si->is_error()){
+ $this->init_successfull = FALSE;
+ msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
+ return;
+ }
- $this->is_account=TRUE;
- if($this->dn == "new"){
- $this->initially_was_account = FALSE;
- }else{
- $this->initially_was_account = TRUE;
- $this->cn = $this->orig_cn = preg_replace("/^opsi:cn=([^,]*),.*$/","\\1",$dn);
+ $this->licenseUses = $res;
+ $this->init_successfull = TRUE;
+ }
}
- // Extract pool name out of the fake dn.
- $this->init();
-
- // Prepare lists
- $this->usageList = new sortableListing();
- $this->usageList->setDeleteable(false);
- $this->usageList->setEditable(false);
- $this->usageList->setWidth("100%");
- $this->usageList->setHeight("300px");
- $this->usageList->setHeader(array(_("Host"),_("Key"),_("Pool"), _("License")));
- $this->usageList->setDefaultSortColumn(1);
- }
-
-
- function init()
- {
- $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;
- msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
- return;
- }
-
- $this->licenseUses = $res;
- $this->init_successfull = TRUE;
+
+ function execute()
+ {
+ plugin::execute();
+
+ $ui = get_userinfo();
+ $readable = $ui->get_permissions($this->config->current['BASE'], "opsi/licenseUsage","");
+ $this->usageList->setAcl($readable);
+
+ // Handle initialization failures.
+ if(isset($_POST['retry_init'])) $this->init();
+ if(!$this->init_successfull){
+ $smarty = get_smarty();
+ $smarty->assign("init_successfull", $this->init_successfull);
+ return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__))));
+ }
+
+ // Create usage list
+ $data = array();
+ if($readable) {
+ foreach($this->licenseUses as $license){
+ $data[] = array('data'=>array(
+ $license['hostId'][0],
+ $license['licenseKey'][0],
+ $license['licensePoolId'][0],
+ $license['softwareLicenseId'][0]));
+ }
+ }
+ $this->usageList->setListData($data,$data);
+ $smarty = get_smarty();
+
+ // Assign ACls
+ $plInfo = $this->plInfo();
+ foreach($plInfo['plProvidedAcls'] as $name => $desc){
+ $smarty->assign("{$name}ACL",$this->getacl($name));
+ }
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,set_post($this->$attr));
+ }
+
+ $smarty->assign("licenseUses", $this->usageList->render());
+ $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__))));
}
- }
- function execute()
- {
- plugin::execute();
+ /* Save HTML inputs
+ */
+ function save_object()
+ {
+ if(isset($_POST['opsiLicenseUsagePosted'])){
+ plugin::save_object();
+ }
+ }
- $ui = get_userinfo();
- $readable = $ui->get_permissions($this->config->current['BASE'], "opsi/licenseUsage","");
- $this->usageList->setAcl($readable);
- // Handle initialization failures.
- if(isset($_POST['retry_init'])) $this->init();
- if(!$this->init_successfull){
- $smarty = get_smarty();
- $smarty->assign("init_successfull", $this->init_successfull);
- return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__))));
- }
-
- // Create usage list
- $data = array();
- if($readable) {
- foreach($this->licenseUses as $license){
- $data[] = array('data'=>array(
- $license['hostId'][0],
- $license['licenseKey'][0],
- $license['licensePoolId'][0],
- $license['softwareLicenseId'][0]));
- }
- }
- $this->usageList->setListData($data,$data);
- $smarty = get_smarty();
-
- // Assign ACls
- $plInfo = $this->plInfo();
- foreach($plInfo['plProvidedAcls'] as $name => $desc){
- $smarty->assign("{$name}ACL",$this->getacl($name));
- }
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
+ /* Check user input and return a list of 'invalid input' messages.
+ */
+ function check()
+ {
+ $message = plugin::check();
+ return($message);
}
- $smarty->assign("licenseUses", $this->usageList->render());
- $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__))));
- }
-
-
- /* Save HTML inputs
- */
- function save_object()
- {
- if(isset($_POST['opsiLicenseUsagePosted'])){
- plugin::save_object();
+
+ /* Saves object modifications
+ */
+ function save() { }
+ function remove_from_parent(){ return; }
+
+
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("License usage"),
+ "plDescription" => _("License usage"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 11,
+ "plSection" => array("administration"),
+ "plCategory" => array("opsi"),
+ "plProvidedAcls"=> array()));
}
- }
-
-
- /* Check user input and return a list of 'invalid input' messages.
- */
- function check()
- {
- $message = plugin::check();
- return($message);
- }
-
-
- /* Saves object modifications
- */
- function save() { }
- function remove_from_parent(){ return; }
-
-
- static function plInfo()
- {
- return (array(
- "plShortName" => _("License usage"),
- "plDescription" => _("License usage"),
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 11,
- "plSection" => array("administration"),
- "plCategory" => array("opsi"),
- "plProvidedAcls"=> array()));
- }
}
diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_licenseUsageByHost.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_licenseUsageByHost.inc
index ff37456fa04fec76902eae495ff99253c0da7173..96b1f0ae9d22799364d43d51522c5f0a57f89328 100644 (file)
<?php
/*
-* This code is part of GOsa (http://www.gosa-project.org)
-* Copyright (C) 2003-2008 GONICUS GmbH
-*
-* ID: $$Id: class_opsiLicenses.inc 13520 2009-03-09 14:54:13Z hickert $$
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id: class_opsiLicenses.inc 13520 2009-03-09 14:54:13Z hickert $$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
class licenseUsageByHost extends plugin
{
- var $cn = "";
- var $licenseUses = array();
- var $reservedLicenses = array();
- var $init_successfull = FALSE;
-
- var $availableLicenses = array();
-
- function __construct(&$config,$dn)
- {
- $this->config = $config;
- $this->dn = $this->orig_dn = $dn;
- $this->si = new opsiLicenceHandler($this->config);
-
- $this->is_account=TRUE;
- if($this->dn == "new"){
- $this->initially_was_account = FALSE;
- }else{
- $this->initially_was_account = TRUE;
- $this->cn = $this->orig_cn = preg_replace("/^opsi:=([^,]*),.*$/","\\1",$dn);
- }
+ var $cn = "";
+ var $licenseUses = array();
+ var $reservedLicenses = array();
+ var $init_successfull = FALSE;
+
+ var $availableLicenses = array();
+
+ function __construct(&$config,$dn)
+ {
+ $this->config = $config;
+ $this->dn = $this->orig_dn = $dn;
+ $this->si = new opsiLicenceHandler($this->config);
+
+ $this->is_account=TRUE;
+ if($this->dn == "new"){
+ $this->initially_was_account = FALSE;
+ }else{
+ $this->initially_was_account = TRUE;
+ $this->cn = $this->orig_cn = preg_replace("/^opsi:=([^,]*),.*$/","\\1",$dn);
+ }
- // Extract pool name out of the fake dn.
- $this->init();
-
- // Prepare lists
- $this->reservedList = new sortableListing();
- $this->reservedList->setDeleteable(true);
- $this->reservedList->setEditable(false);
- $this->reservedList->setWidth("100%");
- $this->reservedList->setHeight("220px");
- $this->reservedList->setColspecs(array('200px','*'));
- $this->reservedList->setHeader(array(_("Pool"),_("License ID")));
- $this->reservedList->setDefaultSortColumn(1);
- $this->reservedList->setAcl('rwcdm'); // All ACLs, we filter on our own here.
-
- $this->usedList = new sortableListing();
- $this->usedList->setDeleteable(false);
- $this->usedList->setEditable(false);
- $this->usedList->setWidth("100%");
- $this->usedList->setHeight("220px");
- $this->usedList->setColspecs(array('200px','*'));
- $this->usedList->setHeader(array(_("Key"),_("Pool"),_("License ID")));
- $this->usedList->setDefaultSortColumn(1);
- $this->usedList->setAcl('rwcdm'); // All ACLs, we filter on our own here.
- }
-
-
- function init()
- {
- $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()){
- msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
- $this->init_successfull = FALSE;
- return;
- }
- $this->licenseUses = $res;
-
- // Get reservations
- $res = $this->si->getReservedLicensesForHost($this->cn);
- if($this->si->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
- $this->init_successfull = FALSE;
- return;
- }
- foreach($res as $pool){
- $l = $pool['softwareLicenseId'][0];
- $this->reservedLicenses[$l] = $l;
- }
- $this->init_reservedLicenses = $this->reservedLicenses;
-
- // Get list of license pools
- $res = $this->si->listLicenses();
- if($this->si->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
- $this->init_successfull = FALSE;
- return;
- }
- $this->availableLicenses = array();
- foreach($res as $license){
- if(!isset($license['licensePoolId'])) $license['licensePoolId'][0] = '-';
- $this->availableLicenses[$license['softwareLicenseId'][0]] = $license;
- }
-
- $this->init_successfull = TRUE;
+ // Extract pool name out of the fake dn.
+ $this->init();
+
+ // Prepare lists
+ $this->reservedList = new sortableListing();
+ $this->reservedList->setDeleteable(true);
+ $this->reservedList->setEditable(false);
+ $this->reservedList->setWidth("100%");
+ $this->reservedList->setHeight("220px");
+ $this->reservedList->setColspecs(array('200px','*'));
+ $this->reservedList->setHeader(array(_("Pool"),_("License ID")));
+ $this->reservedList->setDefaultSortColumn(1);
+ $this->reservedList->setAcl('rwcdm'); // All ACLs, we filter on our own here.
+
+ $this->usedList = new sortableListing();
+ $this->usedList->setDeleteable(false);
+ $this->usedList->setEditable(false);
+ $this->usedList->setWidth("100%");
+ $this->usedList->setHeight("220px");
+ $this->usedList->setColspecs(array('200px','*'));
+ $this->usedList->setHeader(array(_("Key"),_("Pool"),_("License ID")));
+ $this->usedList->setDefaultSortColumn(1);
+ $this->usedList->setAcl('rwcdm'); // All ACLs, we filter on our own here.
}
- }
- function execute()
- {
- plugin::execute();
+ function init()
+ {
+ $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()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
+ $this->init_successfull = FALSE;
+ return;
+ }
+ $this->licenseUses = $res;
+
+ // Get reservations
+ $res = $this->si->getReservedLicensesForHost($this->cn);
+ if($this->si->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
+ $this->init_successfull = FALSE;
+ return;
+ }
+ foreach($res as $pool){
+ $l = $pool['softwareLicenseId'][0];
+ $this->reservedLicenses[$l] = $l;
+ }
+ $this->init_reservedLicenses = $this->reservedLicenses;
+
+ // Get list of license pools
+ $res = $this->si->listLicenses();
+ if($this->si->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
+ $this->init_successfull = FALSE;
+ return;
+ }
+ $this->availableLicenses = array();
+ foreach($res as $license){
+ if(!isset($license['licensePoolId'])) $license['licensePoolId'][0] = '-';
+ $this->availableLicenses[$license['softwareLicenseId'][0]] = $license;
+ }
- // Handle initialization failures.
- if(isset($_POST['retry_init'])) $this->init();
- if(!$this->init_successfull){
- $smarty = get_smarty();
- $smarty->assign("init_successfull", $this->init_successfull);
- return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__))));
- }
-
- // Create usage list
- $data = array();
- $this->usedList->setAcl($this->getacl('hostId'));
- foreach($this->licenseUses as $license){
- $data[] = array('data' => array(
- $license['licenseKey'][0],
- $license['licensePoolId'][0],
- $license['softwareLicenseId'][0]));
- }
- $this->usedList->setListData($data,$data);
- $this->usedList->update();
-
- // Create reserved list
- $data = $lData = array();
- $this->reservedList->setAcl($this->getacl('boundToHost'));
- foreach($this->reservedLicenses as $key => $license){
- $l = $this->availableLicenses[$key];
- $data[$key] = $key;
- $lData[$key] = array('data' => array(
- $l['softwareLicenseId'][0],
- $l['licensePoolId'][0]));
- }
- $this->reservedList->setListData($data,$lData);
- $this->reservedList->update();
-
- $smarty = get_smarty();
-
- // Assign ACls
- $plInfo = $this->plInfo();
- foreach($plInfo['plProvidedAcls'] as $name => $desc){
- $smarty->assign("{$name}ACL",$this->getacl($name));
+ $this->init_successfull = TRUE;
+ }
}
- foreach($this->attributes as $attr){
- $smarty->assign($attr,$this->$attr);
+
+
+ function execute()
+ {
+ plugin::execute();
+
+ // Handle initialization failures.
+ if(isset($_POST['retry_init'])) $this->init();
+ if(!$this->init_successfull){
+ $smarty = get_smarty();
+ $smarty->assign("init_successfull", $this->init_successfull);
+ return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__))));
+ }
+
+ // Create usage list
+ $data = array();
+ $this->usedList->setAcl($this->getacl('hostId'));
+ foreach($this->licenseUses as $license){
+ $data[] = array('data' => array(
+ $license['licenseKey'][0],
+ $license['licensePoolId'][0],
+ $license['softwareLicenseId'][0]));
+ }
+ $this->usedList->setListData($data,$data);
+ $this->usedList->update();
+
+ // Create reserved list
+ $data = $lData = array();
+ $this->reservedList->setAcl($this->getacl('boundToHost'));
+ foreach($this->reservedLicenses as $key => $license){
+ $l = $this->availableLicenses[$key];
+ $data[$key] = $key;
+ $lData[$key] = array('data' => array(
+ $l['softwareLicenseId'][0],
+ $l['licensePoolId'][0]));
+ }
+ $this->reservedList->setListData($data,$lData);
+ $this->reservedList->update();
+
+ $smarty = get_smarty();
+
+ // Assign ACls
+ $plInfo = $this->plInfo();
+ foreach($plInfo['plProvidedAcls'] as $name => $desc){
+ $smarty->assign("{$name}ACL",$this->getacl($name));
+ }
+ foreach($this->attributes as $attr){
+ $smarty->assign($attr,set_post($this->$attr));
+ }
+
+ // build up a available licenses list.
+ $licenses = array();
+ foreach($this->availableLicenses as $key => $license){
+ if(!in_array($license['softwareLicenseId'][0], $this->reservedLicenses)){
+ $licenses[$key] = $license['softwareLicenseId'][0]." [".$license['licensePoolId'][0]."]";
+ }
+ }
+
+ $smarty->assign("licenseUses", $this->usedList->render());
+ $smarty->assign("licenseReserved", $this->reservedList->render());
+ $smarty->assign("init_successfull", $this->init_successfull);
+ $smarty->assign("availableLicenses", $licenses);
+ $smarty->assign("initially_was_account", $this->initially_was_account);
+ return($smarty->fetch(get_template_path('licenseUsageByHost.tpl',TRUE,dirname(__FILE__))));
}
- // build up a available licenses list.
- $licenses = array();
- foreach($this->availableLicenses as $key => $license){
- if(!in_array($license['softwareLicenseId'][0], $this->reservedLicenses)){
- $licenses[$key] = $license['softwareLicenseId'][0]." [".$license['licensePoolId'][0]."]";
- }
+
+ /* Save HTML inputs
+ */
+ function save_object()
+ {
+ if(isset($_POST['opsiLicenseUsagePosted'])){
+ plugin::save_object();
+
+ if(preg_match("/w/i",$this->getacl('boundToHost'))){
+
+ $this->reservedList->save_object();
+ $action = $this->reservedList->getAction();
+ if($action['action'] == "delete") {
+ $id = $this->reservedList->getKey($action['targets'][0]);
+ if(isset($this->reservedLicenses[$id])) {
+ unset($this->reservedLicenses[$id]);
+ }
+ }
+
+ // Check if we've to add reservations
+ if(isset($_POST['availableLicense']) && isset($_POST['addReservation'])){
+ $id = get_post('availableLicense');
+ if(isset($this->availableLicenses[$id]) && !in_array($this->availableLicenses[$id],$this->reservedLicenses)){
+ $this->reservedLicenses[$id] = $this->availableLicenses[$id]['softwareLicenseId'][0];
+ }
+ }
+ }
+ }
+ }
+
+
+ /* Check user input and return a list of 'invalid input' messages.
+ */
+ function check()
+ {
+ $message = plugin::check();
+ return($message);
}
- $smarty->assign("licenseUses", $this->usedList->render());
- $smarty->assign("licenseReserved", $this->reservedList->render());
- $smarty->assign("init_successfull", $this->init_successfull);
- $smarty->assign("availableLicenses", $licenses);
- $smarty->assign("initially_was_account", $this->initially_was_account);
- return($smarty->fetch(get_template_path('licenseUsageByHost.tpl',TRUE,dirname(__FILE__))));
- }
-
-
- /* Save HTML inputs
- */
- function save_object()
- {
- if(isset($_POST['opsiLicenseUsagePosted'])){
- plugin::save_object();
-
- if(preg_match("/w/i",$this->getacl('boundToHost'))){
-
- $this->reservedList->save_object();
- $action = $this->reservedList->getAction();
- if($action['action'] == "delete") {
- $id = $this->reservedList->getKey($action['targets'][0]);
- if(isset($this->reservedLicenses[$id])) {
- unset($this->reservedLicenses[$id]);
+
+ function save()
+ {
+ $del = array_diff($this->init_reservedLicenses, $this->reservedLicenses);
+ $add = array_diff($this->reservedLicenses, $this->init_reservedLicenses);
+
+ foreach($del as $license){
+ $this->si->removeLicenseReservationFromHost($license, $this->cn);
+ if($this->si->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
}
}
- // Check if we've to add reservations
- if(isset($_POST['availableLicense']) && isset($_POST['addReservation'])){
- $id = get_post('availableLicense');
- if(isset($this->availableLicenses[$id]) && !in_array($this->availableLicenses[$id],$this->reservedLicenses)){
- $this->reservedLicenses[$id] = $this->availableLicenses[$id]['softwareLicenseId'][0];
- }
+ foreach($add as $license){
+ $this->si->reserverLicenseForHost($license, $this->cn);
+ if($this->si->is_error()){
+ msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
+ }
}
- }
- }
- }
-
-
- /* Check user input and return a list of 'invalid input' messages.
- */
- function check()
- {
- $message = plugin::check();
- return($message);
- }
-
-
- function save()
- {
- $del = array_diff($this->init_reservedLicenses, $this->reservedLicenses);
- $add = array_diff($this->reservedLicenses, $this->init_reservedLicenses);
-
- foreach($del as $license){
- $this->si->removeLicenseReservationFromHost($license, $this->cn);
- if($this->si->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
- }
}
- foreach($add as $license){
- $this->si->reserverLicenseForHost($license, $this->cn);
- if($this->si->is_error()){
- msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
- }
+
+ function remove_from_parent(){ }
+
+
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Usage by host"),
+ "plDescription" => _("License usage by host"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 13,
+ "plSection" => array("administration"),
+ "plCategory" => array("opsi"),
+ "plProvidedAcls"=> array(
+ "hostId" => _("Used by"),
+ "boundToHost" => _("License reservation"))
+ ));
}
- }
-
-
- function remove_from_parent(){ }
-
-
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Usage by host"),
- "plDescription" => _("License usage by host"),
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 13,
- "plSection" => array("administration"),
- "plCategory" => array("opsi"),
- "plProvidedAcls"=> array(
- "hostId" => _("Used by"),
- "boundToHost" => _("License reservation"))
- ));
- }
}
diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc
index fd8b01f472f7580ace9d88cc517779db0045c6d8..96ae987dc18e3e6d9cc5dba0d2ff3b60048fafec 100644 (file)
- /*******************
- * POOLs
- *******************/
-
- protected $use_alternative_xml_parse_method = TRUE;
-
-
- /* @brief Returns licensePoolId, description, productIds and windowsSoftwareIds
- * for all found license pools.
- */
- function listPools()
- {
- $data= array();
- $res = $this->send_data("gosa_opsi_getLicensePools_listOfHashes",$this->target,$data,TRUE);
- $items = array();
- if(isset($res['XML'][0]['ANSWER_OPSI_GETLICENSEPOOLS_LISTOFHASHES'])){
- if(isset($res['XML'][0]['RESULT'][0]['HIT'])){
- $items = $res['XML'][0]['RESULT'][0]['HIT'];
- $data =array();
- foreach($items as $item){
- $entry = array();
- foreach(
- array(
- "DESCRIPTION" => "description",
- "LICENSEPOOLID" => "cn",
- "PRODUCTIDS" => "productId",
- "WINDOWSSOFTWAREIDS"=> "softwareId") as $source => $dest){
-
- if(isset($item[$source])){
- $entry[$dest] = array('count' => 0);
- foreach($item[$source] as $obj){
- $entry[$dest][] = $obj['VALUE'];
- }
- $entry[$dest]['count'] = (count($entry[$dest]) -1 );
- }
- }
- $data[] =$entry;
+ /*******************
+ * POOLs
+ *******************/
+
+ protected $use_alternative_xml_parse_method = TRUE;
+
+
+ /* @brief Returns licensePoolId, description, productIds and windowsSoftwareIds
+ * for all found license pools.
+ */
+ function listPools()
+ {
+ $data= array();
+ $res = $this->send_data("gosa_opsi_getLicensePools_listOfHashes",$this->target,$data,TRUE);
+ $items = array();
+ if(isset($res['XML'][0]['ANSWER_OPSI_GETLICENSEPOOLS_LISTOFHASHES'])){
+ if(isset($res['XML'][0]['RESULT'][0]['HIT'])){
+ $items = $res['XML'][0]['RESULT'][0]['HIT'];
+ $data =array();
+ foreach($items as $item){
+ $entry = array();
+ foreach(
+ array(
+ "DESCRIPTION" => "description",
+ "LICENSEPOOLID" => "cn",
+ "PRODUCTIDS" => "productId",
+ "WINDOWSSOFTWAREIDS"=> "softwareId") as $source => $dest){
+
+ if(isset($item[$source])){
+ $entry[$dest] = array('count' => 0);
+ foreach($item[$source] as $obj){
+ $entry[$dest][] = $obj['VALUE'];
+ }
+ $entry[$dest]['count'] = (count($entry[$dest]) -1 );
+ }
+ }
+ $data[] =$entry;
+ }
+ return($data);
+ }else{
+ // No entries, but got an answer. We probably do not have any pools yet.
+ return(array());
+ }
}
- return($data);
- }else{
- // No entries, but got an answer. We probably do not have any pools yet.
- return(array());
- }
- }
- return(FALSE);
- }
-
-
- /* @brief Create a license pool at Opsi server.
- * @param licensePoolId The name of the pool (optional).
- * @param description The description of the pool (optional).
- * @param productIds A list of assigned porducts of the pool (optional).
- * @param windowsSoftwareIds A list of windows software Ids associated to the pool (optional).
- */
- function createPool($poolId,$desc = "",$products = array(),$softwareIds = array())
- {
- $data= array();
- $data['licensePoolId'] = htmlentities($poolId);
- if(!empty($desc)){
- $data['description'] = htmlentities($desc);
- }
- if(count($products)){
- $data['productIds'] = $products;
- }
- if(count($softwareIds)){
- $data['windowsSoftwareIds'] = $softwareIds;
+ return(FALSE);
}
- $res = $this->send_data("gosa_opsi_createLicensePool",$this->target,$data,TRUE);
- if(isset($res['XML'][0]['ANSWER_OPSI_CREATELICENSEPOOL'])){
- return(TRUE);
+
+ /* @brief Create a license pool at Opsi server.
+ * @param licensePoolId The name of the pool (optional).
+ * @param description The description of the pool (optional).
+ * @param productIds A list of assigned porducts of the pool (optional).
+ * @param windowsSoftwareIds A list of windows software Ids associated to the pool (optional).
+ */
+ function createPool($poolId,$desc = "",$products = array(),$softwareIds = array())
+ {
+ $data= array();
+ $data['licensePoolId'] = htmlentities($poolId);
+ if(!empty($desc)){
+ $data['description'] = htmlentities($desc);
+ }
+ if(count($products)){
+ $data['productIds'] = $products;
+ }
+ if(count($softwareIds)){
+ $data['windowsSoftwareIds'] = $softwareIds;
+ }
+
+ $res = $this->send_data("gosa_opsi_createLicensePool",$this->target,$data,TRUE);
+ if(isset($res['XML'][0]['ANSWER_OPSI_CREATELICENSEPOOL'])){
+ return(TRUE);
+ }
+ return(FALSE);
}
- return(FALSE);
- }
-
-
- /*
- * @brief Return productIds, windowsSoftwareIds and description for a given licensePoolId
- * @param licensePoolId The name of the pool.
- */
- function getPool($licensePoolId)
- {
- $data= array();
- $data['licensePoolId'] = htmlentities($licensePoolId);
- $res = $this->send_data("gosa_opsi_getPool",$this->target,$data,TRUE);
-
- if(isset($res['XML'][0]['ANSWER_OPSI_GETPOOL'])){
- $item = array();
- foreach(array("LICENSEPOOLID" => "cn",
- "DESCRIPTION" => "description",
- "LICENSES" => "licenses",
- "LICENSECONTRACTDATA" => "contract",
- "WINDOWSSOFTWAREIDS" => "softwareId",
- "PRODUCTIDS" => "productId") as $source => $target){
- if(isset($res['XML'][0][$source])){
- $item[$target] = array('count' => 0);
-
-
- foreach($res['XML'][0][$source] as $data){
- if(isset($data['VALUE'])){
- $item[$target][] = $data['VALUE'];
- }elseif(isset($data['HIT'])){
- $item[$target] = array_merge($item[$target],$data['HIT']);
+
+
+ /*
+ * @brief Return productIds, windowsSoftwareIds and description for a given licensePoolId
+ * @param licensePoolId The name of the pool.
+ */
+ function getPool($licensePoolId)
+ {
+ $data= array();
+ $data['licensePoolId'] = htmlentities($licensePoolId);
+ $res = $this->send_data("gosa_opsi_getPool",$this->target,$data,TRUE);
+
+ if(isset($res['XML'][0]['ANSWER_OPSI_GETPOOL'])){
+ $item = array();
+ foreach(array("LICENSEPOOLID" => "cn",
+ "DESCRIPTION" => "description",
+ "LICENSES" => "licenses",
+ "LICENSECONTRACTDATA" => "contract",
+ "WINDOWSSOFTWAREIDS" => "softwareId",
+ "PRODUCTIDS" => "productId") as $source => $target){
+ if(isset($res['XML'][0][$source])){
+ $item[$target] = array('count' => 0);
+
+
+ foreach($res['XML'][0][$source] as $data){
+ if(isset($data['VALUE'])){
+ $item[$target][] = $data['VALUE'];
+ }elseif(isset($data['HIT'])){
+ $item[$target] = array_merge($item[$target],$data['HIT']);
+ }
+ }
+ $item[$target]['count'] = count($item[$target]) -1 ;
+ }
}
- }
- $item[$target]['count'] = count($item[$target]) -1 ;
+ return($item);
}
- }
- return($item);
+ return(FALSE);
}
- return(FALSE);
- }
-
-
- /*
- * @brief
- * Delete licnese pool by license pool Id.
- * A pool can only be deleted if there are no software licenses bound to the pool.
- * The fixed parameter deleteLicenses=True specifies that
- * all software licenses bound to the pool are being deleted.
- * @param licensePoolId The name of the pool.
- */
- function deletePool($poolId, $force = FALSE)
- {
- $data= array();
- $data['licensePoolId'] = htmlentities($poolId);
- if($force){
- $data['deleteLicenses'] = 'TRUE';
+
+
+ /*
+ * @brief
+ * Delete licnese pool by license pool Id.
+ * A pool can only be deleted if there are no software licenses bound to the pool.
+ * The fixed parameter deleteLicenses=True specifies that
+ * all software licenses bound to the pool are being deleted.
+ * @param licensePoolId The name of the pool.
+ */
+ function deletePool($poolId, $force = FALSE)
+ {
+ $data= array();
+ $data['licensePoolId'] = htmlentities($poolId);
+ if($force){
+ $data['deleteLicenses'] = 'TRUE';
+ }
+ $res = $this->send_data("gosa_opsi_deleteLicensePool",$this->target,$data,TRUE);
+ if(isset($res['XML'][0]['ANSWER_OPSI_DELETELICENSEPOOL'])){
+ return(TRUE);
+ }
+ return(FALSE);
}
- $res = $this->send_data("gosa_opsi_deleteLicensePool",$this->target,$data,TRUE);
- if(isset($res['XML'][0]['ANSWER_OPSI_DELETELICENSEPOOL'])){
- return(TRUE);
+
+
+ /*******************
+ * LICENSES
+ *******************/
+
+
+ function listLicenses()
+ {
+ $data= array();
+ $res = $this->send_data("gosa_opsi_getAllSoftwareLicenses",$this->target,$data,TRUE);
+
+ if(isset($res['XML'][0]['ANSWER_OPSI_GETALLSOFTWARELICENSES'])){
+
+ $licenses = array();
+ if(isset($res['XML'][0]['LICENSES'][0]['HIT'])){
+ foreach($res['XML'][0]['LICENSES'][0]['HIT'] as $entry){
+
+ $item = array();
+
+ // License keys are indexed by the pool id, map it here.
+ if(isset($entry['LICENSEPOOLIDS'][0]['VALUE'])){
+ $n = strtoupper($entry['LICENSEPOOLIDS'][0]['VALUE']);
+ $entry['LICENSEKEYS'] = $entry['LICENSEKEYS'][0][$n];
+ }
+
+ // Now fake an ldap like result
+ foreach(array(
+ "BOUNDTOHOST" => "boundToHost",
+ "LICENSEKEYS" => "licenseKey",
+ "LICENSEPOOLIDS" => "licensePoolId",
+ "LICENSETYPE" => "licenseType",
+ "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 ;
+ }
+ }
+
+ $licenses[] = $item;
+ }
+ }
+ return($licenses);
+ }
+ return(FALSE);
}
- return(FALSE);
- }
-
-
- /*******************
- * LICENSES
- *******************/
-
-
- function listLicenses()
- {
- $data= array();
- $res = $this->send_data("gosa_opsi_getAllSoftwareLicenses",$this->target,$data,TRUE);
-
- if(isset($res['XML'][0]['ANSWER_OPSI_GETALLSOFTWARELICENSES'])){
-
- $licenses = array();
- if(isset($res['XML'][0]['LICENSES'][0]['HIT'])){
- foreach($res['XML'][0]['LICENSES'][0]['HIT'] as $entry){
-
- $item = array();
-
- // License keys are indexed by the pool id, map it here.
- if(isset($entry['LICENSEPOOLIDS'][0]['VALUE'])){
- $n = strtoupper($entry['LICENSEPOOLIDS'][0]['VALUE']);
- $entry['LICENSEKEYS'] = $entry['LICENSEKEYS'][0][$n];
- }
-
- // Now fake an ldap like result
- foreach(array(
- "BOUNDTOHOST" => "boundToHost",
- "LICENSEKEYS" => "licenseKey",
- "LICENSEPOOLIDS" => "licensePoolId",
- "LICENSETYPE" => "licenseType",
- "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 ;
+
+
+ /*
+ * @brief
+ * Create a license contract, create a software
+ * license and add the software license to the license pool
+ * @param licensePoolId The name of the pool the license should be assigned.
+ * @param licenseKey The license key.
+ * @param licenseTyp Typ of a licnese, either "OEM", "VOLUME" or "RETAIL"
+ * @param partner Name of the license partner (optional).
+ * @param conclusionDate Date of conclusion of license contract (optional)
+ * @param notificationDate Date of notification that license is running out soon (optional).
+ * @param notes This is the place for some notes (optional)
+ * @param softwareLicenseId Identificator of a license (optional).
+ * @param maxInstallations The number of clients use this license (optional).
+ * @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,$licenseType = "",
+ $partner = "",
+ $conclusionDate = "",
+ $notificationDate ="",
+ $notes = "",
+ $softwareLicenseId = "",
+ $maxInstallations = "",
+ $boundToHost = "",
+ $expirationDate = "")
+ {
+
+ $data= array();
+ $data['licensePoolId'] = htmlentities($poolId);
+ $data['licenseKey'] = htmlentities($licenseKey);
+ $data['licenseId'] = htmlentities($licenseId);
+
+ // Append optional attributes
+ foreach(array("partner","conclusionDate","notificationDate","notes","softwareLicenseId",
+ "licenseType","maxInstallations","boundToHost","expirationDate") as $attr){
+ if(!empty($$attr)){
+ $data[$attr] = $$attr;
}
- }
+ }
- $licenses[] = $item;
- }
- }
- return($licenses);
- }
- return(FALSE);
- }
-
-
- /*
- * @brief
- * Create a license contract, create a software
- * license and add the software license to the license pool
- * @param licensePoolId The name of the pool the license should be assigned.
- * @param licenseKey The license key.
- * @param licenseTyp Typ of a licnese, either "OEM", "VOLUME" or "RETAIL"
- * @param partner Name of the license partner (optional).
- * @param conclusionDate Date of conclusion of license contract (optional)
- * @param notificationDate Date of notification that license is running out soon (optional).
- * @param notes This is the place for some notes (optional)
- * @param softwareLicenseId Identificator of a license (optional).
- * @param maxInstallations The number of clients use this license (optional).
- * @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,$licenseType = "",
- $partner = "",
- $conclusionDate = "",
- $notificationDate ="",
- $notes = "",
- $softwareLicenseId = "",
- $maxInstallations = "",
- $boundToHost = "",
- $expirationDate = "")
- {
-
- $data= array();
- $data['licensePoolId'] = htmlentities($poolId);
- $data['licenseKey'] = htmlentities($licenseKey);
- $data['licenseId'] = htmlentities($licenseId);
-
- // Append optional attributes
- foreach(array("partner","conclusionDate","notificationDate","notes","softwareLicenseId",
- "licenseType","maxInstallations","boundToHost","expirationDate") as $attr){
- if(!empty($$attr)){
- $data[$attr] = $$attr;
- }
+ $res = $this->send_data("gosa_opsi_createLicense",$this->target,$data,TRUE);
+ if(isset($res['XML'][0]['ANSWER_OPSI_GETSOFTWARELICENSE_HASH'])){
+ return(TRUE);
+ }
+ return(FALSE);
}
- $res = $this->send_data("gosa_opsi_createLicense",$this->target,$data,TRUE);
- if(isset($res['XML'][0]['ANSWER_OPSI_GETSOFTWARELICENSE_HASH'])){
- return(TRUE);
- }
- return(FALSE);
- }
-
-
- /* @brief Returns expirationDate, boundToHost, maxInstallation, licenseTyp,
- * licensePoolIds and licenseKeys for a given softwareLicense Id.
- * @param softwareLicenseId Identificator of a license.
- */
- function getLicense($softwareLicenseId)
- {
- $data= array();
- $data['softwareLicenseId'] = htmlentities($softwareLicenseId);
- $res = $this->send_data("gosa_opsi_getSoftwareLicense_hash",$this->target,$data,TRUE);
-
- if(isset($res['XML'][0]['ANSWER_OPSI_GETSOFTWARELICENSE_HASH'])){
- return($res);
- }
- return(FALSE);
- }
+ /* @brief Returns expirationDate, boundToHost, maxInstallation, licenseTyp,
+ * licensePoolIds and licenseKeys for a given softwareLicense Id.
+ * @param softwareLicenseId Identificator of a license.
+ */
+ function getLicense($softwareLicenseId)
+ {
+ $data= array();
+ $data['softwareLicenseId'] = htmlentities($softwareLicenseId);
+ $res = $this->send_data("gosa_opsi_getSoftwareLicense_hash",$this->target,$data,TRUE);
- function getReservedLicensesForHost($hostId)
- {
- $data= array();
- if(!empty($hostId)){
- $data['hostId'] = htmlentities($hostId);
+ if(isset($res['XML'][0]['ANSWER_OPSI_GETSOFTWARELICENSE_HASH'])){
+ return($res);
+ }
+ return(FALSE);
}
- $res = $this->send_data("gosa_opsi_getReservedLicenses",$this->target,$data,TRUE);
- if(isset($res['XML'][0]['ANSWER_OPSI_GETRESERVEDLICENSES'])){
-
- $items = array();
- if(isset($res['XML'][0]['LICENSES'][0]['HIT'])){
- foreach($res['XML'][0]['LICENSES'][0]['HIT'] as $entry){
- $item = array();
- foreach(array(
- "LICENSEPOOLIDS" => "licensePoolId",
- "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 ;
+
+
+ function getReservedLicensesForHost($hostId)
+ {
+ $data= array();
+ if(!empty($hostId)){
+ $data['hostId'] = htmlentities($hostId);
+ }
+ $res = $this->send_data("gosa_opsi_getReservedLicenses",$this->target,$data,TRUE);
+ if(isset($res['XML'][0]['ANSWER_OPSI_GETRESERVEDLICENSES'])){
+
+ $items = array();
+ if(isset($res['XML'][0]['LICENSES'][0]['HIT'])){
+ foreach($res['XML'][0]['LICENSES'][0]['HIT'] as $entry){
+ $item = array();
+ foreach(array(
+ "LICENSEPOOLIDS" => "licensePoolId",
+ "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;
+ }
}
- }
- $items[] = $item;
+ return($items);
}
- }
- return($items);
- }
- return(FALSE);
- }
-
-
- /*
- * @brief Returns softwareLicenseId, notes, licenseKey, hostId and licensePoolId for optional given licensePoolId and hostId
- * @param hostid Something like client_1.intranet.mydomain.de (optional).
- * @param licensePoolId The name of the pool (optional).
- */
- function getLicenseUsage($hostId = "", $licensePoolId = "")
- {
- $data= array();
- if(!empty($hostId)){
- $data['hostId'] = htmlentities($hostId);
- }
- if(!empty($hostId)){
- $data['licensePoolId'] = htmlentities($licensePoolId);
+ return(FALSE);
}
- $res = $this->send_data("gosa_opsi_getSoftwareLicenseUsages",$this->target,$data,TRUE);
- if(isset($res['XML'][0]['ANSWER_OPSI_GETSOFTWARELICENSEUSAGES'])){
-
- $items = array();
- if(isset($res['XML'][0]['RESULT'][0]['HIT'])){
- 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 ;
+
+ /*
+ * @brief Returns softwareLicenseId, notes, licenseKey, hostId and licensePoolId for optional given licensePoolId and hostId
+ * @param hostid Something like client_1.intranet.mydomain.de (optional).
+ * @param licensePoolId The name of the pool (optional).
+ */
+ function getLicenseUsage($hostId = "", $licensePoolId = "")
+ {
+ $data= array();
+ if(!empty($hostId)){
+ $data['hostId'] = htmlentities($hostId);
+ }
+ if(!empty($hostId)){
+ $data['licensePoolId'] = htmlentities($licensePoolId);
+ }
+
+ $res = $this->send_data("gosa_opsi_getSoftwareLicenseUsages",$this->target,$data,TRUE);
+ if(isset($res['XML'][0]['ANSWER_OPSI_GETSOFTWARELICENSEUSAGES'])){
+
+ $items = array();
+ if(isset($res['XML'][0]['RESULT'][0]['HIT'])){
+ 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;
+ }
}
- }
- $items[] = $item;
+ return($items);
}
- }
- return($items);
+ return(FALSE);
}
- return(FALSE);
- }
-
-
- /* @brief Assigns a software license to a host
- * @param hostId Something like client_1.intranet.mydomain.de
- * @param licensePoolId The name of the pool.
- */
- function addLicenseToHost($licensePoolId,$hostId)
- {
- $data= array();
- $data['licensePoolId'] = htmlentities($licensePoolId);
- $data['hostId'] = htmlentities($hostId);
- $res = $this->send_data("gosa_opsi_assignSoftwareLicenseToHost",$this->target,$data,TRUE);
- if(isset($res['XML'][0]['ANSWER_OPSI_ASSIGNSOFTWARELICENSETOHOST'])){
- return(TRUE);
+
+
+ /* @brief Assigns a software license to a host
+ * @param hostId Something like client_1.intranet.mydomain.de
+ * @param licensePoolId The name of the pool.
+ */
+ function addLicenseToHost($licensePoolId,$hostId)
+ {
+ $data= array();
+ $data['licensePoolId'] = htmlentities($licensePoolId);
+ $data['hostId'] = htmlentities($hostId);
+ $res = $this->send_data("gosa_opsi_assignSoftwareLicenseToHost",$this->target,$data,TRUE);
+ if(isset($res['XML'][0]['ANSWER_OPSI_ASSIGNSOFTWARELICENSETOHOST'])){
+ return(TRUE);
+ }
+ return(FALSE);
}
- return(FALSE);
- }
-
-
- /* @brief Reserve a software license to a host
- * @param softwareLicenseId
- * @param hostId Something like client_1.intranet.mydomain.de
- */
- function reserverLicenseForHost($softwareLicenseId,$hostId)
- {
- $data= array();
- $data['softwareLicenseId'] = htmlentities($softwareLicenseId);
- $data['hostId'] = htmlentities($hostId);
- $res = $this->send_data("gosa_opsi_boundHostToLicense",$this->target,$data,TRUE);
- if(isset($res['XML'][0]['ANSWER_OPSI_BOUNDHOSTTOLICENSE'])){
- return(TRUE);
+
+
+ /* @brief Reserve a software license to a host
+ * @param softwareLicenseId
+ * @param hostId Something like client_1.intranet.mydomain.de
+ */
+ function reserverLicenseForHost($softwareLicenseId,$hostId)
+ {
+ $data= array();
+ $data['softwareLicenseId'] = htmlentities($softwareLicenseId);
+ $data['hostId'] = htmlentities($hostId);
+ $res = $this->send_data("gosa_opsi_boundHostToLicense",$this->target,$data,TRUE);
+ if(isset($res['XML'][0]['ANSWER_OPSI_BOUNDHOSTTOLICENSE'])){
+ return(TRUE);
+ }
+ return(FALSE);
}
- return(FALSE);
- }
-
-
- /*
- * @brief Remove software licnese reservation for a host.
- * @param softwareLicenseId
- * @param hostid Something like client_1.intranet.mydomain.de
- */
- function removeLicenseReservationFromHost($softwareLicenseId,$hostId)
- {
- $data= array();
- $data['softwareLicenseId'] = htmlentities($softwareLicenseId);
- $data['hostId'] = htmlentities($hostId);
- $res = $this->send_data("gosa_opsi_unboundHostFromLicense",$this->target,$data,TRUE);
- if(isset($res['XML'][0]['ANSWER_OPSI_UNBOUNDHOSTFROMLICENSE'])){
- return(TRUE);
+
+
+ /*
+ * @brief Remove software licnese reservation for a host.
+ * @param softwareLicenseId
+ * @param hostid Something like client_1.intranet.mydomain.de
+ */
+ function removeLicenseReservationFromHost($softwareLicenseId,$hostId)
+ {
+ $data= array();
+ $data['softwareLicenseId'] = htmlentities($softwareLicenseId);
+ $data['hostId'] = htmlentities($hostId);
+ $res = $this->send_data("gosa_opsi_unboundHostFromLicense",$this->target,$data,TRUE);
+ if(isset($res['XML'][0]['ANSWER_OPSI_UNBOUNDHOSTFROMLICENSE'])){
+ return(TRUE);
+ }
+ return(FALSE);
}
- return(FALSE);
- }
-
-
- /*
- * @brief Unassign a software license from a host.
- * @param hostid Something like client_1.intranet.mydomain.de
- * @param licensePoolId The name of the pool.
- */
- function removeLicenseFromHost($licensePoolId,$hostId)
- {
- $data= array();
- $data['licensePoolId'] = htmlentities($licensePoolId);
- $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);
+
+
+ /*
+ * @brief Unassign a software license from a host.
+ * @param hostid Something like client_1.intranet.mydomain.de
+ * @param licensePoolId The name of the pool.
+ */
+ function removeLicenseFromHost($licensePoolId,$hostId)
+ {
+ $data= array();
+ $data['licensePoolId'] = htmlentities($licensePoolId);
+ $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);
+ }
+ return(FALSE);
}
- return(FALSE);
- }
-
-
- /*
- * @brief Removes a single license from a license pool
- * Attention, the software license has to exists
- * otherwise it will lead to an Opsi internal server error.
- * @param softwareLicenseId
- * @param licensePoolId
- */
- function removeLicenseFromPool($licensePoolId,$softwareLicenseId)
- {
- $data= array();
- $data['licensePoolId'] = htmlentities($licensePoolId);
- $data['softwareLicenseId'] = htmlentities($softwareLicenseId);
- $res = $this->send_data("gosa_opsi_removeLicense",$this->target,$data,TRUE);
- if(isset($res['XML'][0]['ANSWER_OPSI_REMOVELICENSE'])){
- return(TRUE);
+
+
+ /*
+ * @brief Removes a single license from a license pool
+ * Attention, the software license has to exists
+ * otherwise it will lead to an Opsi internal server error.
+ * @param softwareLicenseId
+ * @param licensePoolId
+ */
+ function removeLicenseFromPool($licensePoolId,$softwareLicenseId)
+ {
+ $data= array();
+ $data['licensePoolId'] = htmlentities($licensePoolId);
+ $data['softwareLicenseId'] = htmlentities($softwareLicenseId);
+ $res = $this->send_data("gosa_opsi_removeLicense",$this->target,$data,TRUE);
+ if(isset($res['XML'][0]['ANSWER_OPSI_REMOVELICENSE'])){
+ return(TRUE);
+ }
+ return(FALSE);
}
- return(FALSE);
- }
-
-
- /*
- * @brief Unassign all software licenses from a host
- * @param hostid Something like client_1.intranet.mydomain.de
- */
- function removeAllLicensesFromHost($hostId)
- {
- $data= array();
- $data['hostId'] = htmlentities($hostid);
- $res = $this->send_data("gosa_opsi_unassignAllSoftwareLicensesFromHost",$this->target,$data,TRUE);
- if(isset($res['XML'][0]['ANSWER_OPSI_UNASSIGNALLSOFTWARELICENSESFROMHOST'])){
- return(TRUE);
+
+
+ /*
+ * @brief Unassign all software licenses from a host
+ * @param hostid Something like client_1.intranet.mydomain.de
+ */
+ function removeAllLicensesFromHost($hostId)
+ {
+ $data= array();
+ $data['hostId'] = htmlentities($hostid);
+ $res = $this->send_data("gosa_opsi_unassignAllSoftwareLicensesFromHost",$this->target,$data,TRUE);
+ if(isset($res['XML'][0]['ANSWER_OPSI_UNASSIGNALLSOFTWARELICENSESFROMHOST'])){
+ return(TRUE);
+ }
+ return(FALSE);
}
- return(FALSE);
- }
-
-
- /* @brief
- * Returns the assigned licensePoolId and licenses,
- * how often the product is installed and at which host
- * and the number of max and remaining installations for a given OPSI product.
- * @param productId Identificator of an OPSI product.
- */
- function getLicensesForProduct($productId)
- {
- $data= array();
- $data['productId'] = htmlentities($productId);
- $res = $this->send_data("gosa_opsi_getSoftwareLicenseUsagesForProductId",$this->target,$data,TRUE);
- if(isset($res['XML'][0]['ANSWER_OPSI_GETSOFTWARELICENSEUSAGESFORPRODUCTID'])){
- if(isset($res['XML'][0]['RESULT'][0]['HIT'])){
- return($res['XML'][0]['RESULT'][0]['HIT']);
- }
- return(array());
+
+
+ /* @brief
+ * Returns the assigned licensePoolId and licenses,
+ * how often the product is installed and at which host
+ * and the number of max and remaining installations for a given OPSI product.
+ * @param productId Identificator of an OPSI product.
+ */
+ function getLicensesForProduct($productId)
+ {
+ $data= array();
+ $data['productId'] = htmlentities($productId);
+ $res = $this->send_data("gosa_opsi_getSoftwareLicenseUsagesForProductId",$this->target,$data,TRUE);
+ if(isset($res['XML'][0]['ANSWER_OPSI_GETSOFTWARELICENSEUSAGESFORPRODUCTID'])){
+ if(isset($res['XML'][0]['RESULT'][0]['HIT'])){
+ return($res['XML'][0]['RESULT'][0]['HIT']);
+ }
+ return(array());
+ }
+ return(FALSE);
}
- return(FALSE);
- }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenses.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenses.inc
index de8c443e827dcd9ae29c2fe0c5ce7f438a96068a..2fc34c86784bdab6ee90e5b8e95db5c66258a688 100644 (file)
class opsiLicenses extends management
{
- var $plHeadline = "Software licenses";
- var $plDescription = "Manage software licenses for Windows system deployments";
- var $plIcon = "plugins/opsi/images/plugin.png";
+ var $plHeadline = "Software licenses";
+ var $plDescription = "Manage software licenses for Windows system deployments";
+ var $plIcon = "plugins/opsi/images/plugin.png";
- // Tab definition
- protected $tabClass = "licenseTabs";
- protected $tabType = "OPSILICENSETABS";
- protected $aclCategory = "opsi";
- protected $aclPlugin = "licenseGeneric";
- protected $objectName = "license";
+ // Tab definition
+ protected $tabClass = "licenseTabs";
+ protected $tabType = "OPSILICENSETABS";
+ protected $aclCategory = "opsi";
+ protected $aclPlugin = "licenseGeneric";
+ protected $objectName = "license";
- function __construct($config,$ui)
- {
- $this->config = $config;
- $this->ui = $ui;
+ function __construct($config,$ui)
+ {
+ $this->config = $config;
+ $this->ui = $ui;
- $this->storagePoints = array("");
+ $this->storagePoints = array("");
- // Build filter
- if (session::global_is_set(get_class($this)."_filter")){
- $filter= session::global_get(get_class($this)."_filter");
- } else {
- $filter = new filter(get_template_path("opsiLicense-filter.xml", true));
- $filter->setObjectStorage($this->storagePoints);
- }
- $this->setFilter($filter);
+ // Build filter
+ if (session::global_is_set(get_class($this)."_filter")){
+ $filter= session::global_get(get_class($this)."_filter");
+ } else {
+ $filter = new filter(get_template_path("opsiLicense-filter.xml", true));
+ $filter->setObjectStorage($this->storagePoints);
+ }
+ $this->setFilter($filter);
- // Build headpage
- $headpage = new listing(get_template_path("opsiLicense-list.xml", true));
- $headpage->setFilter($filter);
+ // Build headpage
+ $headpage = new listing(get_template_path("opsiLicense-list.xml", true));
+ $headpage->setFilter($filter);
- // Add copy&paste and snapshot handler.
- if ($this->config->boolValueIsTrue("core", "copyPaste")){
- $this->cpHandler = new CopyPasteHandler($this->config);
- }
- if($this->config->get_cfg_value("core","enableSnapshots") == "true"){
- $this->snapHandler = new SnapshotHandler($this->config);
+ // Add copy&paste and snapshot handler.
+ if ($this->config->boolValueIsTrue("core", "copyPaste")){
+ $this->cpHandler = new CopyPasteHandler($this->config);
+ }
+ if($this->config->get_cfg_value("core","enableSnapshots") == "true"){
+ $this->snapHandler = new SnapshotHandler($this->config);
+ }
+ parent::__construct($config, $ui, "licenses", $headpage);
}
- parent::__construct($config, $ui, "licenses", $headpage);
- }
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>