mirror of
https://github.com/webmin/webmin.git
synced 2026-06-23 20:40:32 +01:00
Add support for paginated tables in Users and Groups module
This commit is contained in:
@@ -35,6 +35,7 @@ default_other=Create and update in other modules,1,1-Yes,0-No
|
||||
|
||||
line4=Display options,11
|
||||
display_max=Maximum number of users or groups to display,0
|
||||
display_max_auto=Use paginated table to display users and groups?,1,1-Yes,0-No
|
||||
sort_mode=Sort users and groups by,4,0-Order in file,1-Username,2-Real name,3-Surname,4-Shell,5-UID or GID,6-Home directory
|
||||
last_count=Number of previous logins to display,3,Unlimited
|
||||
last_show=Show last login in user list?,1,1-Yes,0-No
|
||||
|
||||
@@ -40,7 +40,8 @@ if ($can_users) {
|
||||
print &ui_tabs_start_tab("mode", "users");
|
||||
}
|
||||
|
||||
if (@ulist > $config{'display_max'}) {
|
||||
if (!$config{'display_max_auto'} &&
|
||||
@ulist > $config{'display_max'}) {
|
||||
# Display advanced search form
|
||||
print "<b>$text{'index_toomany'}</b><p>\n";
|
||||
print &ui_form_start("search_user.cgi");
|
||||
@@ -123,7 +124,8 @@ if ($can_groups) {
|
||||
print &ui_tabs_start_tab("mode", "groups");
|
||||
}
|
||||
|
||||
if (@glist > $config{'display_max'}) {
|
||||
if (!$config{'display_max_auto'} &&
|
||||
@glist > $config{'display_max'}) {
|
||||
# Display group search form
|
||||
print "<b>$text{'index_gtoomany'}</b><p>\n";
|
||||
print &ui_form_start("search_group.cgi");
|
||||
|
||||
@@ -1 +1 @@
|
||||
allowed=display_max,sort_mode,last_count_def,last_count,last_show,display_mode,passwd_stars,random_password,extra_real,secmode,membox
|
||||
allowed=display_max,display_max_auto,sort_mode,last_count_def,last_count,last_show,display_mode,passwd_stars,random_password,extra_real,secmode,membox
|
||||
|
||||
@@ -2324,6 +2324,16 @@ while(@ginfo = &my_getgrent()) {
|
||||
}
|
||||
&my_endgrent();
|
||||
|
||||
my $upagination = $config{'display_max_auto'};
|
||||
if ($upagination) {
|
||||
my $upagination_opts = \%in;
|
||||
$upagination_opts->{'top_offset_px'} = 125;
|
||||
$upagination_opts->{'bottom_offset_px'} = 125;
|
||||
$upagination_opts->{'_form-exports'} =
|
||||
{ 'mode' => 'users', 'colspan' => 6 };
|
||||
$upagination = &ui_paginations($users, $upagination_opts);
|
||||
}
|
||||
|
||||
# Work out if any users can be edited
|
||||
local $anyedit;
|
||||
foreach my $u (@$users) {
|
||||
@@ -2347,6 +2357,10 @@ if ($anyedit) {
|
||||
&select_invert_link("d", $_[1]));
|
||||
}
|
||||
push(@linksrow, @$links);
|
||||
if ($upagination) {
|
||||
push(@{$rightlinks},
|
||||
" $upagination->{'search-form-data'}");
|
||||
}
|
||||
local @grid = ( &ui_links_row(\@linksrow), &ui_links_row($rightlinks) );
|
||||
print &ui_grid_table(\@grid, 2, 100, [ "align=left", "align=right" ]);
|
||||
|
||||
@@ -2370,41 +2384,53 @@ if ($lshow) {
|
||||
}
|
||||
}
|
||||
local $u;
|
||||
foreach $u (@$users) {
|
||||
$u->{'real'} =~ s/,.*$// if ($config{'extra_real'} ||
|
||||
$u->{'real'} =~ /,$/);
|
||||
local @cols;
|
||||
push(@cols, "") if ($anyedit && $u->{'noedit'});
|
||||
push(@cols, &user_link($u));
|
||||
push(@cols, $u->{'uid'});
|
||||
push(@cols, &html_escape($gidgrp{$u->{'gid'}} || $u->{'gid'}));
|
||||
push(@cols, &html_escape($u->{'real'}));
|
||||
push(@cols, &html_escape($u->{'home'}));
|
||||
push(@cols, &html_escape($u->{'shell'}));
|
||||
if ($lshow) {
|
||||
# Show last login, in local format after Unix time conversion
|
||||
my $ll = $llogin->{$u->{'user'}};
|
||||
if (defined(&mailboxes::parse_mail_date)) {
|
||||
my $tm = &mailboxes::parse_mail_date($ll);
|
||||
if ($tm) {
|
||||
$ll = &make_date($tm);
|
||||
if (@$users) {
|
||||
foreach $u (@$users) {
|
||||
$u->{'real'} =~ s/,.*$// if ($config{'extra_real'} ||
|
||||
$u->{'real'} =~ /,$/);
|
||||
local @cols;
|
||||
push(@cols, "") if ($anyedit && $u->{'noedit'});
|
||||
push(@cols, &user_link($u));
|
||||
push(@cols, $u->{'uid'});
|
||||
push(@cols, &html_escape($gidgrp{$u->{'gid'}} || $u->{'gid'}));
|
||||
push(@cols, &html_escape($u->{'real'}));
|
||||
push(@cols, &html_escape($u->{'home'}));
|
||||
push(@cols, &html_escape($u->{'shell'}));
|
||||
if ($lshow) {
|
||||
# Show last login, in local format after Unix time conversion
|
||||
my $ll = $llogin->{$u->{'user'}};
|
||||
if (defined(&mailboxes::parse_mail_date)) {
|
||||
my $tm = &mailboxes::parse_mail_date($ll);
|
||||
if ($tm) {
|
||||
$ll = &make_date($tm);
|
||||
}
|
||||
}
|
||||
push(@cols, &html_escape($ll));
|
||||
}
|
||||
if ($u->{'noedit'}) {
|
||||
print &ui_columns_row(\@cols, \@tds);
|
||||
}
|
||||
else {
|
||||
print &ui_checked_columns_row(\@cols, \@tds, "d", $u->{'user'});
|
||||
}
|
||||
push(@cols, &html_escape($ll));
|
||||
}
|
||||
if ($u->{'noedit'}) {
|
||||
print &ui_columns_row(\@cols, \@tds);
|
||||
}
|
||||
else {
|
||||
print &ui_checked_columns_row(\@cols, \@tds, "d", $u->{'user'});
|
||||
}
|
||||
}
|
||||
else {
|
||||
print $upagination->{'search-no-results'};
|
||||
}
|
||||
print &ui_columns_end();
|
||||
print $upagination->{'paginator-form-data'}
|
||||
if ($upagination);
|
||||
print &ui_links_row(\@linksrow);
|
||||
if ($anyedit) {
|
||||
print $buttons;
|
||||
print &ui_form_end();
|
||||
}
|
||||
if ($upagination) {
|
||||
print $upagination->{'paginator-form'};
|
||||
print $upagination->{'search-form'};
|
||||
print $upagination->{"client-height-script"};
|
||||
}
|
||||
}
|
||||
|
||||
=head2 groups_table(&groups, [form], [no-buttons], [&otherlinks], [&rightlinks])
|
||||
@@ -2429,6 +2455,15 @@ foreach my $g (@$groups) {
|
||||
}
|
||||
$anyedit = 0 if ($noboxes);
|
||||
|
||||
my $gpagination = $config{'display_max_auto'};
|
||||
if ($gpagination) {
|
||||
my $gpagination_opts = \%in;
|
||||
$gpagination_opts->{'top_offset_px'} = 125;
|
||||
$gpagination_opts->{'bottom_offset_px'} = 125;
|
||||
$gpagination_opts->{'_form-exports'} = { 'mode' => 'groups', 'colspan' => 4 };
|
||||
$gpagination = &ui_paginations($groups, $gpagination_opts);
|
||||
}
|
||||
|
||||
local @linksrow;
|
||||
if ($anyedit && $access{'gdelete'}) {
|
||||
print &ui_form_start("mass_delete_group.cgi", "post");
|
||||
@@ -2436,6 +2471,10 @@ if ($anyedit && $access{'gdelete'}) {
|
||||
&select_invert_link("gd", $formno) );
|
||||
}
|
||||
push(@linksrow, @$links);
|
||||
if ($gpagination) {
|
||||
push(@{$rightlinks},
|
||||
" $gpagination->{'search-form-data'}");
|
||||
}
|
||||
local @grid = ( &ui_links_row(\@linksrow), &ui_links_row($rightlinks) );
|
||||
print &ui_grid_table(\@grid, 2, 100, [ "align=left", "align=right" ]);
|
||||
|
||||
@@ -2448,33 +2487,45 @@ print &ui_columns_start([
|
||||
$anydesc ? ( $text{'gedit_desc'} ) : ( ),
|
||||
$text{'gedit_members'} ], 100, 0, \@tds);
|
||||
local $g;
|
||||
foreach $g (@$groups) {
|
||||
local $members = join(" ", split(/,/, $g->{'members'}));
|
||||
local @cols;
|
||||
if ($anyedit && ($g->{'noedit'} || !$access{'gdelete'})) {
|
||||
# Need an explicitly blank first column
|
||||
push(@cols, "");
|
||||
}
|
||||
push(@cols, &group_link($g));
|
||||
push(@cols, $g->{'gid'});
|
||||
if ($anydesc) {
|
||||
push(@cols, &html_escape($g->{'desc'}));
|
||||
}
|
||||
push(@cols, &html_escape($members));
|
||||
if ($g->{'noedit'} || !$access{'gdelete'}) {
|
||||
print &ui_columns_row(\@cols, \@tds);
|
||||
}
|
||||
else {
|
||||
print &ui_checked_columns_row(\@cols, \@tds, "gd",
|
||||
$g->{'group'});
|
||||
if (@$groups) {
|
||||
foreach $g (@$groups) {
|
||||
local $members = join(" ", split(/,/, $g->{'members'}));
|
||||
local @cols;
|
||||
if ($anyedit && ($g->{'noedit'} || !$access{'gdelete'})) {
|
||||
# Need an explicitly blank first column
|
||||
push(@cols, "");
|
||||
}
|
||||
push(@cols, &group_link($g));
|
||||
push(@cols, $g->{'gid'});
|
||||
if ($anydesc) {
|
||||
push(@cols, &html_escape($g->{'desc'}));
|
||||
}
|
||||
push(@cols, &html_escape($members));
|
||||
if ($g->{'noedit'} || !$access{'gdelete'}) {
|
||||
print &ui_columns_row(\@cols, \@tds);
|
||||
}
|
||||
else {
|
||||
print &ui_checked_columns_row(\@cols, \@tds, "gd",
|
||||
$g->{'group'});
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
print $gpagination->{'search-no-results'};
|
||||
}
|
||||
print &ui_columns_end();
|
||||
print $gpagination->{'paginator-form-data'}
|
||||
if ($gpagination);
|
||||
print &ui_links_row(\@linksrow);
|
||||
if ($anyedit && $access{'gdelete'}) {
|
||||
print &ui_submit($text{'index_gmass'}, "delete"),"<br>\n";
|
||||
print &ui_form_end();
|
||||
}
|
||||
if ($gpagination) {
|
||||
print $gpagination->{'paginator-form'};
|
||||
print $gpagination->{'search-form'};
|
||||
print $gpagination->{"client-height-script"};
|
||||
}
|
||||
}
|
||||
|
||||
=head2 date_input(day, month, year, prefix)
|
||||
|
||||
Reference in New Issue
Block a user