reordered input fields
This commit is contained in:
parent
dbb5f987a7
commit
a77fd26347
|
@ -84,12 +84,6 @@ class fixed_ip extends baseModule {
|
||||||
) , 'ip' => array(
|
) , 'ip' => array(
|
||||||
"Headline" => _("IP address"),
|
"Headline" => _("IP address"),
|
||||||
"Text" => _("The IP address of the PC.")
|
"Text" => _("The IP address of the PC.")
|
||||||
) , 'drop_ip' => array(
|
|
||||||
"Headline" => _("Delete IP"),
|
|
||||||
"Text" => _("Deletes a fixed IP address.")
|
|
||||||
) , 'add_ip' => array(
|
|
||||||
"Headline" => _("Add IP"),
|
|
||||||
"Text" => _("Adds input fields for a new fixed IP address.")
|
|
||||||
) );
|
) );
|
||||||
// available PDF fields
|
// available PDF fields
|
||||||
$return['PDF_fields'] = array('IPlist');
|
$return['PDF_fields'] = array('IPlist');
|
||||||
|
@ -98,7 +92,6 @@ class fixed_ip extends baseModule {
|
||||||
|
|
||||||
public function load_Messages() {
|
public function load_Messages() {
|
||||||
$this->messages['errors'][0] = array('ERROR', _('One or more errors occured. The invalid fields are marked.'), '');
|
$this->messages['errors'][0] = array('ERROR', _('One or more errors occured. The invalid fields are marked.'), '');
|
||||||
$this->messages['add_ip'][0] = array('ERROR', _('Adding of a fixed IP failed because of errors.'), '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -202,8 +195,7 @@ class fixed_ip extends baseModule {
|
||||||
$sr = @ldap_search($_SESSION['ldap']->server(),'cn='.$_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0].','.$_SESSION['config']->get_suffix('dhcp'),'(objectClass=dhcpHost)');
|
$sr = @ldap_search($_SESSION['ldap']->server(),'cn='.$_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0].','.$_SESSION['config']->get_suffix('dhcp'),'(objectClass=dhcpHost)');
|
||||||
if ($sr) {
|
if ($sr) {
|
||||||
$entries = ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
$entries = ldap_get_entries($_SESSION['ldap']->server(), $sr);
|
||||||
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]));
|
||||||
$this->fixed_ip[$i]['ip'] = array_pop(explode(" ", $entries[$i]['dhcpstatements'][0]));
|
$this->fixed_ip[$i]['ip'] = array_pop(explode(" ", $entries[$i]['dhcpstatements'][0]));
|
||||||
|
@ -243,8 +235,6 @@ class fixed_ip extends baseModule {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If all three inputs are empty, then do nothing:
|
|
||||||
if (!empty($_POST['pc_'.$id]) || !empty($_POST['mac_'.$id]) || !empty($_POST['ip_'.$id]) ) {
|
|
||||||
// MAC address
|
// MAC address
|
||||||
$_POST['mac_'.$id] = strtolower(trim($_POST['mac_'.$id]));
|
$_POST['mac_'.$id] = strtolower(trim($_POST['mac_'.$id]));
|
||||||
|
|
||||||
|
@ -305,7 +295,6 @@ class fixed_ip extends baseModule {
|
||||||
}
|
}
|
||||||
$this->fixed_ip[$id]['cn'] = $_POST['pc_'.$id];
|
$this->fixed_ip[$id]['cn'] = $_POST['pc_'.$id];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ($error) {
|
if ($error) {
|
||||||
$errors[] = $this->messages['errors'][0];
|
$errors[] = $this->messages['errors'][0];
|
||||||
}
|
}
|
||||||
|
@ -313,14 +302,8 @@ class fixed_ip extends baseModule {
|
||||||
|
|
||||||
// Add new IP
|
// Add new IP
|
||||||
if(isset($_POST['add_ip'])) {
|
if(isset($_POST['add_ip'])) {
|
||||||
// Check, if there where no errors:
|
|
||||||
if ($error) {
|
|
||||||
$errors[] = $this->messages['add_ip'][0];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Add IP:
|
// Add IP:
|
||||||
$this->fixed_ip[] = array('cn'=>'','mac'=>'','ip'=>'');
|
$this->fixed_ip[] = array('cn' => $_POST['pc_add'], 'mac' => $_POST['mac_add'], 'ip' => $_POST['ip_add']);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,10 +319,26 @@ class fixed_ip extends baseModule {
|
||||||
echo "<b>" . _("Please fill out the DHCP settings first.") . "</b>";
|
echo "<b>" . _("Please fill out the DHCP settings first.") . "</b>";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Reset oberldapd ips
|
// caption
|
||||||
|
$return[] = array(
|
||||||
|
array('kind' => 'table', 'value' => array(array(
|
||||||
|
array('kind' => 'text', 'text' => _('PC name') . "*"),
|
||||||
|
array('kind' => 'help', 'value' => 'pc', 'scope' => 'user'),
|
||||||
|
))),
|
||||||
|
array('kind' => 'table', 'value' => array(array(
|
||||||
|
array('kind' => 'text', 'text' => _('MAC address') . "*"),
|
||||||
|
array('kind' => 'help', 'value' => 'mac', 'scope' => 'user'),
|
||||||
|
))),
|
||||||
|
array('kind' => 'table', 'value' => array(array(
|
||||||
|
array('kind' => 'text', 'text' => _('IP address') . "*"),
|
||||||
|
array('kind' => 'help', 'value' => 'ip', 'scope' => 'user'),
|
||||||
|
))),
|
||||||
|
array('kind' => 'text', 'text' => ''),
|
||||||
|
);
|
||||||
|
// Reset oberlaped ips
|
||||||
$this->reset_overlapd_ip();
|
$this->reset_overlapd_ip();
|
||||||
|
|
||||||
// If $ranges is not a array, then create an:
|
// 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();
|
||||||
}
|
}
|
||||||
|
@ -348,74 +347,78 @@ class fixed_ip extends baseModule {
|
||||||
// pc name
|
// pc name
|
||||||
$result = @ldap_search($_SESSION['ldap']->server(),"cn=".$_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0].",".$_SESSION['config']->get_Suffix('dhcp'),'(cn='.$_POST['pc_'.$id].')');
|
$result = @ldap_search($_SESSION['ldap']->server(),"cn=".$_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0].",".$_SESSION['config']->get_Suffix('dhcp'),'(cn='.$_POST['pc_'.$id].')');
|
||||||
$num = (@ldap_get_entries($_SESSION['ldap']->server(), $result)=="")?0:ldap_get_entries($_SESSION['ldap']->server(), $result);
|
$num = (@ldap_get_entries($_SESSION['ldap']->server(), $result)=="")?0:ldap_get_entries($_SESSION['ldap']->server(), $result);
|
||||||
$error = "";
|
$pcError = "";
|
||||||
if (!$this->processed) {
|
if (!$this->processed) {
|
||||||
$error = "";
|
$pcError = "";
|
||||||
}
|
}
|
||||||
elseif (strlen($this->fixed_ip[$id]['cn'])>20) {
|
elseif (strlen($this->fixed_ip[$id]['cn'])>20) {
|
||||||
$error = "«« " . _("The PC name may not be longer than 20 characters.");
|
$pcError = _("The PC name may not be longer than 20 characters.");
|
||||||
}
|
}
|
||||||
elseif (strlen($this->fixed_ip[$id]['cn'])<2) {
|
elseif (strlen($this->fixed_ip[$id]['cn'])<2) {
|
||||||
$error = "«« " . _("The PC name needs to be at least 2 characters long.");
|
$pcError = _("The PC name needs to be at least 2 characters long.");
|
||||||
}
|
}
|
||||||
elseif (in_array($this->fixed_ip[$id]['cn'], $pcs) ) {
|
elseif (in_array($this->fixed_ip[$id]['cn'], $pcs) ) {
|
||||||
$error="«« " . _("This PC name already exists.");
|
$pcError = _("This PC name already exists.");
|
||||||
}
|
}
|
||||||
elseif (!eregi("^[A-Za-z0-9\._-]*$",$_POST['pc_'.$id])) {
|
elseif (!eregi("^[A-Za-z0-9\._-]*$",$_POST['pc_'.$id])) {
|
||||||
$error="«« " . _("The PC name may only contain A-Z, a-z and 0-9.");
|
$pcError = _("The PC name may only contain A-Z, a-z and 0-9.");
|
||||||
}
|
}
|
||||||
$pcs[] = $this->fixed_ip[$id]['cn'];
|
$pcs[] = $this->fixed_ip[$id]['cn'];
|
||||||
$return[] = array(
|
|
||||||
array('kind' => 'text', 'text' => _('PC name') . ":* "),
|
|
||||||
array('kind' => 'input', 'name' => 'pc_'.$id.'', 'value' => $this->fixed_ip[$id]['cn']),
|
|
||||||
array('kind' => 'help', 'value' => 'pc', 'scope' => 'user'),
|
|
||||||
array('kind' => 'text', 'text'=>$error));
|
|
||||||
|
|
||||||
// MAC address
|
// MAC address
|
||||||
$error = "";
|
$macError = "";
|
||||||
if (!$this->processed) {
|
if (!$this->processed) {
|
||||||
$error = "";
|
$macError = "";
|
||||||
}
|
}
|
||||||
elseif ($this->check_mac($this->fixed_ip[$id]['mac'])) {
|
elseif ($this->check_mac($this->fixed_ip[$id]['mac'])) {
|
||||||
$error = "«« " . _("Invalid MAC address.");
|
$macError = _("Invalid MAC address.");
|
||||||
}
|
}
|
||||||
$return[] = array(
|
|
||||||
array('kind' => 'text', 'text' => _('MAC address') . ":* "),
|
|
||||||
array('kind' => 'input', 'name' => 'mac_'.$id.'', 'value' => $this->fixed_ip[$id]['mac']),
|
|
||||||
array('kind' => 'help', 'value' => 'mac', 'scope' => 'user'),
|
|
||||||
array('kind' => 'text', 'text'=>$error));
|
|
||||||
|
|
||||||
// fixed ip
|
// fixed ip
|
||||||
$error = "";
|
$ipError = "";
|
||||||
if (!$this->processed) {
|
if (!$this->processed) {
|
||||||
$error = "";
|
$ipError = "";
|
||||||
}
|
}
|
||||||
elseif (check_ip($this->fixed_ip[$id]['ip']) && !$_SESSION['account']->getAccountModule('range')->check_subnet_range($this->fixed_ip[$id]['ip'], $_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0]) ) {
|
elseif (($this->fixed_ip[$id]['ip'] == '') || !check_ip($this->fixed_ip[$id]['ip'])) {
|
||||||
$error = "«« " . _("The IP address does not match the subnet.");
|
$ipError = _("The IP address is invalid.");
|
||||||
|
}
|
||||||
|
elseif (!$_SESSION['account']->getAccountModule('range')->check_subnet_range($this->fixed_ip[$id]['ip'], $_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0]) ) {
|
||||||
|
$ipError = _("The IP address does not match the subnet.");
|
||||||
}
|
}
|
||||||
elseif (!$this->overlapd_ip($this->fixed_ip[$id]['ip'])) {
|
elseif (!$this->overlapd_ip($this->fixed_ip[$id]['ip'])) {
|
||||||
$error = "«« " . _("The IP address is already in use.");
|
$ipError = _("The IP address is already in use.");
|
||||||
|
}
|
||||||
|
$error = '';
|
||||||
|
if ($pcError != '') {
|
||||||
|
$error .= ' ' . $pcError;
|
||||||
|
}
|
||||||
|
if ($macError != '') {
|
||||||
|
$error .= ' ' . $macError;
|
||||||
|
}
|
||||||
|
if ($ipError != '') {
|
||||||
|
$error .= ' ' . $ipError;
|
||||||
|
}
|
||||||
|
if ($error != '') {
|
||||||
|
$error = ' « ' . $error;
|
||||||
}
|
}
|
||||||
$return[] = array(
|
$return[] = array(
|
||||||
array('kind' => 'text', 'text' => _('IP address') . ":* "),
|
array('kind' => 'input', 'name' => 'pc_'.$id, 'value' => $this->fixed_ip[$id]['cn']),
|
||||||
array('kind' => 'input', 'name' => 'ip_'.$id.'', 'value' => $this->fixed_ip[$id]['ip']),
|
array('kind' => 'input', 'name' => 'mac_'.$id, 'value' => $this->fixed_ip[$id]['mac']),
|
||||||
array('kind' => 'help', 'value' => 'ip', 'scope' => 'user'),
|
array('kind' => 'input', 'name' => 'ip_'.$id, 'value' => $this->fixed_ip[$id]['ip']),
|
||||||
array('kind' => 'text', 'text'=>$error));
|
array('kind' => 'input', 'name' => 'drop_ip_'.$id, 'type' => 'submit', 'value' => ' ', 'image' => 'del.png'),
|
||||||
|
array('kind' => 'text', 'text'=>$error),
|
||||||
// fixed_ip drop:
|
);
|
||||||
$return[] = array(
|
|
||||||
array('kind' => 'text', 'text' => _('Delete IP') . ':'),
|
|
||||||
array('kind' => 'input', 'name' => 'drop_ip_'.$id, 'type' => 'submit', 'value' => _('Delete IP')),
|
|
||||||
array('kind' => 'help', 'value' => 'drop_ip'));
|
|
||||||
|
|
||||||
// Space Line
|
|
||||||
$return[] = array(array('kind' => 'text', 'text' => '<br />'));
|
|
||||||
}
|
}
|
||||||
|
$return[] = array(
|
||||||
|
array('kind' => 'text', 'text' => ''),
|
||||||
|
);
|
||||||
// add fixed ip:
|
// add fixed ip:
|
||||||
$return[] = array(
|
$return[] = array(
|
||||||
array('kind' => 'text', 'text' => _('Add IP') . ':'),
|
array('kind' => 'input', 'name' => 'pc_add', 'value' => ''),
|
||||||
array('kind' => 'input', 'name' => 'add_ip', 'type' => 'submit', 'value' => _('Add IP')),
|
array('kind' => 'input', 'name' => 'mac_add', 'value' => ''),
|
||||||
array('kind' => 'help', 'value' => 'add_ip'));
|
array('kind' => 'input', 'name' => 'ip_add', 'value' => ''),
|
||||||
|
array('kind' => 'input', 'name' => 'add_ip', 'type' => 'submit', 'value' => ' ', 'image' => 'add.png'),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
|
|
Loading…
Reference in New Issue