<?
require_once("../classes/network.php");
require_once("../classes/user.php");
session_start(); //Start session
$user = new User();
$network = new Network();
//If the user hasn't logged in then we should send him to the login page.
if (!$user->IsLoggedIn())
header("Location: index.php");
if ($HTTP_POST_VARS)
{
// Data posted, update users preferences from database
if ($viewmode == 1)
$viewmode = "All";
else if ($viewmode == 2)
$viewmode = "Overview";
else
$viewmode = "Details";
$tooltip = $tooltip?'Y':'N';
$user->SetUserPreferences($tooltip, $viewmode);
}
else
{
// Get users preferences from database
$result = $user->GetUserPreferences();
$tooltip = $result[0];
$viewmode = $result[1];
}
// shows the menu
function ShowMenu($user,$user_id)
{
if ($user->IsAdmin())
{
$name = $user->GetUserName($user_id);
print "<td height=19>[ <a href=selnodes.php?id=id0>your nodes</a> ]</td>\n";
if ($user_id == 0)
{
print "<td height=19>[ <a href=profile.php>your details</a> ]</td>\n";
}
else
{
print "<td height=19>[ <a href=profile.php?id=0>your details</a> ]</td>\n";
}
print "<td>[ preferences ]</td>\n";
print "</tr></table><table align=center><tr>\n";
if ($user_id != 0)
{
print "<td height=19>[ <a href=selnodes.php?id=id$user_id>$name's nodes</a> ]</td>\n";
print "<td height=19>[ $name's details ]</td>\n";
}
print "<td height=19>[ <a href=allusers.php>users</a> ]</td>\n";
}
else
{
print "<td height=19>[ <a href=profile.php>your details</a> ]</td>\n";
print "<td height=19>[ <a href=selnodes.php?id=id0>your nodes</a> ]</td>\n";
print "<td>[ preferences ]</td>\n";
}
}
?>
<html>
<head>
<link href="css/style1.css" rel="styleSheet" type="text/css">
<title>Preferences</title>
</head>
<body>
<?include("menuinclude.php");?>
<br><br>
<table align="center">
<tr>
<? ShowMenu($user,$name,$user_id) ?>
</tr>
</table>
<br>
<form method="post">
<table width = "50%" align="center" border="0">
<tr>
<td>
<!-- background table -->
<table width="300" align="center" border="0" cellspacing="1" cellpadding="0" bgcolor="#000000">
<tr>
<td>
<!-- gui table -->
<table width="300" border="0" cellspacing="1" cellpadding="2">
<!-- title row -->
<tr>
<td bgcolor="#515173" colspan="2">
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#FFFFFF"><b>Preferences</b></font>
</td>
</tr>
<tr>
<td bgcolor="#c0c0c0" colspan="2">
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
These preferences will affect the network monitor page<br>
</font>
</td>
</tr>
<!-- Submit -->
<tr bgcolor="#fcfcfc">
<td>
<table border=0>
<tr>
<td> </td>
<td><input type="checkbox" name="tooltip" <? if ($tooltip == 'Y') print 'checked';?> >Show tooltips</td>
</tr>
<tr>
<td>Viewmode</td>
<td>
<select name="viewmode">
<option value="1" <? if ($viewmode == 'All') print 'selected';?>>All</option>
<option value="2" <? if ($viewmode == 'Overview') print 'selected';?>>Overview</option>
<option value="3" <? if ($viewmode == 'Details') print 'selected';?> >Details</option>
</select>
</td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="#fcfcfc">
<td colspan="2" align="center"><input type="submit" value="Save changes"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>