better DHCP searching

This commit is contained in:
Roland Gruber 2018-11-11 13:28:36 +01:00
parent 89b46e63fc
commit 29c3f6582c
2 changed files with 38 additions and 1 deletions

View File

@ -770,7 +770,7 @@ class fixed_ip extends baseModule {
/**
* Extracts the IP from a list of DHCP statements.
*
* @param array $dhcpStatements values of dhcpStatements attribute
* @param string $dhcpStatements values of dhcpStatements attribute
*/
public static function extractIP($dhcpStatements) {
$return = null;

View File

@ -177,6 +177,43 @@ class lamDHCPList extends lamList {
'deleteEntry' => _("Delete selected DHCP entries"));
}
/**
* {@inheritDoc}
* @see lamList::isFilterMatching()
*/
protected function isFilterMatching(&$data, $filterAttribute, $regex) {
if ($filterAttribute == "fixed_ips") {
if (empty($regex)) {
return true;
}
$entries = searchLDAP($data['dn'], 'objectClass=dhcpHost', array('dhcpstatements', 'dhcphwaddress', 'cn'));
if (sizeof($entries) > 0) {
foreach ($entries as $entry) {
foreach ($entry as $attrName => $attrValues) {
if (!is_array($attrValues)) {
continue;
}
foreach ($attrValues as $attrValue) {
if (preg_match($regex, $attrValue)) {
return true;
}
}
if (!empty($entry['dhcpstatements'])) {
$ip = fixed_ip::extractIP($entry['dhcpstatements']);
if (!empty($ip)) {
if (preg_match($regex, $ip)) {
return true;
}
}
}
}
}
}
return false;
}
return parent::isFilterMatching($data, $filterAttribute, $regex);
}
/**
* {@inheritDoc}
* @see lamList::getTableCellContent()