diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index d98fc1d944..800f738394 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -1444,7 +1444,7 @@ html_print_input_hidden('json_profile', ''); echo ''; -profile_print_profile_table($id); +profile_print_profile_table($id, io_safe_output($json_profile)); echo '
'; @@ -1560,11 +1560,11 @@ $(document).ready (function () { switch_ehorus_conf(); }); $('#checkbox-ehorus_user_level_enabled').trigger('change'); - var img_delete = ''; var id_user = ''; var is_metaconsole = ''; var user_is_global_admin = ''; + var is_err = ''; var data = []; $('input:image[name="add"]').click(function (e) { @@ -1588,7 +1588,7 @@ $(document).ready (function () { return; } - if (id_user === '') { + if (id_user === '' || is_err === 1) { let new_json = `{"profile":${profile},"group":${group},"tags":[${tags}],"hierarchy":${hierarchy}}`; data.push(new_json); json_profile.val('['+data+']'); diff --git a/pandora_console/include/functions_profile.php b/pandora_console/include/functions_profile.php index a16772c49e..c6a62c4c9d 100644 --- a/pandora_console/include/functions_profile.php +++ b/pandora_console/include/functions_profile.php @@ -181,7 +181,7 @@ function profile_delete_profile_and_clean_users($id_profile) * @param int User id * @param bool Show the tags select or not */ -function profile_print_profile_table($id) +function profile_print_profile_table($id, $json_profile=false) { global $config; @@ -243,7 +243,19 @@ function profile_print_profile_table($id) } if ($result === false) { - $result = []; + if ($json_profile !== false && empty($json_profile) !== true) { + $profile_decoded = json_decode($json_profile); + foreach ($profile_decoded as $profile) { + $result[] = [ + 'id_grupo' => $profile->group, + 'id_perfil' => $profile->profile, + 'tags' => $profile->tags, + 'hierarchy' => $profile->hierarchy, + ]; + } + } else { + $result = []; + } } foreach ($result as $profile) { @@ -268,7 +280,12 @@ function profile_print_profile_table($id) if (empty($profile['tags'])) { $data['tags'] = ''; } else { - $tags_ids = explode(',', $profile['tags']); + if (is_array($profile['tags'] === false)) { + $tags_ids = explode(',', $profile['tags']); + } else { + $tags_ids = $profile['tags']; + } + $tags = tags_get_tags($tags_ids); $data['tags'] = tags_get_tags_formatted($tags); }