Fixed users list view

This commit is contained in:
Jose Gonzalez 2023-01-30 16:14:05 +01:00
parent 0162767f6d
commit 891e485781
4 changed files with 173 additions and 88 deletions

View File

@ -80,13 +80,24 @@ if (is_metaconsole() === false) {
$buttons[$tab]['active'] = true; $buttons[$tab]['active'] = true;
ui_print_page_header( // Header.
__('User management').' » '.__('Profiles defined on %s', get_product_name()), ui_print_standard_header(
__('User Profile management'),
'images/gm_users.png', 'images/gm_users.png',
false, false,
'profile_tab', 'profile_tab',
true, false,
$buttons $buttons,
[
[
'link' => '',
'label' => __('Profiles'),
],
[
'link' => '',
'label' => __('Manage users'),
],
]
); );
$sec = 'gusuarios'; $sec = 'gusuarios';
} else { } else {

View File

@ -14,7 +14,7 @@
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
* *
* ============================================================================ * ============================================================================
* Copyright (c) 2005-2021 Artica Soluciones Tecnologicas * Copyright (c) 2005-2023 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list * Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -285,13 +285,24 @@ if (is_metaconsole() === true) {
$buttons[$tab]['active'] = true; $buttons[$tab]['active'] = true;
ui_print_page_header( // Header.
__('User management').' » '.__('Users defined on %s', get_product_name()), ui_print_standard_header(
__('Users management'),
'images/gm_users.png', 'images/gm_users.png',
false, false,
'', '',
true, false,
$buttons $buttons,
[
[
'link' => '',
'label' => __('Profiles'),
],
[
'link' => '',
'label' => __('Manage users'),
],
]
); );
$sec = 'gusuarios'; $sec = 'gusuarios';
@ -443,12 +454,14 @@ if (($filter_group == 0) && ($filter_search == '')) {
$search = false; $search = false;
} }
$table = new stdClass(); $filterTable = new stdClass();
$table->width = '100%'; $filterTable->width = '100%';
$table->class = 'databox filters'; $filterTable->class = 'fixed_filter_bar';
$table->rowclass[0] = ''; $filterTable->rowclass[0] = '';
$table->data[0][0] = '<b>'.__('Group').'</b>'; $filterTable->cellstyle[0][0] = 'width:0';
$table->data[0][1] = html_print_select_groups( $filterTable->cellstyle[0][1] = 'width:0';
$filterTable->data[0][0] = __('Group');
$filterTable->data[1][0] = html_print_select_groups(
false, false,
'AR', 'AR',
true, true,
@ -459,8 +472,8 @@ $table->data[0][1] = html_print_select_groups(
0, 0,
true true
); );
$table->data[0][2] = '<b>'.__('Search').'</b>'.ui_print_help_tip(__('Search by username, fullname or email'), true); $filterTable->data[0][1] = __('Search').ui_print_help_tip(__('Search by username, fullname or email'), true);
$table->data[0][3] = html_print_input_text( $filterTable->data[1][1] = html_print_input_text(
'filter_search', 'filter_search',
$filter_search, $filter_search,
__('Search by username, fullname or email'), __('Search by username, fullname or email'),
@ -468,11 +481,16 @@ $table->data[0][3] = html_print_input_text(
90, 90,
true true
); );
$table->data[0][4] = html_print_submit_button( $filterTable->cellstyle[1][2] = 'vertical-align: bottom';
$filterTable->data[1][2] = html_print_submit_button(
__('Search'), __('Search'),
'search', 'search',
false, false,
['class' => 'sub search'], [
'icon' => 'search',
'class' => 'float-right',
'mode' => 'secondary mini',
],
true true
); );
@ -497,22 +515,16 @@ if (is_metaconsole() === false && is_management_allowed() === false) {
if (is_metaconsole() === true) { if (is_metaconsole() === true) {
$table->width = '96%'; $filterTable->width = '96%';
$form_filter = "<form class='filters_form' method='post'>"; $form_filter = "<form class='filters_form' method='post'>";
$form_filter .= html_print_table($table, true); $form_filter .= html_print_table($filterTable, true);
$form_filter .= '</form>'; $form_filter .= '</form>';
ui_toggle($form_filter, __('Show Options')); ui_toggle($form_filter, __('Show Options'));
} else { } else {
$form_filter = "<form method='post'>"; $form_filter = "<form method='post'>";
$form_filter .= html_print_table($table, true); $form_filter .= html_print_table($filterTable, true);
$form_filter .= '</form>'; $form_filter .= '</form>';
ui_toggle( echo $form_filter;
$form_filter,
__('Users control filter'),
__('Toggle filter(s)'),
'',
!$search
);
} }
// Urls to sort the table. // Urls to sort the table.
@ -527,8 +539,9 @@ $url_down_last = '?sec='.$sec.'&sec2=godmode/users/user_list&sort_field=last_con
$table = new stdClass(); $table = new stdClass();
$table->cellpadding = 0; $table->cellpadding = 0;
$table->cellspacing = 0; $table->cellspacing = 0;
$table->width = '100%'; $table->class = 'info_table tactical_table';
$table->class = 'info_table'; $table->id = 'user_list';
$table->styleTable = 'margin: 0 10px';
$table->head = []; $table->head = [];
$table->data = []; $table->data = [];
@ -536,15 +549,18 @@ $table->align = [];
$table->size = []; $table->size = [];
$table->valign = []; $table->valign = [];
$table->head[0] = __('User ID').ui_get_sorting_arrows($url_up_id, $url_down_id, $selectUserIDUp, $selectUserIDDown); $table->head[0] = '<span>'.__('User ID').'</span>';
$table->head[1] = __('Name').ui_get_sorting_arrows($url_up_name, $url_down_name, $selectFullnameUp, $selectFullnameDown); $table->head[0] .= ui_get_sorting_arrows($url_up_id, $url_down_id, $selectUserIDUp, $selectUserIDDown);
$table->head[2] = __('Last contact').ui_get_sorting_arrows($url_up_last, $url_down_last, $selectLastConnectUp, $selectLastConnectDown); $table->head[1] = '<span>'.__('Name').'</span>';
$table->head[1] .= ui_get_sorting_arrows($url_up_name, $url_down_name, $selectFullnameUp, $selectFullnameDown);
$table->head[2] = '<span>'.__('Last contact').'</span>';
$table->head[2] .= ui_get_sorting_arrows($url_up_last, $url_down_last, $selectLastConnectUp, $selectLastConnectDown);
$table->head[3] = __('Admin'); $table->head[3] = '<span>'.__('Admin').'</span>';
$table->head[4] = __('Profile / Group'); $table->head[4] = '<span>'.__('Profile / Group').'</span>';
$table->head[5] = __('Description'); $table->head[5] = '<span>'.__('Description').'</span>';
if ($is_management_allowed === true) { if ($is_management_allowed === true) {
$table->head[6] = '<span title="Operations">'.__('Op.').'</span>'; $table->head[6] = '<span>'.__('Actions').'</span>';
} }
if (is_metaconsole() === false) { if (is_metaconsole() === false) {
@ -579,7 +595,7 @@ if ($user_is_admin) {
} else { } else {
$group_um = users_get_groups_UM($config['id_user']); $group_um = users_get_groups_UM($config['id_user']);
// 0 is the group 'all'. // 0 is the group 'all'.
if (isset($group_um[0])) { if (isset($group_um[0]) === true) {
$info1 = get_users($order); $info1 = get_users($order);
} else { } else {
foreach ($group_um as $group => $value) { foreach ($group_um as $group => $value) {
@ -636,9 +652,6 @@ foreach ($info1 as $user_id => $user_info) {
$info = $info1; $info = $info1;
// Prepare pagination.
ui_pagination(count($info));
$offset = (int) get_parameter('offset'); $offset = (int) get_parameter('offset');
$limit = (int) $config['block_size']; $limit = (int) $config['block_size'];
@ -720,12 +733,12 @@ foreach ($info as $user_id => $user_info) {
if ($user_info['is_admin']) { if ($user_info['is_admin']) {
$data[3] = html_print_image( $data[3] = html_print_image(
'images/user_suit.png', 'images/user.svg',
true, true,
[ [
'alt' => __('Admin'), 'alt' => __('Admin'),
'title' => __('Administrator'), 'title' => __('Administrator'),
'class' => 'invert_filter', 'class' => 'main_menu_icon invert_filter',
] ]
).'&nbsp;'; ).'&nbsp;';
} else { } else {
@ -784,10 +797,10 @@ foreach ($info as $user_id => $user_info) {
} }
$data[5] = ui_print_string_substr($user_info['comments'], 24, true); $data[5] = ui_print_string_substr($user_info['comments'], 24, true);
$table->cellclass[][6] = 'table_action_buttons';
$data[6] = '';
$userListActionButtons = [];
if ($is_management_allowed === true) { if ($is_management_allowed === true) {
$table->cellclass[][6] = 'table_action_buttons';
$data[6] = '';
if ($user_is_admin if ($user_is_admin
|| $config['id_user'] == $user_info['id_user'] || $config['id_user'] == $user_info['id_user']
|| isset($group_um[0]) || isset($group_um[0])
@ -796,30 +809,47 @@ foreach ($info as $user_id => $user_info) {
) { ) {
// Disable / Enable user. // Disable / Enable user.
if (isset($user_info['not_delete']) === false) { if (isset($user_info['not_delete']) === false) {
if ($user_info['disabled'] == 0) { if ((int) $user_info['disabled'] === 0) {
$toDoString = __('Disable'); $toDoString = __('Disable');
$toDoAction = '1'; $toDoAction = '1';
$toDoImage = 'images/lightbulb.png'; $toDoImage = 'images/disable.svg';
$toDoClass = ''; $toDoClass = '';
} else { } else {
$toDoString = __('Enable'); $toDoString = __('Enable');
$toDoAction = '0'; $toDoAction = '0';
$toDoImage = 'images/lightbulb_off.png'; $toDoImage = 'images/enable.svg';
$toDoClass = 'filter_none'; $toDoClass = 'filter_none';
} }
$data[6] = '<form method="POST" action="index.php?sec='.$sec.'&amp;sec2=godmode/users/user_list&amp;pure='.$pure.'" class="inline">'; $userListActionButtons[] = html_print_menu_button(
$data[6] .= html_print_input_hidden( [
'href' => ui_get_full_url(
sprintf(
'index.php?sec=%s&amp;sec2=godmode/users/user_list&disable_user=%s&pure=%s&id=%s',
$sec,
$toDoAction,
$pure,
$user_info['id_user']
)
),
'image' => $toDoImage,
'title' => $toDoString,
],
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(
'id', 'id',
$user_info['id_user'], $user_info['id_user'],
true true
); );
$data[6] .= html_print_input_hidden( $data[6] .= html_print_input_hidden(
'disable_user', 'disable_user',
$toDoAction, $toDoAction,
true true
); );
$data[6] .= html_print_input_image( $data[6] .= html_print_input_image(
'submit_disable_enable', 'submit_disable_enable',
$toDoImage, $toDoImage,
'', '',
@ -828,66 +858,101 @@ foreach ($info as $user_id => $user_info) {
[ [
'data-title' => $toDoString, 'data-title' => $toDoString,
'data-use_title_for_force_title' => '1', 'data-use_title_for_force_title' => '1',
'class' => 'forced_title no-padding '.$toDoClass, 'class' => 'main_menu_icon forced_title no-padding '.$toDoClass,
] ]
); );
$data[6] .= '</form>'; $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">'; // Edit user.
$data[6] .= html_print_input_hidden( $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', 'id_user',
$user_info['id_user'], $user_info['id_user'],
true true
); );
$data[6] .= html_print_input_hidden( $data[6] .= html_print_input_hidden(
'edit_user', 'edit_user',
'1', '1',
true true
); );
$data[6] .= html_print_input_image( $data[6] .= html_print_input_image(
'submit_edit_user', 'submit_edit_user',
'images/config.png', 'images/edit.svg',
'', '',
'padding:0', 'padding:0',
true, true,
[ [
'data-title' => __('Edit'), 'data-title' => __('Edit'),
'data-use_title_for_force_title' => '1', 'data-use_title_for_force_title' => '1',
'class' => 'forced_title no-padding', 'class' => 'main_menu_icon forced_title no-padding',
] ]
);
$data[6] .= '</form>';*/
$userListActionButtons[] = html_print_menu_button(
[
'href' => ui_get_full_url(
sprintf(
'index.php?sec=%s&amp;sec2=godmode/users/configure_user&edit_user=1&pure=%s&id_user=%s',
$sec,
$pure,
$user_info['id_user']
)
),
'image' => 'images/edit.svg',
'title' => __('Edit user'),
],
true
); );
$data[6] .= '</form>';
if ($config['admin_can_delete_user'] if ($config['admin_can_delete_user']
&& $user_info['id_user'] != $config['id_user'] && $user_info['id_user'] != $config['id_user']
&& isset($user_info['not_delete']) === false && 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( $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', 'delete_user',
$user_info['id_user'], $user_info['id_user'],
true true
); );
$data[6] .= html_print_input_hidden( $data[6] .= html_print_input_hidden(
'user_del', 'user_del',
'1', '1',
true true
); );
$data[6] .= html_print_input_image( $data[6] .= html_print_input_image(
'submit_delete_user', 'submit_delete_user',
'images/cross.png', 'images/delete.svg',
'', '',
'padding:0', 'padding:0',
true, true,
[ [
'data-title' => __('Delete'), 'data-title' => __('Delete'),
'data-use_title_for_force_title' => '1', 'data-use_title_for_force_title' => '1',
'class' => 'forced_title no-padding', 'class' => 'main_menu_icon forced_title no-padding',
] ]
);
$data[6] .= '</form>';
*/
$userListActionButtons[] = html_print_menu_button(
[
'href' => ui_get_full_url(
sprintf(
'index.php?sec=%s&amp;sec2=godmode/users/user_list&user_del=1&pure=%s&delete_user=%s',
$sec,
$pure,
$user_info['id_user']
)
),
'image' => 'images/delete.svg',
'title' => __('Delete'),
],
true
); );
$data[6] .= '</form>';
if (is_metaconsole() === true) { 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] .= '<form method="POST" action="index.php?sec='.$sec.'&amp;sec2=godmode/users/user_list&amp;pure='.$pure.'" class="inline">';
@ -907,11 +972,16 @@ foreach ($info as $user_id => $user_info) {
true true
); );
$data[6] .= '</form>'; $data[6] .= '</form>';
} else {
$data[6] = implode('', $userListActionButtons);
} }
} else { } else {
$data[6] .= ''; $data[6] .= '';
// Delete button not in this mode. // Delete button not in this mode.
} }
// TODO. Check this in META!!!
$data[6] = implode('', $userListActionButtons);
} else { } else {
$data[6] .= ''; $data[6] .= '';
// Delete button not in this mode. // Delete button not in this mode.
@ -922,24 +992,27 @@ foreach ($info as $user_id => $user_info) {
} }
html_print_table($table); html_print_table($table);
ui_pagination(count($info), false, 0, 0, false, 'offset', true, 'pagination-bottom');
echo '<div style="width: '.$table->width.'" class="action-buttons">';
unset($table); unset($table);
if ($is_management_allowed === true) { if ($is_management_allowed === true) {
if ($config['admin_can_add_user'] !== false) { if ($config['admin_can_add_user'] !== false) {
echo '<form method="post" action="index.php?sec='.$sec.'&amp;sec2=godmode/users/configure_user&pure='.$pure.'">'; echo '<form method="post" action="index.php?sec='.$sec.'&amp;sec2=godmode/users/configure_user&pure='.$pure.'">';
html_print_action_buttons(
html_print_submit_button(
__('Create user'),
'crt',
false,
[ 'icon' => 'wand' ],
true
),
['type' => 'form_action'],
);
html_print_input_hidden('new_user', 1); html_print_input_hidden('new_user', 1);
html_print_submit_button(__('Create user'), 'crt', false, 'class="sub next"');
echo '</form>'; echo '</form>';
} else { } else {
echo '<i>'.__("The current authentication scheme doesn't support creating users on %s", get_product_name()).'</i>'; echo '<i>'.__("The current authentication scheme doesn't support creating users on %s", get_product_name()).'</i>';
} }
} }
echo '</div>';
enterprise_hook('close_meta_frame'); enterprise_hook('close_meta_frame');
?> ?>

View File

@ -3950,7 +3950,7 @@ function html_print_table(&$table, $return=false)
} }
$output .= '</tbody></table>'."\n"; $output .= '</tbody></table>'."\n";
hd($output, true);
if ($return) { if ($return) {
return $output; return $output;
} }

View File

@ -4302,8 +4302,8 @@ span.log_zone_line_error {
width: 50%; width: 50%;
} }
.rowPair:hover, tr.rowPair:hover,
.rowOdd:hover { tr.rowOdd:hover {
background-color: #eee; background-color: #eee;
} }
@ -10769,6 +10769,7 @@ pre.external_tools_output {
.fixed_filter_bar { .fixed_filter_bar {
position: sticky; position: sticky;
top: 114px; top: 114px;
margin-bottom: 10px;
border: 1px solid #e5e9ed; border: 1px solid #e5e9ed;
background-color: #fff; background-color: #fff;
z-index: 1; z-index: 1;