From 573089fd7c5b3fdbfcbbc2533c712339343bb29b Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 23 Sep 2009 09:22:24 +0000 Subject: [PATCH] Added host and product dialogs git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14330 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../opsiLicenses/class_licenseByProduct.inc | 181 ++++++++++++++++++ .../opsiLicenses/class_licenseUsageByHost.inc | 181 ++++++++++++++++++ .../admin/opsiLicenses/licenseByProduct.tpl | 16 ++ .../admin/opsiLicenses/licenseUsageByHost.tpl | 16 ++ 4 files changed, 394 insertions(+) create mode 100644 gosa-plugins/opsi/admin/opsiLicenses/class_licenseByProduct.inc create mode 100644 gosa-plugins/opsi/admin/opsiLicenses/class_licenseUsageByHost.inc create mode 100644 gosa-plugins/opsi/admin/opsiLicenses/licenseByProduct.tpl create mode 100644 gosa-plugins/opsi/admin/opsiLicenses/licenseUsageByHost.tpl diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_licenseByProduct.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_licenseByProduct.inc new file mode 100644 index 000000000..f54b036a4 --- /dev/null +++ b/gosa-plugins/opsi/admin/opsiLicenses/class_licenseByProduct.inc @@ -0,0 +1,181 @@ +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(); + } + + + 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; + return; + } + + $this->licenseUses = $res; + $this->init_successfull = TRUE; + } + } + + + 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__)))); + } + + // Create usage list + $list = new divSelectBox("licenseUsage"); + foreach($this->licenseUses as $license){ + + $f1 = array("string" => $license['hostId'][0]); + $f2 = array("string" => $license['licenseKey'][0]); + $f3 = array("string" => $license['licensePoolId'][0]); + $f4 = array("string" => $license['softwareLicenseId'][0], + "attach" => "style='border-right:0px;'"); + $list->addEntry(array($f1,$f2,$f3,$f4)); + } + + $smarty = get_smarty(); + + // 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("licenseUses", $list->DrawList()); + $smarty->assign("init_successfull", $this->init_successfull); + $smarty->assign("initially_was_account", $this->initially_was_account); + return($smarty->fetch(get_template_path('licenseUsage.tpl',TRUE,dirname(__FILE__)))); + } + + + /* 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); + } + + + /* Saves object modifications + */ + function 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; + } + + + function remove_from_parent(){ return; } + + + static function plInfo() + { + return (array( + "plShortName" => _("Usage"), + "plDescription" => _("License usage"), + "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_licenseUsageByHost.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_licenseUsageByHost.inc new file mode 100644 index 000000000..10d9a2074 --- /dev/null +++ b/gosa-plugins/opsi/admin/opsiLicenses/class_licenseUsageByHost.inc @@ -0,0 +1,181 @@ +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(); + } + + + 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; + return; + } + + $this->licenseUses = $res; + $this->init_successfull = TRUE; + } + } + + + 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__)))); + } + + // Create usage list + $list = new divSelectBox("licenseUsage"); + foreach($this->licenseUses as $license){ + + $f1 = array("string" => $license['hostId'][0]); + $f2 = array("string" => $license['licenseKey'][0]); + $f3 = array("string" => $license['licensePoolId'][0]); + $f4 = array("string" => $license['softwareLicenseId'][0], + "attach" => "style='border-right:0px;'"); + $list->addEntry(array($f1,$f2,$f3,$f4)); + } + + $smarty = get_smarty(); + + // 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("licenseUses", $list->DrawList()); + $smarty->assign("init_successfull", $this->init_successfull); + $smarty->assign("initially_was_account", $this->initially_was_account); + return($smarty->fetch(get_template_path('licenseUsage.tpl',TRUE,dirname(__FILE__)))); + } + + + /* 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); + } + + + /* Saves object modifications + */ + function 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; + } + + + function remove_from_parent(){ return; } + + + static function plInfo() + { + return (array( + "plShortName" => _("Usage"), + "plDescription" => _("License usage"), + "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/licenseByProduct.tpl b/gosa-plugins/opsi/admin/opsiLicenses/licenseByProduct.tpl new file mode 100644 index 000000000..443d2f4f4 --- /dev/null +++ b/gosa-plugins/opsi/admin/opsiLicenses/licenseByProduct.tpl @@ -0,0 +1,16 @@ +{if !$init_successfull} +
+{msgPool type=siError}
+{t}Check if the GOsa support daemon (gosa-si) is running.{/t}  + +
+
+{else} + + +

{t}License usage{/t}

+ +{$licenseUses} + + +{/if} diff --git a/gosa-plugins/opsi/admin/opsiLicenses/licenseUsageByHost.tpl b/gosa-plugins/opsi/admin/opsiLicenses/licenseUsageByHost.tpl new file mode 100644 index 000000000..443d2f4f4 --- /dev/null +++ b/gosa-plugins/opsi/admin/opsiLicenses/licenseUsageByHost.tpl @@ -0,0 +1,16 @@ +{if !$init_successfull} +
+{msgPool type=siError}
+{t}Check if the GOsa support daemon (gosa-si) is running.{/t}  + +
+
+{else} + + +

{t}License usage{/t}

+ +{$licenseUses} + + +{/if} -- 2.30.2