Merge branch 'ent-9903-no-permitir-nombres-de-perfiles-duplicados' into 'develop'
Ent 9903 no permitir nombres de perfiles duplicados See merge request artica/pandorafms!5321
This commit is contained in:
commit
6b4bc8b9b0
|
@ -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,53 @@ 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'});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//Not enable enter for prevent submits
|
||||
$(window).keydown(function(event){
|
||||
if(event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#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().trim(),
|
||||
},
|
||||
success: function (data) {
|
||||
if(data === 'true'){
|
||||
alert( <?php echo "'".__('Profile name already on use, please, change the name before save')."'"; ?> );
|
||||
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>
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue