#12219 Fix icons and metaconsole delete profile
This commit is contained in:
parent
c77686807f
commit
d2390979aa
|
@ -158,92 +158,84 @@ if (is_ajax() === true) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ($delete_profile) {
|
||||
$id2 = (string) get_parameter('id_user');
|
||||
if ($delete_profile === true) {
|
||||
// Get parameters.
|
||||
$result = false;
|
||||
$id_user = (string) get_parameter('id_user');
|
||||
$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);
|
||||
$id_perfil = $perfilUser['id_perfil'];
|
||||
$perfil = db_get_row('tperfil', 'id_perfil', $id_perfil);
|
||||
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_USER_MANAGEMENT,
|
||||
'Deleted profile for user '.io_safe_output($id2),
|
||||
'Deleted profile for user '.io_safe_output($id_user),
|
||||
false,
|
||||
false,
|
||||
'The profile with id '.$id_perfil.' in the group '.$perfilUser['id_grupo']
|
||||
);
|
||||
// Delete profile.
|
||||
$profile_deleted = profile_delete_user_profile($id_user, $id_up);
|
||||
// Check if exists more profiles.
|
||||
$has_profile = db_get_row('tusuario_perfil', 'id_usuario', $id_user);
|
||||
if ($profile_deleted === true) {
|
||||
if ($has_profile === false && $user_is_global_admin === false && $delete_user === true) {
|
||||
if (is_metaconsole() === true) {
|
||||
$servers = metaconsole_get_servers();
|
||||
foreach ($servers as $server) {
|
||||
// Connect to the remote console.
|
||||
metaconsole_connect($server);
|
||||
|
||||
$return = profile_delete_user_profile($id2, $id_up);
|
||||
ui_print_result_message(
|
||||
$return,
|
||||
__('Successfully deleted'),
|
||||
__('Could not be deleted')
|
||||
);
|
||||
// Delete the user.
|
||||
$result = delete_user($id_user);
|
||||
if ($result === true) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_USER_MANAGEMENT,
|
||||
__('Deleted user %s from metaconsole', io_safe_output($id_user))
|
||||
);
|
||||
}
|
||||
|
||||
// Restore the db connection.
|
||||
metaconsole_restore_db();
|
||||
|
||||
$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);
|
||||
// Log to the metaconsole too.
|
||||
if ($result === true) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_USER_MANAGEMENT,
|
||||
__(
|
||||
'Deleted user %s from %s',
|
||||
io_safe_input($id_user),
|
||||
io_safe_input($server['server_name'])
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($has_profile === false && $user_is_global_admin === false && $delete_user_profile === true) {
|
||||
$result = delete_user($id2);
|
||||
$result = delete_user((string) $id_user);
|
||||
|
||||
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) {
|
||||
$servers = metaconsole_get_servers();
|
||||
foreach ($servers as $server) {
|
||||
// Connect to the remote console.
|
||||
metaconsole_connect($server);
|
||||
|
||||
// Delete the user.
|
||||
$result = delete_user($id_user);
|
||||
if ($result === true) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_USER_MANAGEMENT,
|
||||
__('Deleted user %s from metaconsole', io_safe_output($id_user))
|
||||
__('Deleted user %s', io_safe_output($id_user))
|
||||
);
|
||||
}
|
||||
|
||||
// Restore the db connection.
|
||||
metaconsole_restore_db();
|
||||
|
||||
// Log to the metaconsole too.
|
||||
} else {
|
||||
$result = delete_user((string) $id_user);
|
||||
if ($result === true) {
|
||||
db_pandora_audit(
|
||||
AUDIT_LOG_USER_MANAGEMENT,
|
||||
__(
|
||||
'Deleted user %s from %s',
|
||||
io_safe_input($id_user),
|
||||
io_safe_input($server['server_name'])
|
||||
)
|
||||
__('Deleted user %s', io_safe_output($id_user))
|
||||
);
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('Successfully deleted from %s', io_safe_input($server['server_name'])),
|
||||
__('There was a problem deleting the user from %s', io_safe_input($server['server_name']))
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$result = $profile_deleted;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
return $return;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2014,7 +2006,7 @@ if (is_metaconsole() === false) {
|
|||
id_user_profile = id_user_profile[1].value;
|
||||
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")
|
||||
.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.'); ?>");
|
||||
|
@ -2061,7 +2053,7 @@ if (is_metaconsole() === false) {
|
|||
}
|
||||
});
|
||||
} 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?'); ?>')) {
|
||||
return false;
|
||||
} else {
|
||||
|
@ -2080,11 +2072,10 @@ if (is_metaconsole() === false) {
|
|||
});
|
||||
|
||||
function delete_user_profile(id_user_profile, row, id_user, deleteuser){
|
||||
|
||||
var params = [];
|
||||
params.push("delete_profile=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_profile=" + id_user_profile);
|
||||
params.push("page=godmode/users/configure_user");
|
||||
|
@ -2095,10 +2086,9 @@ if (is_metaconsole() === false) {
|
|||
success: function(data) {
|
||||
row.remove();
|
||||
var rows = $("#table_profiles tr").length;
|
||||
|
||||
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); ?>");
|
||||
} 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); ?>");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -308,7 +308,7 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c
|
|||
'del',
|
||||
'images/delete.svg',
|
||||
1,
|
||||
'',
|
||||
'background-color: transparent !important;',
|
||||
true,
|
||||
[
|
||||
'onclick' => 'delete_profile(event, this)',
|
||||
|
@ -317,7 +317,14 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c
|
|||
);
|
||||
} else {
|
||||
$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('id_user_profile', $profile['id_up'], 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_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('add_profile', 1, true);
|
||||
$data['last_actions'] .= '</form>';
|
||||
|
|
Loading…
Reference in New Issue