Merge branch 'ent-9817-duplicado-de-perfiles-al-crear-agente' into 'develop'

Ent 9817 duplicado de perfiles al crear agente

See merge request artica/pandorafms!5377
This commit is contained in:
Daniel Rodriguez 2023-01-10 16:18:24 +00:00
commit 2f4758009b
2 changed files with 31 additions and 10 deletions

View File

@ -1643,13 +1643,18 @@ if ($config['admin_can_add_user']) {
}
echo '</div>';
if ($new_user === true) {
html_print_input_hidden('json_profile', $json_profile);
}
html_print_input_hidden('json_profile', $json_profile);
echo '</form>';
profile_print_profile_table($id, io_safe_output($json_profile));
if ($is_err === true && $new_user === true) {
profile_print_profile_table($id, io_safe_output($json_profile), false, true);
} else {
profile_print_profile_table($id, io_safe_output($json_profile));
}
echo '<br />';
@ -1869,6 +1874,8 @@ $(document).ready (function () {
});
$('input:image[name="del"]').click(function (e) {
if($(json_profile).length > 0) return;
if (!confirm ('Are you sure?')) return;
e.preventDefault();
var rows = $("#table_profiles tr").length;
if (((is_metaconsole === '1' && rows <= 4) || (is_metaconsole === '' && rows <= 3)) && user_is_global_admin !== '1') {

View File

@ -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, $json_profile=false, $return=false)
function profile_print_profile_table($id, $json_profile=false, $return=false, $create_user=false)
{
global $config;
@ -296,12 +296,26 @@ function profile_print_profile_table($id, $json_profile=false, $return=false)
$data['hierarchy'] = $profile['no_hierarchy'] ? __('Yes') : __('No');
if ($create_user) {
$data['actions'] .= html_print_input_image(
'del',
'images/cross.png',
1,
'',
true,
[
'onclick' => 'delete_profile(event, this)',
'class' => 'invert_filter',
]
);
} else {
$data['actions'] = '<form method="post" onsubmit="if (!confirm (\''.__('Are you sure?').'\')) return false">';
$data['actions'] .= html_print_input_image('del', 'images/cross.png', 1, ['class' => 'invert_filter'], true);
$data['actions'] .= html_print_input_hidden('delete_profile', 1, true);
$data['actions'] .= html_print_input_hidden('id_user_profile', $profile['id_up'], true);
$data['actions'] .= html_print_input_hidden('id_user', $id, true);
$data['actions'] .= '</form>';
}
array_push($table->data, $data);
}