better DHCP searching
This commit is contained in:
parent
89b46e63fc
commit
29c3f6582c
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue