webui: Allow users to set their default dashboard from preferences page

This commit is contained in:
Neil Lathwood
2016-10-22 17:06:52 +01:00
committed by GitHub

View File

@@ -24,11 +24,15 @@ if ($_SESSION['userlevel'] == 11) {
$changepass_message = 'Incorrect password';
}
}
if ($vars['action'] === 'changedash') {
if (!empty($vars['dashboard'])) {
dbUpdate(array('dashboard'=>$vars['dashboard']), 'users', 'user_id = ?', array($_SESSION['user_id']));
$updatedashboard_message = "User default dashboard updated";
}
}
include 'includes/update-preferences-password.inc.php';
if (passwordscanchange($_SESSION['username'])) {
echo '<h3>Change Password</h3>';
echo '<hr>';
@@ -173,6 +177,44 @@ if ($_SESSION['userlevel'] == 11) {
}//end if
}//end if
echo "<h3>Default Dashboard</h3>
<hr>
<div class='well'>";
if (!empty($updatedashboard_message)) {
print_message($updatedashboard_message);
}
echo "
<form method='post' action='preferences/' class='form-horizontal' role='form'>
<div class='form-group'>
<input type=hidden name='action' value='changedash'>
<div class='form-group'>
<label for='dashboard' class='col-sm-2 control-label'>Dashboard</label>
<div class='col-sm-4'>
<select class='form-control' name='dashboard'>";
$defdash = dbFetchCell("SELECT dashboard FROM users WHERE user_id = ?", array($_SESSION['user_id']));
$dashoptions = dbFetchRows(
"SELECT dashboards.*,users.username
FROM `dashboards`
INNER JOIN `users` ON users.user_id = dashboards.user_id
WHERE (dashboards.access > 0 && dashboards.user_id != ?) || dashboards.user_id = ?",
array($_SESSION['user_id'],$_SESSION['user_id'])
);
foreach ($dashoptions as $dash) {
echo "
<option value='".$dash['dashboard_id']."'".($defdash == $dash['dashboard_id'] ? ' selected' : '').">".display($dash['username']).':'.display($dash['dashboard_name'])."</option>";
}
echo "
</select>
<br>
<center><button type='submit' class='btn btn-default'>Update Dashboard</button></center>
</div>
<div class='col-sm-6'></div>
</div>
</div>
</form>
</div>";
echo "<h3>Device Permissions</h3>";
echo "<hr>";