#9903 Duplicate control profile

This commit is contained in:
Jonathan 2022-12-09 11:37:08 +01:00
parent f2ad934c92
commit 0b6d1a7840
2 changed files with 64 additions and 4 deletions

View File

@ -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');
?>
<script type="text/javascript" language="javascript">
<script type="text/javascript" language="javascript">
$(document).ready (function () {
var disable_option = '<?php echo $disable_option; ?>';
if (disable_option != '') {
var ids = ['#checkbox-db_management', '#checkbox-user_management', '#checkbox-pandora_management'];
if (disable_option != '') {
var ids = ['#checkbox-db_management', '#checkbox-user_management', '#checkbox-pandora_management'];
ids.forEach(id => {
$(id).css({'cursor':'not-allowed', 'opacity':'0.5'});
});
}
}
});
$('#text-name').on('blur',function(){
/* Check if the name is already on use for new profiles or check if the
name is already on use for update checking if the name is distinct of the original*/
if($('#hidden-create_profile').val()==1 || ($('#hidden-update_profile').val()==1 && $('#hidden-old_name_profile').val()!=$('#text-name').val())){
$.ajax({
type: "POST",
url: "ajax.php",
dataType: "html",
data: {
page: 'include/ajax/profile',
search_profile_nanme: true,
profile_name: $('#text-name').val(),
},
success: function (data) {
if(data === 'true'){
alert( <?php echo "'".__('Profile name already on use, please, change the name before safe')."'"; ?> );
if($('#hidden-old_name_profile').val()){
$('#text-name').val($('#hidden-old_name_profile').val());
}else{
$('#text-name').val("");
}
}
},
error: function (data) {
console.error("Fatal error in AJAX call to interpreter order", data)
}
});
}
});
</script>

View File

@ -0,0 +1,29 @@
<?php
// Pandora FMS- http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
global $config;
require_once $config['homedir'].'/include/functions_profile.php';
// Clean the possible blanks introduced by the included files.
ob_clean();
$search_profile_name = (bool) get_parameter('search_profile_nanme');
if ($search_profile_name) {
$profile_name = (string) get_parameter('profile_name');
echo json_encode(profile_exist($profile_name));
return;
}