From 9e90c8da07a2f361fc8c0649c8fc8e91d008d63d Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 20 Sep 2022 13:56:36 +0200 Subject: [PATCH 1/5] #9506 Changes in user profiles --- pandora_console/godmode/users/user_list.php | 113 +++++++++++++++----- 1 file changed, 85 insertions(+), 28 deletions(-) diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index efc3321c2c..b0dda31890 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -52,6 +52,8 @@ if (is_ajax()) { $method = get_parameter('method'); $group_id = get_parameter('group_id'); $group_recursion = (bool) get_parameter('group_recursion', 0); + $get_user_profile_group = (bool) get_parameter('get_user_profile_group', false); + $return_all = false; if ($group_id == -1) { @@ -93,6 +95,37 @@ if (is_ajax()) { echo json_encode($ret_id); return; } + + if ($get_user_profile_group === true) { + $id_user = get_parameter('id_user'); + + $user_profiles = []; + + // User profiles. + if (users_is_admin()) { + $user_profiles = db_get_all_rows_field_filter( + 'tusuario_perfil', + 'id_usuario', + $id_user + ); + } else { + $user_profiles_aux = users_get_user_profile($id_user); + foreach ($group_um as $key => $value) { + if (isset($user_profiles_aux[$key]) === true) { + $user_profiles[$key] = $user_profiles_aux[$key]; + unset($user_profiles_aux[$key]); + } + } + } + + foreach ($user_profiles as $key => $value) { + $user_profiles[$key]['id_perfil'] = profile_get_name($value['id_perfil']); + $user_profiles[$key]['id_grupo'] = groups_get_name($value['id_grupo'], true); + } + + echo json_encode($user_profiles); + return; + } } $sortField = get_parameter('sort_field'); @@ -588,10 +621,8 @@ $cont = 0; foreach ($info as $user_id => $user_info) { // User profiles. if ($user_is_admin || $user_id == $config['id_user'] || isset($group_um[0])) { - $user_profiles = db_get_all_rows_field_filter( - 'tusuario_perfil', - 'id_usuario', - $user_id + $user_profiles = db_get_all_rows_sql( + 'SELECT * FROM tusuario_perfil where id_usuario LIKE "'.$user_id.'" LIMIT 5' ); } else { $user_profiles_aux = users_get_user_profile($user_id); @@ -674,9 +705,9 @@ foreach ($info as $user_id => $user_info) { if ($user_profiles !== false) { $total_profile = 0; - $data[4] .= '
'; + $data[4] .= '
'; foreach ($user_profiles as $row) { - if ($total_profile <= 5) { + if ($total_profile < 5) { $data[4] .= "
"; $data[4] .= profile_get_name($row['id_perfil']); $data[4] .= ' /
'; @@ -685,8 +716,7 @@ foreach ($info as $user_id => $user_info) { $data[4] .= '
'; if ($total_profile == 0 && count($user_profiles) >= 5) { - $data[4] .= ' - '.html_print_image( + $data[4] .= ''.html_print_image( 'images/zoom.png', true, [ @@ -694,16 +724,15 @@ foreach ($info as $user_id => $user_info) { 'class' => 'invert_filter', ] ).''; + + $data[4] .= html_print_input_hidden( + 'show_groups_'.$row['id_usuario'], + -1, + true + ); } - $data[4] .= '
'; - $data[4] .= '
'; - $data[4] .= '
'; - } else { - $data[4] .= "'; enterprise_hook('close_meta_frame'); -echo ''; +; From 9b79ea79128db9cd8b19f9c49e0f9d5177d7f404 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Tue, 20 Sep 2022 16:05:27 +0200 Subject: [PATCH 2/5] #9506 Fixed um --- pandora_console/godmode/users/user_list.php | 14 ++++++++++---- pandora_console/include/functions_users.php | 7 ++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index b0dda31890..d282ff05af 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -99,10 +99,16 @@ if (is_ajax()) { if ($get_user_profile_group === true) { $id_user = get_parameter('id_user'); + $user_is_admin = users_is_admin(); + $user_profiles = []; + if ($user_is_admin === false) { + $group_um = users_get_groups_UM($config['id_user']); + } + // User profiles. - if (users_is_admin()) { + if ($user_is_admin || $id_user == $config['id_user'] || isset($group_um[0])) { $user_profiles = db_get_all_rows_field_filter( 'tusuario_perfil', 'id_usuario', @@ -625,7 +631,7 @@ foreach ($info as $user_id => $user_info) { 'SELECT * FROM tusuario_perfil where id_usuario LIKE "'.$user_id.'" LIMIT 5' ); } else { - $user_profiles_aux = users_get_user_profile($user_id); + $user_profiles_aux = users_get_user_profile($user_id, 'LIMIT 5'); $user_profiles = []; foreach ($group_um as $key => $value) { if (isset($user_profiles_aux[$key]) === true) { @@ -911,7 +917,7 @@ echo ''; enterprise_hook('close_meta_frame'); -?>; +?> ; + diff --git a/pandora_console/include/functions_users.php b/pandora_console/include/functions_users.php index f4e6e25be8..5db489377a 100755 --- a/pandora_console/include/functions_users.php +++ b/pandora_console/include/functions_users.php @@ -838,13 +838,14 @@ function users_has_profile_without_UM($id_user, $id_groups) } -function users_get_user_profile($id_user) +function users_get_user_profile($id_user, $limit='') { $sql = sprintf( "SELECT * FROM tusuario_perfil INNER JOIN tperfil ON tperfil.id_perfil = tusuario_perfil.id_perfil - WHERE tusuario_perfil.id_usuario like '%s'", - $id_user + WHERE tusuario_perfil.id_usuario like '%s' %s", + $id_user, + $limit ); $aux = db_get_all_rows_sql($sql); From 29c06a17f7c7b94d7de377d427feb0b228996cd0 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 21 Sep 2022 11:19:00 +0200 Subject: [PATCH 3/5] #9506 Fixed show profiles --- pandora_console/godmode/users/user_list.php | 59 ++++++++++----------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index d282ff05af..85a95a8f22 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -711,37 +711,35 @@ foreach ($info as $user_id => $user_info) { if ($user_profiles !== false) { $total_profile = 0; - $data[4] .= '
'; + $data[4] .= '
'; foreach ($user_profiles as $row) { - if ($total_profile < 5) { - $data[4] .= "
"; - $data[4] .= profile_get_name($row['id_perfil']); - $data[4] .= ' /
'; - $data[4] .= "
"; - $data[4] .= groups_get_name($row['id_grupo'], true); - $data[4] .= '
'; + $data[4] .= "
"; + $data[4] .= profile_get_name($row['id_perfil']); + $data[4] .= ' /
'; + $data[4] .= "
"; + $data[4] .= groups_get_name($row['id_grupo'], true); + $data[4] .= '
'; - if ($total_profile == 0 && count($user_profiles) >= 5) { - $data[4] .= ''.html_print_image( - 'images/zoom.png', - true, - [ - 'title' => __('Show'), - 'class' => 'invert_filter', - ] - ).''; + if ($total_profile == 0 && count($user_profiles) >= 5) { + $data[4] .= ''.html_print_image( + 'images/zoom.png', + true, + [ + 'title' => __('Show profiles'), + 'class' => 'invert_filter', + ] + ).''; - $data[4] .= html_print_input_hidden( - 'show_groups_'.$row['id_usuario'], - -1, - true - ); - } - - $data[4] .= '
'; - $data[4] .= '
'; + $data[4] .= html_print_input_hidden( + 'show_groups_'.$row['id_usuario'], + -1, + true + ); } + $data[4] .= '
'; + $data[4] .= '
'; + $total_profile++; } @@ -754,6 +752,8 @@ foreach ($info as $user_id => $user_info) { } $data[4] .= '
'; + $data[4] .= ''; } else { $data[4] .= __('The user doesn\'t have any assigned profile/group'); } @@ -946,14 +946,13 @@ enterprise_hook('close_meta_frame'); } }); $(`#hidden-show_groups_${id_user}`).val('1'); + $(`#profiles_${id_user}`).show(); } else if ($(`#hidden-show_groups_${id_user}`).val() === '1') { $(`#hidden-show_groups_${id_user}`).val('0'); - $(`div[id^=left_${id_user}_]`).hide(); - $(`div[id^=right_${id_user}_]`).hide(); + $(`#profiles_${id_user}`).hide(); } else { $(`#hidden-show_groups_${id_user}`).val('1'); - $(`div[id^=left_${id_user}_]`).show(); - $(`div[id^=right_${id_user}_]`).show(); + $(`#profiles_${id_user}`).show(); } } From 83ac81ab2336a7182c1f905e341eeb6b9d5b4ccb Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Fri, 7 Oct 2022 10:56:12 +0200 Subject: [PATCH 4/5] #9506 Fixed meta --- pandora_console/godmode/users/user_list.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index 85a95a8f22..e99a5648b1 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -31,8 +31,6 @@ global $config; check_login(); -enterprise_hook('open_meta_frame'); - require_once $config['homedir'].'/include/functions_profile.php'; require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_groups.php'; @@ -134,6 +132,8 @@ if (is_ajax()) { } } +enterprise_hook('open_meta_frame'); + $sortField = get_parameter('sort_field'); $sort = get_parameter('sort', 'none'); $tab = get_parameter('tab', 'user'); @@ -924,7 +924,7 @@ enterprise_hook('close_meta_frame'); var request = $.ajax({ url: "", type: 'GET', - dataType: 'JSON', + dataType: 'json', data: { page: 'godmode/users/user_list', get_user_profile_group: 1, @@ -943,6 +943,9 @@ enterprise_hook('close_meta_frame'); } count ++; }); + }, + error: function (e, textStatus) { + console.error(textStatus); } }); $(`#hidden-show_groups_${id_user}`).val('1'); From f3bc5427baee7575a38a42db35a75e56ee9b8ec0 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Thu, 13 Oct 2022 13:22:36 +0200 Subject: [PATCH 5/5] #9506 Fixed meta ajax --- pandora_console/godmode/users/user_list.php | 74 ++++++++++----------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index e99a5648b1..a5ec875334 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -54,6 +54,43 @@ if (is_ajax()) { $return_all = false; + if ($get_user_profile_group === true) { + $id_user = get_parameter('id_user'); + + $user_is_admin = users_is_admin(); + + $user_profiles = []; + + if ($user_is_admin === false) { + $group_um = users_get_groups_UM($config['id_user']); + } + + // User profiles. + if ($user_is_admin || $id_user == $config['id_user'] || isset($group_um[0])) { + $user_profiles = db_get_all_rows_field_filter( + 'tusuario_perfil', + 'id_usuario', + $id_user + ); + } else { + $user_profiles_aux = users_get_user_profile($id_user); + foreach ($group_um as $key => $value) { + if (isset($user_profiles_aux[$key]) === true) { + $user_profiles[$key] = $user_profiles_aux[$key]; + unset($user_profiles_aux[$key]); + } + } + } + + foreach ($user_profiles as $key => $value) { + $user_profiles[$key]['id_perfil'] = profile_get_name($value['id_perfil']); + $user_profiles[$key]['id_grupo'] = groups_get_name($value['id_grupo'], true); + } + + echo json_encode($user_profiles); + return; + } + if ($group_id == -1) { $sql = 'SELECT tusuario.id_user FROM tusuario LEFT OUTER JOIN tusuario_perfil @@ -93,43 +130,6 @@ if (is_ajax()) { echo json_encode($ret_id); return; } - - if ($get_user_profile_group === true) { - $id_user = get_parameter('id_user'); - - $user_is_admin = users_is_admin(); - - $user_profiles = []; - - if ($user_is_admin === false) { - $group_um = users_get_groups_UM($config['id_user']); - } - - // User profiles. - if ($user_is_admin || $id_user == $config['id_user'] || isset($group_um[0])) { - $user_profiles = db_get_all_rows_field_filter( - 'tusuario_perfil', - 'id_usuario', - $id_user - ); - } else { - $user_profiles_aux = users_get_user_profile($id_user); - foreach ($group_um as $key => $value) { - if (isset($user_profiles_aux[$key]) === true) { - $user_profiles[$key] = $user_profiles_aux[$key]; - unset($user_profiles_aux[$key]); - } - } - } - - foreach ($user_profiles as $key => $value) { - $user_profiles[$key]['id_perfil'] = profile_get_name($value['id_perfil']); - $user_profiles[$key]['id_grupo'] = groups_get_name($value['id_grupo'], true); - } - - echo json_encode($user_profiles); - return; - } } enterprise_hook('open_meta_frame');