mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 18:38:25 +00:00
Implement more efficient is_dev_attrib_enabled()
This commit is contained in:
parent
78bf0b7a0a
commit
982faeb869
@ -453,16 +453,6 @@ function get_dev_attribs($device)
|
||||
return $attribs;
|
||||
}
|
||||
|
||||
function is_dev_attrib_enabled($device, $attrib)
|
||||
{
|
||||
foreach (get_dev_attribs($device) as $name => $val) {
|
||||
if ($name == $attrib && $val == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function get_dev_entity_state($device)
|
||||
{
|
||||
$state = array();
|
||||
@ -486,6 +476,19 @@ function get_dev_attrib($device, $attrib_type)
|
||||
}
|
||||
}
|
||||
|
||||
function is_dev_attrib_enabled($device, $attrib, $default = true)
|
||||
{
|
||||
$val = get_dev_attrib($device, $attrib);
|
||||
if ($val != NULL) {
|
||||
// attribute is set
|
||||
return ($val != 0);
|
||||
}
|
||||
else {
|
||||
// attribute not set
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
|
||||
function del_dev_attrib($device, $attrib_type)
|
||||
{
|
||||
return dbDelete('devices_attribs', "`device_id` = ? AND `attrib_type` = ?", array($device['device_id'], $attrib_type));
|
||||
|
Loading…
Reference in New Issue
Block a user