Merge branch 'dashboards-in-home-page-dev' into 'develop'

Added dashboards to "edit my user" section

See merge request !391
This commit is contained in:
vgilc 2017-05-17 17:20:29 +02:00
commit 3118a70f66
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) {
if (users_is_admin($id_user)) {
$sql = "SELECT name
FROM tdashboard WHERE id_user = '" . $id_user ."' OR id_user = ''";
}
else {
$user_can_manage_all = users_can_manage_group_all('RR');
if ($user_can_manage_all) {
$sql = "SELECT name
FROM tdashboard WHERE id_user = '" . $id_user ."' OR id_user = ''";
}
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_user="."'".$id_user."'";
WHERE id_group IN (" . implode(",", $u_groups) . ") AND (id_user = '" . $id_user ."' OR id_user = '')";
}
}
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');