mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
add a distinction between ignore and disable for ports, like for devices - patch by Paul Gear
git-svn-id: http://www.observium.org/svn/observer/trunk@1942 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -7,24 +7,58 @@ $rows_updated = 0;
|
||||
|
||||
foreach ($_POST as $key => $val)
|
||||
{
|
||||
if (strncmp($key,"oldval_",7) == 0)
|
||||
if (strncmp($key,"oldign_",7) == 0)
|
||||
{
|
||||
# Interface identifier passed as part of the field name
|
||||
|
||||
$interface_id = intval(substr($key,7));
|
||||
|
||||
$oldval = intval($val) ? 1 : 0;
|
||||
$newval = $_POST['ignore_'.$interface_id] ? 1 : 0;
|
||||
$oldign = intval($val) ? 1 : 0;
|
||||
$newign = $_POST['ignore_'.$interface_id] ? 1 : 0;
|
||||
|
||||
# As checkboxes are not posted when unset - we effectively need to do a diff to work
|
||||
# out a set->unset case.
|
||||
|
||||
if ($oldval == $newval)
|
||||
if ($oldign == $newign)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!mysql_query('UPDATE `ports` SET `ignore`='.$newval.' WHERE `device_id`='.$device_id.' AND `interface_id`='.$interface_id))
|
||||
if (!mysql_query('UPDATE `ports` SET `ignore`='.$newign.' WHERE `device_id`='.$device_id.' AND `interface_id`='.$interface_id))
|
||||
{
|
||||
$n = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$n = mysql_affected_rows();
|
||||
}
|
||||
|
||||
if ($n <0)
|
||||
{
|
||||
$rows_updated = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
$rows_updated += $n;
|
||||
}
|
||||
elseif (strncmp($key,"olddis_",7) == 0)
|
||||
{
|
||||
# Interface identifier passed as part of the field name
|
||||
|
||||
$interface_id = intval(substr($key,7));
|
||||
|
||||
$olddis = intval($val) ? 1 : 0;
|
||||
$newdis = $_POST['disabled_'.$interface_id] ? 1 : 0;
|
||||
|
||||
# As checkboxes are not posted when unset - we effectively need to do a diff to work
|
||||
# out a set->unset case.
|
||||
|
||||
if ($olddis == $newdis)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!mysql_query('UPDATE `ports` SET `disabled`='.$newdis.' WHERE `device_id`='.$device_id.' AND `interface_id`='.$interface_id))
|
||||
{
|
||||
$n = -1;
|
||||
}
|
||||
@@ -55,4 +89,4 @@ if ($rows_updated > 0)
|
||||
$updated = 0;
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
Reference in New Issue
Block a user