From 056cbce9c3de2300f0f000d78012eec96a9ad6d1 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 2 May 2017 21:20:16 +0200 Subject: [PATCH] new type API --- lam/lib/modules/range.inc | 18 ++++++++++++++---- lam/lib/types/dhcp.inc | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/lam/lib/modules/range.inc b/lam/lib/modules/range.inc index f632bd40..0fa30c91 100644 --- a/lam/lib/modules/range.inc +++ b/lam/lib/modules/range.inc @@ -232,7 +232,7 @@ class range extends baseModule { * @return string status ("enabled", "disabled", "hidden") */ public function getButtonStatus() { - if ($this->getAccountContainer()->dn_orig!=$_SESSION['config']->get_suffix('dhcp')) { + if (!$this->isRootNode()) { return "enabled"; } else { @@ -248,7 +248,7 @@ class range extends baseModule { function load_attributes($attr) { parent::load_attributes($attr); // Load DHCP Options: - if ($this->getAccountContainer()->dn_orig!=$_SESSION['config']->get_suffix('dhcp')) { + if (!$this->isRootNode()) { $this->orig = $attr; $this->attributes = $attr; // Load DHCP Options: @@ -316,7 +316,7 @@ class range extends baseModule { */ public function process_attributes() { $errors = array(); - if ($this->getAccountContainer()->dn_orig == $_SESSION['config']->get_suffix('dhcp')) { + if ($this->isRootNode()) { return $errors; } $subnet = $this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0]; @@ -756,7 +756,7 @@ class range extends baseModule { public function save_attributes() { $return = array(); // Get easy attributes - if ($this->getAccountContainer()->dn_orig!=$_SESSION['config']->get_suffix('dhcp')) { + if (!$this->isRootNode()) { $return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig); } // Return attributes @@ -824,6 +824,16 @@ class range extends baseModule { $this->poolsNew = $this->poolsOrig; } + /** + * Returns if the current DN is the root entry. + * + * @return bool is root + */ + private function isRootNode() { + $rootSuffix = $this->getAccountContainer()->get_type()->getSuffix(); + return $this->getAccountContainer()->dn_orig == $rootSuffix; + } + } ?> diff --git a/lam/lib/types/dhcp.inc b/lam/lib/types/dhcp.inc index bce4b03d..e0311712 100644 --- a/lam/lib/types/dhcp.inc +++ b/lam/lib/types/dhcp.inc @@ -286,7 +286,7 @@ class lamDHCPList extends lamList { function listDoPost() { $fragment = parent::listDoPost(); if (isset($_POST['dhcpDefaults'])) { - metaRefresh("../account/edit.php?type=dhcp&DN='" . $this->type->getSuffix() . "'"); + metaRefresh("../account/edit.php?type=" . $this->type->getId() . "&DN='" . $this->type->getSuffix() . "'"); die(); } else {