From 0b6d1a784086b5a8ed9bd3724c0f8e08b5546650 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 9 Dec 2022 11:37:08 +0100 Subject: [PATCH 1/4] #9903 Duplicate control profile --- .../godmode/users/configure_profile.php | 39 +++++++++++++++++-- pandora_console/include/ajax/profile.php | 29 ++++++++++++++ 2 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 pandora_console/include/ajax/profile.php diff --git a/pandora_console/godmode/users/configure_profile.php b/pandora_console/godmode/users/configure_profile.php index b1db4e26e9..a0335921de 100644 --- a/pandora_console/godmode/users/configure_profile.php +++ b/pandora_console/godmode/users/configure_profile.php @@ -404,6 +404,7 @@ if ($id_profile || $new_profile) { html_print_input_hidden('create_profile', 1); } else { html_print_input_hidden('id', $id_profile); + html_print_input_hidden('old_name_profile', $name); html_print_input_hidden('update_profile', 1); html_print_submit_button(__('Update'), 'upd', false, 'class="sub upd"'); } @@ -415,15 +416,45 @@ enterprise_hook('close_meta_frame'); ?> - diff --git a/pandora_console/include/ajax/profile.php b/pandora_console/include/ajax/profile.php new file mode 100644 index 0000000000..56a29fd31d --- /dev/null +++ b/pandora_console/include/ajax/profile.php @@ -0,0 +1,29 @@ + Date: Mon, 12 Dec 2022 10:50:59 +0100 Subject: [PATCH 2/4] Change "safe" for "save" on profile duplicate --- pandora_console/godmode/users/configure_profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/users/configure_profile.php b/pandora_console/godmode/users/configure_profile.php index a0335921de..a37df6bb5e 100644 --- a/pandora_console/godmode/users/configure_profile.php +++ b/pandora_console/godmode/users/configure_profile.php @@ -443,7 +443,7 @@ enterprise_hook('close_meta_frame'); }, success: function (data) { if(data === 'true'){ - alert( ); + alert( ); if($('#hidden-old_name_profile').val()){ $('#text-name').val($('#hidden-old_name_profile').val()); }else{ From 14b884b53d573ccae6114ef3baa10c0d7fef7301 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 15 Dec 2022 15:37:46 +0100 Subject: [PATCH 3/4] Trim duplicate profile before post to save --- pandora_console/godmode/users/configure_profile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora_console/godmode/users/configure_profile.php b/pandora_console/godmode/users/configure_profile.php index a37df6bb5e..004aabd6ca 100644 --- a/pandora_console/godmode/users/configure_profile.php +++ b/pandora_console/godmode/users/configure_profile.php @@ -439,7 +439,7 @@ enterprise_hook('close_meta_frame'); data: { page: 'include/ajax/profile', search_profile_nanme: true, - profile_name: $('#text-name').val(), + profile_name: $('#text-name').val().trim(), }, success: function (data) { if(data === 'true'){ From 97c967ede8deb6edc3a783a3c81cceabee2e5c5e Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 16 Dec 2022 09:53:10 +0100 Subject: [PATCH 4/4] Disable enter on profiles create/edit for duplicate profile name check --- pandora_console/godmode/users/configure_profile.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandora_console/godmode/users/configure_profile.php b/pandora_console/godmode/users/configure_profile.php index 004aabd6ca..70342f1fea 100644 --- a/pandora_console/godmode/users/configure_profile.php +++ b/pandora_console/godmode/users/configure_profile.php @@ -426,6 +426,14 @@ enterprise_hook('close_meta_frame'); $(id).css({'cursor':'not-allowed', 'opacity':'0.5'}); }); } + + //Not enable enter for prevent submits + $(window).keydown(function(event){ + if(event.keyCode == 13) { + event.preventDefault(); + return false; + } + }); }); $('#text-name').on('blur',function(){