new type API

This commit is contained in:
Roland Gruber 2017-04-22 15:59:07 +02:00
parent a844d4d06d
commit 01f2d618f2
1 changed files with 18 additions and 8 deletions

View File

@ -136,11 +136,11 @@ class fixed_ip 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 "hidden";
} }
else { else {
return "hidden"; return "enabled";
} }
} }
@ -227,7 +227,7 @@ class fixed_ip extends baseModule {
* @param array $attr list of attributes * @param array $attr list of attributes
*/ */
function load_attributes($attr) { function load_attributes($attr) {
if ($this->getAccountContainer()->dn_orig!=$_SESSION['config']->get_suffix('dhcp')) { if (!$this->isRootNode()) {
$attributes = array('cn', 'dhcphwaddress', 'dhcpstatements', 'dhcpcomments'); $attributes = array('cn', 'dhcphwaddress', 'dhcpstatements', 'dhcpcomments');
$entries = searchLDAP($this->getAccountContainer()->dn_orig, '(objectClass=dhcpHost)', $attributes); $entries = searchLDAP($this->getAccountContainer()->dn_orig, '(objectClass=dhcpHost)', $attributes);
for ($i = 0; $i < sizeof($entries); $i++) { for ($i = 0; $i < sizeof($entries); $i++) {
@ -287,7 +287,7 @@ class fixed_ip 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()) {
$this->processed = true; $this->processed = true;
$this->reset_overlapd_ip(); $this->reset_overlapd_ip();
@ -644,8 +644,8 @@ class fixed_ip extends baseModule {
* @return array array which contains status messages. Each entry is an array containing the status message parameters. * @return array array which contains status messages. Each entry is an array containing the status message parameters.
*/ */
public function postModifyActions($newAccount, $attributes) { public function postModifyActions($newAccount, $attributes) {
if ($this->getAccountContainer()->dn_orig!=$_SESSION['config']->get_suffix('dhcp')) { if (!$this->isRootNode()) {
$ldapSuffix = ',cn=' . $this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0] . ',' . $_SESSION['config']->get_suffix('dhcp'); $ldapSuffix = ',cn=' . $this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0] . ',' . $this->getAccountContainer()->get_type()->getSuffix();
$add = array(); $add = array();
$mod = array(); // DN => array(attr => values) $mod = array(); // DN => array(attr => values)
$delete = array(); $delete = array();
@ -859,6 +859,16 @@ class fixed_ip extends baseModule {
} }
} }
/**
* 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;
}
} }
?> ?>