Added form-type buttons for user-actions

This commit is contained in:
José González 2021-05-06 14:46:58 +02:00
parent 0308fdbdc2
commit ce5934b9a1
3 changed files with 122 additions and 14 deletions

View File

@ -233,8 +233,7 @@ if (defined('METACONSOLE')) {
$disable_user = get_parameter('disable_user', false); $disable_user = get_parameter('disable_user', false);
if ((bool) get_parameter('user_del', false) === true) {
if (isset($_GET['user_del'])) {
// delete user // delete user
$id_user = get_parameter('delete_user', 0); $id_user = get_parameter('delete_user', 0);
// Only allow delete user if is not the actual user // Only allow delete user if is not the actual user
@ -312,13 +311,13 @@ if (isset($_GET['user_del'])) {
$result = false; $result = false;
} }
if ($disable_user == 1) { if ($disable_user === 1) {
ui_print_result_message( ui_print_result_message(
$result, $result,
__('Successfully disabled'), __('Successfully disabled'),
__('There was a problem disabling user') __('There was a problem disabling user')
); );
} else { } else if ($disable_user === 0) {
ui_print_result_message( ui_print_result_message(
$result, $result,
__('Successfully enabled'), __('Successfully enabled'),
@ -558,7 +557,7 @@ foreach ($info as $user_id => $user_info) {
$iterator++; $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'])))) { 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] = '<a href="index.php?sec='.$sec.'&amp;sec2=godmode/users/configure_user&pure='.$pure.'&amp;id='.$user_id.'">'.$user_id.'</a>'; $data[0] = '<a href="#" onclick="document.forms[\'edit_user_form_'.$user_info['id_user'].'\'].submit();">'.$user_id.'</a>';
} else { } else {
$data[0] = $user_id; $data[0] = $user_id;
} }
@ -638,19 +637,126 @@ foreach ($info as $user_id => $user_info) {
$table->cellclass[][6] = 'action_buttons'; $table->cellclass[][6] = 'action_buttons';
$data[6] = ''; $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 ($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) { if ($user_info['disabled'] == 0) {
$data[6] = '<a href="index.php?sec='.$sec.'&amp;sec2=godmode/users/user_list&amp;disable_user=1&pure='.$pure.'&amp;id='.$user_info['id_user'].'">'.html_print_image('images/lightbulb.png', true, ['title' => __('Disable'), 'class' => 'invert_filter']).'</a>'; $toDoString = __('Disable');
$toDoAction = '1';
$toDoImage = 'images/lightbulb.png';
} else { } else {
$data[6] = '<a href="index.php?sec='.$sec.'&amp;sec2=godmode/users/user_list&amp;disable_user=0&pure='.$pure.'&amp;id='.$user_info['id_user'].'">'.html_print_image('images/lightbulb_off.png', true, ['title' => __('Enable')]).'</a>'; $toDoString = __('Enable');
} $toDoAction = '0';
$toDoImage = 'images/lightbulb_off.png';
} }
$data[6] .= '<a href="index.php?sec='.$sec.'&amp;sec2=godmode/users/configure_user&pure='.$pure.'&amp;id='.$user_id.'">'.html_print_image('images/config.png', true, ['title' => __('Edit'), 'class' => 'invert_filter']).'</a>'; $data[6] = '<form method="POST" action="index.php?sec='.$sec.'&amp;sec2=godmode/users/user_list&amp;pure='.$pure.'" class="inline">';
if ($config['admin_can_delete_user'] && $user_info['id_user'] != $config['id_user'] && !isset($user_info['not_delete'])) { $data[6] .= html_print_input_hidden(
$data[6] .= "<a href='index.php?sec=".$sec.'&sec2=godmode/users/user_list&user_del=1&pure='.$pure.'&delete_user='.$user_info['id_user']."'>".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"]).'</a>'; 'id',
if (defined('METACONSOLE')) { $user_info['id_user'],
$data[6] .= "<a href='index.php?sec=".$sec.'&sec2=godmode/users/user_list&user_del=1&pure='.$pure.'&delete_user='.$user_info['id_user']."&delete_all=1'>".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"]).'</a>'; 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] .= '</form>';
}
// Edit user.
$data[6] .= '<form method="POST" action="index.php?sec='.$sec.'&amp;sec2=godmode/users/configure_user&pure='.$pure.'" id="edit_user_form_'.$user_info['id_user'].'" class="inline">';
$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] .= '</form>';
if ($config['admin_can_delete_user'] && $user_info['id_user'] != $config['id_user'] && isset($user_info['not_delete']) === false) {
$data[6] .= '<form method="POST" action="index.php?sec='.$sec.'&amp;sec2=godmode/users/user_list&amp;pure='.$pure.'" class="inline">';
$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] .= '</form>';
if (is_metaconsole() === true) {
$data[6] .= '<form method="POST" action="index.php?sec='.$sec.'&amp;sec2=godmode/users/user_list&amp;pure='.$pure.'" class="inline">';
$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] .= '</form>';
} }
} else { } else {
$data[6] .= ''; $data[6] .= '';

View File

@ -2698,6 +2698,8 @@ function html_print_input_image($name, $src, $value, $style='', $return=false, $
'lang', 'lang',
'tabindex', 'tabindex',
'title', 'title',
'data-title',
'data-use_title_for_force_title',
'xml:lang', 'xml:lang',
'onclick', 'onclick',
'ondblclick', 'ondblclick',

View File

@ -644,7 +644,7 @@ foreach ($timezones as $timezone_name => $tz) {
} }
if (is_metaconsole()) { if (is_metaconsole()) {
echo '<form name="user_mod" method="post" action="'.ui_get_full_url('index.php?sec=advanced&sec2=advanced/users_setup').'&amp;tab=user_edit&amp;modified=1&amp;id='.$id.'&amp;pure='.$config['pure'].'">'; echo '<form name="user_mod" method="post" action="'.ui_get_full_url('index.php?sec=advanced&sec2=advanced/users_setup').'&amp;tab=user_edit&amp;modified=1&amp;pure='.$config['pure'].'">';
} else { } else {
echo '<form name="user_mod" method="post" action="'.ui_get_full_url('index.php?sec=workspace&sec2=operation/users/user_edit').'&amp;modified=1&amp;pure='.$config['pure'].'">'; echo '<form name="user_mod" method="post" action="'.ui_get_full_url('index.php?sec=workspace&sec2=operation/users/user_edit').'&amp;modified=1&amp;pure='.$config['pure'].'">';
} }