From: hickert Date: Thu, 24 Sep 2009 09:18:11 +0000 (+0000) Subject: Enabled license listing X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=5208f365e85e9326b9ca85b1eedf694423d6fb88;p=gosa.git Enabled license listing git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14337 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_licenseGeneric.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_licenseGeneric.inc new file mode 100644 index 000000000..726de0787 --- /dev/null +++ b/gosa-plugins/opsi/admin/opsiLicenses/class_licenseGeneric.inc @@ -0,0 +1,166 @@ +config = $config; + $this->dn = $this->orig_dn = $dn; + $this->si = new opsiLicenceHandler($this->config); + + // Extract pool name out of the fake dn. + $this->init(); + } + + + function init() + { + // Load local Boot Products + $res = $this->si->get_local_products(); + if($this->si->is_error()){ + $this->init_successfull = FALSE; + return(FALSE); + } + } + + + function 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(); + + // 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("initially_was_account", $this->initially_was_account); + return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__)))); + } + + + /* Save HTML inputs + */ + function save_object() + { + if(isset($_POST['opsiLicensesPosted'])){ + plugin::save_object(); + } + } + + + /* 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() + { + echo "missing remove."; +# $this->si->deletePool($this->orig_cn); +# if($this->si->is_error()){ +# msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG); +# }else{ +# +# // Trigger remove signal +# $this->handle_post_events("remove"); +# } +# +# new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$this->si->get_error()); + } + + + /* Saves object modifications + */ + function save() + { + + echo "missing save"; +# plugin::save(); +# +# // Send modify/add events +# $mode = "modify"; +# if($this->orig_dn == "new"){ +# $mode = "add"; +# } +# +# $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); +# } +# +# // 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; + } + + static function plInfo() + { + return (array( + "plShortName" => _("Generic"), + "plDescription" => _("License generic"), + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 1, + "plSection" => array("administration"), + "plCategory" => array("opsi"), + "plProvidedAcls"=> array( + "cn" => _("Name"), + "description" => _("Description")) + )); + } +} + + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_licensePoolGeneric.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_licensePoolGeneric.inc index e7ff0ae7b..5cdd41f56 100644 --- a/gosa-plugins/opsi/admin/opsiLicenses/class_licensePoolGeneric.inc +++ b/gosa-plugins/opsi/admin/opsiLicenses/class_licensePoolGeneric.inc @@ -21,7 +21,7 @@ */ -class poolGeneric extends plugin +class licensePoolGeneric extends plugin { var $cn = ""; @@ -97,6 +97,12 @@ class poolGeneric extends plugin $this->productIds[] = $this->data['productId'][$i]; } } + + // Load Licences + $this->licenses = array(); + if(isset($this->data['licenses'])){ + $this->licenses = $this->data['licenses']; + } $this->init_successfull = TRUE; return; } @@ -111,7 +117,7 @@ class poolGeneric extends plugin 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__)))); + return($smarty->fetch(get_template_path('licensePoolGeneric.tpl',TRUE,dirname(__FILE__)))); } $smarty = get_smarty(); @@ -124,14 +130,13 @@ class poolGeneric extends plugin 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('licenseGeneric.tpl',TRUE,dirname(__FILE__)))); + return($smarty->fetch(get_template_path('licensePoolGeneric.tpl',TRUE,dirname(__FILE__)))); } @@ -139,9 +144,29 @@ class poolGeneric extends plugin { $list = new divSelectBox("test"); $list->setHeight(100); - + for($i=0 ; $i<$this->licenses['count'] ; $i++){ + $license = $this->licenses[$i]; + + $keys = ""; + foreach($license['LICENSEKEYS'] as $key_by_pool){ + foreach($key_by_pool as $key){ + $keys .= $key[0]['VALUE'].", "; + } + } + + $link = ""; + $link.= ""; + $f1 = array("string" => $license['SOFTWARELICENSEID'][0]['VALUE'], "attach" => ""); + $f2 = array("string" => $license['LICENSETYPE'][0]['VALUE'], "attach" => ""); + $f3 = array("string" => $license['EXPIRATIONDATE'][0]['VALUE'], "attach" => ""); + $f4 = array("string" => $license['MAXINSTALLATIONS'][0]['VALUE'], "attach" => ""); + $f5 = array("string" => rtrim($keys,", ")); + $f6 = array("string" => $link, "attach" => "style='border-right: 0px; width:32px;'"); + + $list->addEntry(array($f1,$f2,$f3,$f4,$f5,$f6)); + } return($list->DrawList()); } diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc index 032ade87c..30e983d38 100644 --- a/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc +++ b/gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenseHandler.inc @@ -84,18 +84,24 @@ class opsiLicenceHandler extends opsi { { $data= array(); $data['licensePoolId'] = htmlentities($licensePoolId); - $res = $this->send_data("gosa_opsi_getLicensePool_hash",$this->target,$data,TRUE); - if(isset($res['XML'][0]['ANSWER_OPSI_GETLICENSEPOOL_HASH'])){ + $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", "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){ - $item[$target][] = $data['VALUE']; + 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 ; } diff --git a/gosa-plugins/opsi/admin/opsiLicenses/licensePoolGeneric.tpl b/gosa-plugins/opsi/admin/opsiLicenses/licensePoolGeneric.tpl new file mode 100644 index 000000000..4e3fe3ec4 --- /dev/null +++ b/gosa-plugins/opsi/admin/opsiLicenses/licensePoolGeneric.tpl @@ -0,0 +1,98 @@ +{if !$init_successfull} +
+{msgPool type=siError}
+{t}Check if the GOsa support daemon (gosa-si) is running.{/t}  + +
+
+{else} + + + + + + + + + + + + + + +
+ +

{t}Generic{/t}

+ + + + + + + + + +
{t}Name{/t} + {if $initially_was_account} + + {else} +{render acl=$cnACL} + +{/render} + {/if} +
{t}Description{/t} +{render acl=$descriptionACL} + +{/render} +
+ +
+ +

{t}Licenses{/t}

+ + + + +
+ {$licenses} +
+ +
+

 

+
+ +

{t}Applications{/t}

+ + + + +
+
+ + + +
+ +
+ +

{t}Windows software IDs{/t}

+ + + + +
+ + + + +
+ +
+ +{/if}