small cleanups etc, plus allow sysLocation override

git-svn-id: http://www.observium.org/svn/observer/trunk@2000 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-03-31 17:19:54 +00:00
parent 28e03f65ea
commit b7720135e9
12 changed files with 382 additions and 319 deletions
+52 -34
View File
@@ -4,11 +4,25 @@ if ($_POST['editing'])
{
if ($_SESSION['userlevel'] > "7")
{
$updated = 0;
$descr = mres($_POST['descr']);
$ignore = mres($_POST['ignore']);
$type = mres($_POST['type']);
$disabled = mres($_POST['disabled']);
$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 ($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
$sql = "UPDATE `devices` SET `purpose` = '" . $descr . "', `type` = '$type'";
$sql .= ", `ignore` = '$ignore', `disabled` = '$disabled'";
@@ -26,14 +40,19 @@ if ($_POST['editing'])
$updated = -1;
} else {
$update_message = "Device record update error.";
$updated = 0;
}
}
else
{
include("includes/error-no-perm.inc.php");
}
}
$device = mysql_fetch_assoc(mysql_query("SELECT * FROM `devices` WHERE `device_id` = '".$device['device_id']."'"));
$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);
@@ -41,29 +60,31 @@ if ($updated && $update_message)
print_error($update_message);
}
echo("<table cellpadding=0 cellspacing=0><tr><td>
?>
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<h5>
<a href="?page=delhost&id="<?php echo($device['device_id']) ?>">
<img src="images/16/server_delete.png" align="absmiddle">
Delete
</a>
</h5>
<h5>
<a href='?page=delhost&id=".$device['device_id']."'>
<img src='images/16/server_delete.png' align='absmiddle'>
Delete
</a>
</h5>
<form id='edit' name='edit' method='post' action=''>
<input type=hidden name='editing' value='yes'>
<table width='400' border='0'>
<form id="edit" name="edit" method="post" action="">
<input type=hidden name="editing" value="yes">
<table width="500" border="0">
<tr>
<td><div align='right'>Description</div></td>
<td colspan='3'><input name='descr' size='32' value='" . $device['purpose'] . "'></input></td>
<td colspan="2" align="right">Description:</td>
<td colspan="3"><input name="descr" size="32" value="<?php echo($device['purpose']); ?>"></input></td>
</tr>
<tr>
<td align='right'>
Type
<td colspan="2" align="right">
Type:
</td>
<td>
<select name='type'>");
<select name="type">
<?php
$unknown = 1;
foreach ($device_types as $type)
{
@@ -79,22 +100,21 @@ foreach ($device_types as $type)
{
echo(' <option value="other">Other</option>');
}
echo("
?>
</select>
</td>
</tr>
<tr>
<td><div align='right'>Disable</div></td>
<td><input name='disabled' type='checkbox' id='disabled' value='1'");
if ($device['disabled']) { echo("checked=checked"); }
echo("/></td>
<td><div align='right'>Ignore</div></td>
<td><input name='ignore' type='checkbox' id='disable' value='1'");
if ($device['ignore']) { echo("checked=checked"); }
echo("/></td>
</tr>");
echo('
<td width="40"><div style="padding-right: 5px; text-align: right"><input onclick="edit.sysLocation.disabled=!edit.override_sysLocation.checked" type="checkbox" name="override_sysLocation"<?php if ($override_sysLocation_bool) { echo(' checked="1"'); } ?> /></div></td>
<td width="150" align="right">Override sysLocation:</td>
<td><input name="sysLocation" size="32"<?php if (!$override_sysLocation_bool) { echo(' disabled="1"'); } ?> value="<?php echo($override_sysLocation_string); ?>" /></td>
</tr>
<tr>
<td colspan="2"><div align="right">Disable</div></td>
<td><input name="disabled" type="checkbox" id="disabled" value="1" <?php if ($device["disabled"]) { echo("checked=checked"); } ?> /></td>
<td><div align="right">Ignore</div></td>
<td><input name="ignore" type="checkbox" id="disable" value="1" <?php if ($device['ignore']) { echo("checked=checked"); } ?> /></td>
</tr>
</table>
<input type="submit" name="Submit" value="Save" />
<label><br />
@@ -102,6 +122,4 @@ echo('
</form>
</td>
<td width="50"></td><td></td></tr></table>');
?>
<td width="50"></td><td></td></tr></table>