#12219 Fix icons and metaconsole delete profile
This commit is contained in:
parent
c77686807f
commit
d2390979aa
|
@ -158,50 +158,30 @@ if (is_ajax() === true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($delete_profile) {
|
if ($delete_profile === true) {
|
||||||
$id2 = (string) get_parameter('id_user');
|
// Get parameters.
|
||||||
|
$result = false;
|
||||||
|
$id_user = (string) get_parameter('id_user');
|
||||||
$id_up = (int) get_parameter('id_user_profile');
|
$id_up = (int) get_parameter('id_user_profile');
|
||||||
|
$delete_user = (bool) get_parameter('delete_user', false);
|
||||||
|
$user_is_global_admin = users_is_admin($id_user);
|
||||||
|
|
||||||
$perfilUser = db_get_row('tusuario_perfil', 'id_up', $id_up);
|
$perfilUser = db_get_row('tusuario_perfil', 'id_up', $id_up);
|
||||||
$id_perfil = $perfilUser['id_perfil'];
|
$id_perfil = $perfilUser['id_perfil'];
|
||||||
$perfil = db_get_row('tperfil', 'id_perfil', $id_perfil);
|
|
||||||
|
|
||||||
db_pandora_audit(
|
db_pandora_audit(
|
||||||
AUDIT_LOG_USER_MANAGEMENT,
|
AUDIT_LOG_USER_MANAGEMENT,
|
||||||
'Deleted profile for user '.io_safe_output($id2),
|
'Deleted profile for user '.io_safe_output($id_user),
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
'The profile with id '.$id_perfil.' in the group '.$perfilUser['id_grupo']
|
'The profile with id '.$id_perfil.' in the group '.$perfilUser['id_grupo']
|
||||||
);
|
);
|
||||||
|
// Delete profile.
|
||||||
$return = profile_delete_user_profile($id2, $id_up);
|
$profile_deleted = profile_delete_user_profile($id_user, $id_up);
|
||||||
ui_print_result_message(
|
// Check if exists more profiles.
|
||||||
$return,
|
$has_profile = db_get_row('tusuario_perfil', 'id_usuario', $id_user);
|
||||||
__('Successfully deleted'),
|
if ($profile_deleted === true) {
|
||||||
__('Could not be deleted')
|
if ($has_profile === false && $user_is_global_admin === false && $delete_user === true) {
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
$has_profile = db_get_row('tusuario_perfil', 'id_usuario', $id2);
|
|
||||||
$user_is_global_admin = users_is_admin($id2);
|
|
||||||
$delete_user_profile = (bool) get_parameter('delete_user_profile', false);
|
|
||||||
|
|
||||||
if ($has_profile === false && $user_is_global_admin === false && $delete_user_profile === true) {
|
|
||||||
$result = delete_user($id2);
|
|
||||||
|
|
||||||
if ($result === true) {
|
|
||||||
db_pandora_audit(
|
|
||||||
AUDIT_LOG_USER_MANAGEMENT,
|
|
||||||
__('Deleted user %s', io_safe_output($id_user))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
ui_print_result_message(
|
|
||||||
$result,
|
|
||||||
__('Successfully deleted'),
|
|
||||||
__('There was a problem deleting the user')
|
|
||||||
);
|
|
||||||
|
|
||||||
// Delete the user in all the consoles.
|
|
||||||
if (is_metaconsole() === true) {
|
if (is_metaconsole() === true) {
|
||||||
$servers = metaconsole_get_servers();
|
$servers = metaconsole_get_servers();
|
||||||
foreach ($servers as $server) {
|
foreach ($servers as $server) {
|
||||||
|
@ -231,20 +211,32 @@ if (is_ajax() === true) {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ui_print_result_message(
|
$result = delete_user((string) $id_user);
|
||||||
$result,
|
|
||||||
__('Successfully deleted from %s', io_safe_input($server['server_name'])),
|
if ($result === true) {
|
||||||
__('There was a problem deleting the user from %s', io_safe_input($server['server_name']))
|
db_pandora_audit(
|
||||||
|
AUDIT_LOG_USER_MANAGEMENT,
|
||||||
|
__('Deleted user %s', io_safe_output($id_user))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$result = delete_user((string) $id_user);
|
||||||
|
if ($result === true) {
|
||||||
|
db_pandora_audit(
|
||||||
|
AUDIT_LOG_USER_MANAGEMENT,
|
||||||
|
__('Deleted user %s', io_safe_output($id_user))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$result = $profile_deleted;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$tab = get_parameter('tab', 'user');
|
$tab = get_parameter('tab', 'user');
|
||||||
|
@ -2014,7 +2006,7 @@ if (is_metaconsole() === false) {
|
||||||
id_user_profile = id_user_profile[1].value;
|
id_user_profile = id_user_profile[1].value;
|
||||||
var row = $(this).closest('tr');
|
var row = $(this).closest('tr');
|
||||||
|
|
||||||
if (((is_metaconsole === '1' && rows <= 4) || (is_metaconsole !== '1' && rows <= 3)) && user_is_global_admin !== '1') {
|
if (((is_metaconsole === '1' && rows <= 3) || (is_metaconsole !== '1' && rows <= 3)) && user_is_global_admin !== '1') {
|
||||||
$("#delete_profile_modal")
|
$("#delete_profile_modal")
|
||||||
.empty()
|
.empty()
|
||||||
.html("<?php echo __('Deleting this profile will leave your user without a profile or group. You can continue by deleting the user or preserving it.'); ?>");
|
.html("<?php echo __('Deleting this profile will leave your user without a profile or group. You can continue by deleting the user or preserving it.'); ?>");
|
||||||
|
@ -2061,7 +2053,7 @@ if (is_metaconsole() === false) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (((is_metaconsole === '1' && rows <= 4) || (is_metaconsole === '' && rows <= 3)) && user_is_global_admin !== '1') {
|
if (((is_metaconsole === '1' && rows <= 3) || (is_metaconsole === '' && rows <= 3)) && user_is_global_admin !== '1') {
|
||||||
if (!confirm('<?php echo __('Deleting last profile will delete this user'); ?>' + '. ' + '<?php echo __('Are you sure?'); ?>')) {
|
if (!confirm('<?php echo __('Deleting last profile will delete this user'); ?>' + '. ' + '<?php echo __('Are you sure?'); ?>')) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2080,11 +2072,10 @@ if (is_metaconsole() === false) {
|
||||||
});
|
});
|
||||||
|
|
||||||
function delete_user_profile(id_user_profile, row, id_user, deleteuser){
|
function delete_user_profile(id_user_profile, row, id_user, deleteuser){
|
||||||
|
|
||||||
var params = [];
|
var params = [];
|
||||||
params.push("delete_profile=1");
|
params.push("delete_profile=1");
|
||||||
params.push("edit_user=1");
|
params.push("edit_user=1");
|
||||||
params.push("delete_user_profile=" + deleteuser);
|
params.push("delete_user=" + deleteuser);
|
||||||
params.push("id_user=" + id_user);
|
params.push("id_user=" + id_user);
|
||||||
params.push("id_user_profile=" + id_user_profile);
|
params.push("id_user_profile=" + id_user_profile);
|
||||||
params.push("page=godmode/users/configure_user");
|
params.push("page=godmode/users/configure_user");
|
||||||
|
@ -2095,10 +2086,9 @@ if (is_metaconsole() === false) {
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
row.remove();
|
row.remove();
|
||||||
var rows = $("#table_profiles tr").length;
|
var rows = $("#table_profiles tr").length;
|
||||||
|
|
||||||
if (is_metaconsole === '' && rows <= 2 && user_is_global_admin !== '1' && deleteuser == '1') {
|
if (is_metaconsole === '' && rows <= 2 && user_is_global_admin !== '1' && deleteuser == '1') {
|
||||||
window.location.replace("<?php echo ui_get_full_url('index.php?sec=gusuarios&sec2=godmode/users/user_list&tab=user&pure=0', false, false, false); ?>");
|
window.location.replace("<?php echo ui_get_full_url('index.php?sec=gusuarios&sec2=godmode/users/user_list&tab=user&pure=0', false, false, false); ?>");
|
||||||
} else if (is_metaconsole === '1' && rows <= 3 && user_is_global_admin !== '1') {
|
} else if (is_metaconsole === '1' && rows <= 2 && user_is_global_admin !== '1' && deleteuser == '1') {
|
||||||
window.location.replace("<?php echo ui_get_full_url('index.php?sec=advanced&sec2=advanced/users_setup', false, false, true); ?>");
|
window.location.replace("<?php echo ui_get_full_url('index.php?sec=advanced&sec2=advanced/users_setup', false, false, true); ?>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -308,7 +308,7 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c
|
||||||
'del',
|
'del',
|
||||||
'images/delete.svg',
|
'images/delete.svg',
|
||||||
1,
|
1,
|
||||||
'',
|
'background-color: transparent !important;',
|
||||||
true,
|
true,
|
||||||
[
|
[
|
||||||
'onclick' => 'delete_profile(event, this)',
|
'onclick' => 'delete_profile(event, this)',
|
||||||
|
@ -317,7 +317,14 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$data['actions'] = '<form method="post" onsubmit="">';
|
$data['actions'] = '<form method="post" onsubmit="">';
|
||||||
$data['actions'] .= html_print_input_image('del', 'images/delete.svg', 1, '', true, ['class' => 'main_menu_icon invert_filter']);
|
$data['actions'] .= html_print_input_image(
|
||||||
|
'del',
|
||||||
|
'images/delete.svg',
|
||||||
|
1,
|
||||||
|
'background-color: transparent !important;',
|
||||||
|
true,
|
||||||
|
['class' => 'main_menu_icon invert_filter']
|
||||||
|
);
|
||||||
$data['actions'] .= html_print_input_hidden('delete_profile', 1, 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_profile', $profile['id_up'], true);
|
||||||
$data['actions'] .= html_print_input_hidden('id_user', $id, true);
|
$data['actions'] .= html_print_input_hidden('id_user', $id, true);
|
||||||
|
@ -391,7 +398,14 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c
|
||||||
|
|
||||||
$data['last_hierarchy'] = html_print_checkbox('no_hierarchy', 1, false, true);
|
$data['last_hierarchy'] = html_print_checkbox('no_hierarchy', 1, false, true);
|
||||||
|
|
||||||
$data['last_actions'] = html_print_input_image('add', 'images/validate.svg', 1, '', true, ['class' => 'main_menu_icon invert_filter']);
|
$data['last_actions'] = html_print_input_image(
|
||||||
|
'add',
|
||||||
|
'images/validate.svg',
|
||||||
|
1,
|
||||||
|
'background-color: transparent !important;',
|
||||||
|
true,
|
||||||
|
['class' => 'main_menu_icon invert_filter']
|
||||||
|
);
|
||||||
$data['last_actions'] .= html_print_input_hidden('id', $id, true);
|
$data['last_actions'] .= html_print_input_hidden('id', $id, true);
|
||||||
$data['last_actions'] .= html_print_input_hidden('add_profile', 1, true);
|
$data['last_actions'] .= html_print_input_hidden('add_profile', 1, true);
|
||||||
$data['last_actions'] .= '</form>';
|
$data['last_actions'] .= '</form>';
|
||||||
|
|
Loading…
Reference in New Issue