Fix reset user creation form on error
This commit is contained in:
parent
eed28bc668
commit
1c157ba2e4
|
@ -1444,7 +1444,7 @@ html_print_input_hidden('json_profile', '');
|
|||
echo '</form>';
|
||||
|
||||
|
||||
profile_print_profile_table($id);
|
||||
profile_print_profile_table($id, io_safe_output($json_profile));
|
||||
|
||||
echo '<br />';
|
||||
|
||||
|
@ -1560,11 +1560,11 @@ $(document).ready (function () {
|
|||
switch_ehorus_conf();
|
||||
});
|
||||
$('#checkbox-ehorus_user_level_enabled').trigger('change');
|
||||
|
||||
var img_delete = '<?php echo $delete_image; ?>';
|
||||
var id_user = '<?php echo io_safe_output($id); ?>';
|
||||
var is_metaconsole = '<?php echo $meta; ?>';
|
||||
var user_is_global_admin = '<?php echo users_is_admin($id); ?>';
|
||||
var is_err = '<?php echo $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+']');
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue