mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Implement more efficient is_dev_attrib_enabled()
This commit is contained in:
@@ -453,16 +453,6 @@ function get_dev_attribs($device)
|
|||||||
return $attribs;
|
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)
|
function get_dev_entity_state($device)
|
||||||
{
|
{
|
||||||
$state = array();
|
$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)
|
function del_dev_attrib($device, $attrib_type)
|
||||||
{
|
{
|
||||||
return dbDelete('devices_attribs', "`device_id` = ? AND `attrib_type` = ?", array($device['device_id'], $attrib_type));
|
return dbDelete('devices_attribs', "`device_id` = ? AND `attrib_type` = ?", array($device['device_id'], $attrib_type));
|
||||||
|
|||||||
Reference in New Issue
Block a user