mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix coding style part 2
This commit is contained in:
@@ -1,45 +1,51 @@
|
||||
<?php
|
||||
|
||||
if ($_POST['editing'])
|
||||
{
|
||||
if ($_SESSION['userlevel'] > "7")
|
||||
{
|
||||
$updated = 0;
|
||||
if ($_POST['editing']) {
|
||||
if ($_SESSION['userlevel'] > "7") {
|
||||
$updated = 0;
|
||||
|
||||
$override_sysLocation_bool = mres($_POST['override_sysLocation']);
|
||||
if (isset($_POST['sysLocation'])) { $override_sysLocation_string = mres($_POST['sysLocation']); }
|
||||
$override_sysLocation_bool = mres($_POST['override_sysLocation']);
|
||||
if (isset($_POST['sysLocation'])) {
|
||||
$override_sysLocation_string = mres($_POST['sysLocation']);
|
||||
}
|
||||
|
||||
if (get_dev_attrib($device,'override_sysLocation_bool') != $override_sysLocation_bool
|
||||
|| get_dev_attrib($device,'override_sysLocation_string') != $override_sysLocation_string)
|
||||
{
|
||||
$updated = 1;
|
||||
if (get_dev_attrib($device,'override_sysLocation_bool') != $override_sysLocation_bool
|
||||
|| get_dev_attrib($device,'override_sysLocation_string') != $override_sysLocation_string) {
|
||||
$updated = 1;
|
||||
}
|
||||
|
||||
if ($override_sysLocation_bool) {
|
||||
set_dev_attrib($device, 'override_sysLocation_bool', '1');
|
||||
}
|
||||
else {
|
||||
del_dev_attrib($device, 'override_sysLocation_bool');
|
||||
}
|
||||
if (isset($override_sysLocation_string)) {
|
||||
set_dev_attrib($device, 'override_sysLocation_string', $override_sysLocation_string);
|
||||
};
|
||||
|
||||
#FIXME needs more sanity checking! and better feedback
|
||||
|
||||
$param = array('purpose' => $_POST['descr'], 'type' => $_POST['type'], 'ignore' => $_POST['ignore'], 'disabled' => $_POST['disabled']);
|
||||
|
||||
$rows_updated = dbUpdate($param, 'devices', '`device_id` = ?', array($device['device_id']));
|
||||
|
||||
if ($rows_updated > 0 || $updated) {
|
||||
$update_message = "Device record updated.";
|
||||
$updated = 1;
|
||||
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
|
||||
}
|
||||
elseif ($rows_updated = '-1') {
|
||||
$update_message = "Device record unchanged. No update necessary.";
|
||||
$updated = -1;
|
||||
}
|
||||
else {
|
||||
$update_message = "Device record update error.";
|
||||
}
|
||||
}
|
||||
|
||||
if ($override_sysLocation_bool) { set_dev_attrib($device, 'override_sysLocation_bool', '1'); } else { del_dev_attrib($device, 'override_sysLocation_bool'); }
|
||||
if (isset($override_sysLocation_string)) { set_dev_attrib($device, 'override_sysLocation_string', $override_sysLocation_string); };
|
||||
|
||||
#FIXME needs more sanity checking! and better feedback
|
||||
|
||||
$param = array('purpose' => $_POST['descr'], 'type' => $_POST['type'], 'ignore' => $_POST['ignore'], 'disabled' => $_POST['disabled']);
|
||||
|
||||
$rows_updated = dbUpdate($param, 'devices', '`device_id` = ?', array($device['device_id']));
|
||||
|
||||
if ($rows_updated > 0 || $updated)
|
||||
{
|
||||
$update_message = "Device record updated.";
|
||||
$updated = 1;
|
||||
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = ?", array($device['device_id']));
|
||||
} elseif ($rows_updated = '-1') {
|
||||
$update_message = "Device record unchanged. No update necessary.";
|
||||
$updated = -1;
|
||||
} else {
|
||||
$update_message = "Device record update error.";
|
||||
else {
|
||||
include 'includes/error-no-perm.inc.php';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
include("includes/error-no-perm.inc.php");
|
||||
}
|
||||
}
|
||||
|
||||
$descr = $device['purpose'];
|
||||
@@ -47,11 +53,11 @@ $descr = $device['purpose'];
|
||||
$override_sysLocation_bool = get_dev_attrib($device,'override_sysLocation_bool');
|
||||
$override_sysLocation_string = get_dev_attrib($device,'override_sysLocation_string');
|
||||
|
||||
if ($updated && $update_message)
|
||||
{
|
||||
print_message($update_message);
|
||||
} elseif ($update_message) {
|
||||
print_error($update_message);
|
||||
if ($updated && $update_message) {
|
||||
print_message($update_message);
|
||||
}
|
||||
elseif ($update_message) {
|
||||
print_error($update_message);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -91,20 +97,17 @@ if($config['enable_clear_discovery'] == 1) {
|
||||
<?php
|
||||
$unknown = 1;
|
||||
|
||||
foreach ($config['device_types'] as $type)
|
||||
{
|
||||
echo(' <option value="'.$type['type'].'"');
|
||||
if ($device['type'] == $type['type'])
|
||||
{
|
||||
echo(' selected="1"');
|
||||
$unknown = 0;
|
||||
}
|
||||
echo(' >' . ucfirst($type['type']) . '</option>');
|
||||
foreach ($config['device_types'] as $type) {
|
||||
echo(' <option value="'.$type['type'].'"');
|
||||
if ($device['type'] == $type['type']) {
|
||||
echo(' selected="1"');
|
||||
$unknown = 0;
|
||||
}
|
||||
echo(' >' . ucfirst($type['type']) . '</option>');
|
||||
}
|
||||
if ($unknown)
|
||||
{
|
||||
if ($unknown) {
|
||||
echo(' <option value="other">Other</option>');
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
@@ -113,7 +116,7 @@ foreach ($config['device_types'] as $type)
|
||||
<label for="sysLocation" class="col-sm-2 control-label">Override sysLocation:</label>
|
||||
<div class="col-sm-6">
|
||||
<div class="checkbox">
|
||||
<input onclick="edit.sysLocation.disabled=!edit.override_sysLocation.checked" type="checkbox" name="override_sysLocation"<?php if ($override_sysLocation_bool) { echo(' checked="1"'); } ?> />
|
||||
<input onclick="edit.sysLocation.disabled=!edit.override_sysLocation.checked" type="checkbox" name="override_sysLocation"<?php if ($override_sysLocation_bool) echo(' checked="1"'); ?> />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -121,19 +124,19 @@ foreach ($config['device_types'] as $type)
|
||||
<div class="col-sm-2">
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<input id="sysLocation" name="sysLocation" class="form-control" <?php if (!$override_sysLocation_bool) { echo(' disabled="1"'); } ?> value="<?php echo($override_sysLocation_string); ?>" />
|
||||
<input id="sysLocation" name="sysLocation" class="form-control" <?php if (!$override_sysLocation_bool) echo(' disabled="1"'); ?> value="<?php echo($override_sysLocation_string); ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="disabled" class="col-sm-2 control-label">Disable:</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="disabled" type="checkbox" id="disabled" value="1" <?php if ($device["disabled"]) { echo("checked=checked"); } ?> />
|
||||
<input name="disabled" type="checkbox" id="disabled" value="1" <?php if ($device["disabled"]) echo("checked=checked"); ?> />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="ignore" class="col-sm-2 control-label">Ignore</label>
|
||||
<div class="col-sm-6">
|
||||
<input name="ignore" type="checkbox" id="ignore" value="1" <?php if ($device['ignore']) { echo("checked=checked"); } ?> />
|
||||
<input name="ignore" type="checkbox" id="ignore" value="1" <?php if ($device['ignore']) echo("checked=checked"); ?> />
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" name="Submit" class="btn btn-default">Save</button>
|
||||
|
Reference in New Issue
Block a user