Added dashboards to "edit my user" section

This commit is contained in:
Arturo Gonzalez 2017-04-20 17:36:26 +02:00
parent c3ccb00b2a
commit 87f3798499
2 changed files with 27 additions and 3 deletions

View File

@ -1990,9 +1990,32 @@ function get_os_name ($id_os) {
* @return array Dashboard name of the given user.
*/
function get_user_dashboards ($id_user) {
$sql = "SELECT name
FROM tdashboard
WHERE id_user="."'".$id_user."'";
if (users_is_admin($id_user)) {
$sql = "SELECT name
FROM tdashboard";
}
else {
$user_can_manage_all = users_can_manage_group_all('RR');
if ($user_can_manage_all) {
$sql = "SELECT name
FROM tdashboard";
}
else {
$user_groups = users_get_groups($id_user, "RR", false);
if (empty($user_groups)) {
return false;
}
$u_groups = array();
foreach ($user_groups as $id => $group_name) {
$u_groups[] = $id;
}
$sql = "SELECT name
FROM tdashboard
WHERE id_group IN (" . implode(",", $u_groups) . ")";
}
}
return db_get_all_rows_sql ($sql);
}

View File

@ -288,6 +288,7 @@ if (!$meta) {
if (enterprise_installed()) {
$dashboards = get_user_dashboards ($config['id_user']);
$dashboards_aux = array();
if ($dashboards === false) {
$dashboards = array('None'=>'None');