Config option for global default dashboard (#4080)

* Config option for global default dashboard

Add config option to set a global default dashbord.  This will be used
instead of the user's "Default" dashboard unless they have changed their
default dashboard in their user settings.

* Use a dropdown for the default_dashboard option

Update generate_dynamic_config_panel to allow assoc arrays with
`'value'` and `'description'` as keys and change to a select box.

* Fix PHP style issues lost during merge
This commit is contained in:
Eldon Koyle
2016-08-23 12:37:12 -06:00
committed by Neil Lathwood
parent 0b57b1ef69
commit 787c4f09f7
5 changed files with 59 additions and 7 deletions

View File

@@ -18,12 +18,23 @@
$no_refresh = true;
$default_dash = 0;
if (($tmp = dbFetchCell('SELECT dashboard FROM users WHERE user_id=?', array($_SESSION['user_id']))) != 0) {
$tmp = dbFetchCell(
'SELECT dashboard FROM users WHERE user_id=?',
array($_SESSION['user_id'])
);
if ($tmp != 0) {
$default_dash = $tmp;
} elseif (dbFetchCell('SELECT dashboard_id FROM dashboards WHERE user_id=?', array($_SESSION['user_id'])) == 0) {
$vars['dashboard'] = dbInsert(array('dashboard_name'=>'Default','user_id'=>$_SESSION['user_id']), 'dashboards');
} elseif ((int)$config['webui']['default_dashboard_id']) {
// if the user hasn't set their default page, and there is a global default set
$default_dash = (int)$config['webui']['default_dashboard_id'];
}
if ($default_dash == 0 && dbFetchCell(
'SELECT dashboard_id FROM dashboards WHERE user_id=?',
array($_SESSION['user_id'])
) == 0) {
$vars['dashboard'] = dbInsert(array('dashboard_name'=>'Default', 'user_id'=>$_SESSION['user_id']), 'dashboards');
if (dbFetchCell('select 1 from users_widgets where user_id = ? && dashboard_id = ?', array($_SESSION['user_id'],0)) == 1) {
dbUpdate(array('dashboard_id'=>$vars['dashboard']), 'users_widgets', 'user_id = ? && dashboard_id = ?', array($_SESSION['user_id'],0));
dbUpdate(array('dashboard_id'=>$vars['dashboard']), 'users_widgets', 'user_id = ? && dashboard_id = ?', array($_SESSION['user_id'], 0));
}
}
if (!empty($vars['dashboard'])) {