new type API

This commit is contained in:
Roland Gruber 2017-05-02 21:20:16 +02:00
parent 51bb97ba38
commit 056cbce9c3
2 changed files with 15 additions and 5 deletions

View File

@ -232,7 +232,7 @@ class range extends baseModule {
* @return string status ("enabled", "disabled", "hidden") * @return string status ("enabled", "disabled", "hidden")
*/ */
public function getButtonStatus() { public function getButtonStatus() {
if ($this->getAccountContainer()->dn_orig!=$_SESSION['config']->get_suffix('dhcp')) { if (!$this->isRootNode()) {
return "enabled"; return "enabled";
} }
else { else {
@ -248,7 +248,7 @@ class range extends baseModule {
function load_attributes($attr) { function load_attributes($attr) {
parent::load_attributes($attr); parent::load_attributes($attr);
// Load DHCP Options: // Load DHCP Options:
if ($this->getAccountContainer()->dn_orig!=$_SESSION['config']->get_suffix('dhcp')) { if (!$this->isRootNode()) {
$this->orig = $attr; $this->orig = $attr;
$this->attributes = $attr; $this->attributes = $attr;
// Load DHCP Options: // Load DHCP Options:
@ -316,7 +316,7 @@ class range extends baseModule {
*/ */
public function process_attributes() { public function process_attributes() {
$errors = array(); $errors = array();
if ($this->getAccountContainer()->dn_orig == $_SESSION['config']->get_suffix('dhcp')) { if ($this->isRootNode()) {
return $errors; return $errors;
} }
$subnet = $this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0]; $subnet = $this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0];
@ -756,7 +756,7 @@ class range extends baseModule {
public function save_attributes() { public function save_attributes() {
$return = array(); $return = array();
// Get easy attributes // 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 = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);
} }
// Return attributes // Return attributes
@ -824,6 +824,16 @@ class range extends baseModule {
$this->poolsNew = $this->poolsOrig; $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;
}
} }
?> ?>

View File

@ -286,7 +286,7 @@ class lamDHCPList extends lamList {
function listDoPost() { function listDoPost() {
$fragment = parent::listDoPost(); $fragment = parent::listDoPost();
if (isset($_POST['dhcpDefaults'])) { 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(); die();
} }
else { else {