From ce5934b9a1aa5984f0e2847f59704877e55108e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Gonz=C3=A1lez?= Date: Thu, 6 May 2021 14:46:58 +0200 Subject: [PATCH] Added form-type buttons for user-actions --- pandora_console/godmode/users/user_list.php | 132 ++++++++++++++++-- pandora_console/include/functions_html.php | 2 + pandora_console/operation/users/user_edit.php | 2 +- 3 files changed, 122 insertions(+), 14 deletions(-) diff --git a/pandora_console/godmode/users/user_list.php b/pandora_console/godmode/users/user_list.php index 5134ad0a0b..fd4507f739 100644 --- a/pandora_console/godmode/users/user_list.php +++ b/pandora_console/godmode/users/user_list.php @@ -233,8 +233,7 @@ if (defined('METACONSOLE')) { $disable_user = get_parameter('disable_user', false); - -if (isset($_GET['user_del'])) { +if ((bool) get_parameter('user_del', false) === true) { // delete user $id_user = get_parameter('delete_user', 0); // Only allow delete user if is not the actual user @@ -312,13 +311,13 @@ if (isset($_GET['user_del'])) { $result = false; } - if ($disable_user == 1) { + if ($disable_user === 1) { ui_print_result_message( $result, __('Successfully disabled'), __('There was a problem disabling user') ); - } else { + } else if ($disable_user === 0) { ui_print_result_message( $result, __('Successfully enabled'), @@ -558,7 +557,7 @@ foreach ($info as $user_id => $user_info) { $iterator++; if ($user_is_admin || $config['id_user'] == $user_info['id_user'] || (!$user_info['is_admin'] && (!isset($user_info['edit']) || isset($group_um[0]) || (isset($user_info['edit']) && $user_info['edit'])))) { - $data[0] = ''.$user_id.''; + $data[0] = ''.$user_id.''; } else { $data[0] = $user_id; } @@ -638,19 +637,126 @@ foreach ($info as $user_id => $user_info) { $table->cellclass[][6] = 'action_buttons'; $data[6] = ''; if ($user_is_admin || $config['id_user'] == $user_info['id_user'] || isset($group_um[0]) || (!$user_info['is_admin'] && (!isset($user_info['edit']) || (isset($user_info['edit']) && $user_info['edit'])))) { - if (!isset($user_info['not_delete'])) { + // Disable / Enable user. + if (isset($user_info['not_delete']) === false) { if ($user_info['disabled'] == 0) { - $data[6] = ''.html_print_image('images/lightbulb.png', true, ['title' => __('Disable'), 'class' => 'invert_filter']).''; + $toDoString = __('Disable'); + $toDoAction = '1'; + $toDoImage = 'images/lightbulb.png'; } else { - $data[6] = ''.html_print_image('images/lightbulb_off.png', true, ['title' => __('Enable')]).''; + $toDoString = __('Enable'); + $toDoAction = '0'; + $toDoImage = 'images/lightbulb_off.png'; } + + $data[6] = '
'; + $data[6] .= html_print_input_hidden( + 'id', + $user_info['id_user'], + true + ); + $data[6] .= html_print_input_hidden( + 'disable_user', + $toDoAction, + true + ); + $data[6] .= html_print_input_image( + 'submit_disable_enable', + $toDoImage, + '', + '', + true, + [ + 'data-title' => $toDoString, + 'data-use_title_for_force_title' => '1', + 'class' => 'forced_title no-padding', + ] + ); + $data[6] .= '
'; } - $data[6] .= ''.html_print_image('images/config.png', true, ['title' => __('Edit'), 'class' => 'invert_filter']).''; - if ($config['admin_can_delete_user'] && $user_info['id_user'] != $config['id_user'] && !isset($user_info['not_delete'])) { - $data[6] .= "".html_print_image('images/cross.png', true, ['class' => 'invert_filter', 'title' => __('Delete'), 'onclick' => "if (! confirm ('".__('Deleting User').' '.$user_info['id_user'].'. '.__('Are you sure?')."')) return false"]).''; - if (defined('METACONSOLE')) { - $data[6] .= "".html_print_image('images/cross_double.png', true, ['class' => 'invert_filter', 'title' => __('Delete from all consoles'), 'onclick' => "if (! confirm ('".__('Deleting User %s from all consoles', $user_info['id_user']).'. '.__('Are you sure?')."')) return false"]).''; + // Edit user. + $data[6] .= '
'; + $data[6] .= html_print_input_hidden( + 'id_user', + $user_info['id_user'], + true + ); + $data[6] .= html_print_input_hidden( + 'edit_user', + '1', + true + ); + $data[6] .= html_print_input_image( + 'submit_edit_user', + 'images/config.png', + '', + 'padding:0', + true, + [ + 'data-title' => __('Edit'), + 'data-use_title_for_force_title' => '1', + 'class' => 'forced_title no-padding', + ] + ); + $data[6] .= '
'; + + if ($config['admin_can_delete_user'] && $user_info['id_user'] != $config['id_user'] && isset($user_info['not_delete']) === false) { + $data[6] .= '
'; + $data[6] .= html_print_input_hidden( + 'delete_user', + $user_info['id_user'], + true + ); + $data[6] .= html_print_input_hidden( + 'user_del', + '1', + true + ); + $data[6] .= html_print_input_image( + 'submit_delete_user', + 'images/cross.png', + '', + 'padding:0', + true, + [ + 'data-title' => __('Delete'), + 'data-use_title_for_force_title' => '1', + 'class' => 'forced_title no-padding', + ] + ); + $data[6] .= '
'; + + if (is_metaconsole() === true) { + $data[6] .= '
'; + $data[6] .= html_print_input_hidden( + 'delete_user', + $user_info['id_user'], + true + ); + $data[6] .= html_print_input_hidden( + 'user_del', + '1', + true + ); + $data[6] .= html_print_input_hidden( + 'delete_all', + '1', + true + ); + $data[6] .= html_print_input_image( + 'submit_delete_all', + 'images/cross_double.png', + '', + '', + true, + [ + 'data-title' => __('Delete from all consoles'), + 'data-use_title_for_force_title' => '1', + 'class' => 'forced_title no-padding', + ] + ); + $data[6] .= '
'; } } else { $data[6] .= ''; diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index e80fa6f9fd..0a9c3217ab 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -2698,6 +2698,8 @@ function html_print_input_image($name, $src, $value, $style='', $return=false, $ 'lang', 'tabindex', 'title', + 'data-title', + 'data-use_title_for_force_title', 'xml:lang', 'onclick', 'ondblclick', diff --git a/pandora_console/operation/users/user_edit.php b/pandora_console/operation/users/user_edit.php index 8b67ba53ab..435e6b7a85 100644 --- a/pandora_console/operation/users/user_edit.php +++ b/pandora_console/operation/users/user_edit.php @@ -644,7 +644,7 @@ foreach ($timezones as $timezone_name => $tz) { } if (is_metaconsole()) { - echo '
'; + echo ''; } else { echo ''; }