fixed ghost range when no ranges exist

This commit is contained in:
Roland Gruber 2009-11-24 19:13:06 +00:00
parent 39c33fd9f1
commit 95d93478ed
1 changed files with 16 additions and 14 deletions

View File

@ -41,7 +41,7 @@ $Id$
class fixed_ip extends baseModule { class fixed_ip extends baseModule {
// fixed ips // fixed ips
public $fixed_ips; public $fixed_ip;
// already processed? // already processed?
public $processed = false; public $processed = false;
@ -196,6 +196,7 @@ class fixed_ip extends baseModule {
'(objectClass=dhcpHost)', array(), 0, 0, 0, LDAP_DEREF_NEVER); '(objectClass=dhcpHost)', array(), 0, 0, 0, LDAP_DEREF_NEVER);
if ($sr) { if ($sr) {
$entries = ldap_get_entries($_SESSION['ldap']->server(), $sr); $entries = ldap_get_entries($_SESSION['ldap']->server(), $sr);
if ($entries) {
for ($i=0; $i < $entries["count"]; $i++) { for ($i=0; $i < $entries["count"]; $i++) {
$this->fixed_ip[$i]['cn'] = $entries[$i]['cn'][0]; $this->fixed_ip[$i]['cn'] = $entries[$i]['cn'][0];
$this->fixed_ip[$i]['mac'] = array_pop(explode(" ", $entries[$i]['dhcphwaddress'][0])); $this->fixed_ip[$i]['mac'] = array_pop(explode(" ", $entries[$i]['dhcphwaddress'][0]));
@ -208,6 +209,7 @@ class fixed_ip extends baseModule {
} }
} }
} }
}
/** /**
@ -324,15 +326,15 @@ class fixed_ip extends baseModule {
$return[] = array( $return[] = array(
array('kind' => 'table', 'value' => array(array( array('kind' => 'table', 'value' => array(array(
array('kind' => 'text', 'text' => _('PC name') . "*"), array('kind' => 'text', 'text' => _('PC name') . "*"),
array('kind' => 'help', 'value' => 'pc', 'scope' => 'user'), array('kind' => 'help', 'value' => 'pc'),
))), ))),
array('kind' => 'table', 'value' => array(array( array('kind' => 'table', 'value' => array(array(
array('kind' => 'text', 'text' => _('MAC address') . "*"), array('kind' => 'text', 'text' => _('MAC address') . "*"),
array('kind' => 'help', 'value' => 'mac', 'scope' => 'user'), array('kind' => 'help', 'value' => 'mac'),
))), ))),
array('kind' => 'table', 'value' => array(array( array('kind' => 'table', 'value' => array(array(
array('kind' => 'text', 'text' => _('IP address') . "*"), array('kind' => 'text', 'text' => _('IP address') . "*"),
array('kind' => 'help', 'value' => 'ip', 'scope' => 'user'), array('kind' => 'help', 'value' => 'ip'),
))), ))),
array('kind' => 'text', 'text' => ''), array('kind' => 'text', 'text' => ''),
); );
@ -341,7 +343,7 @@ class fixed_ip extends baseModule {
// If $ranges is not a array, then create one: // If $ranges is not a array, then create one:
if (!is_array($this->fixed_ip)) { if (!is_array($this->fixed_ip)) {
$this->fixed_ip[] = array(); $this->fixed_ip = array();
} }
$pcs = array(); $pcs = array();
foreach($this->fixed_ip AS $id=>$arr) { foreach($this->fixed_ip AS $id=>$arr) {