UI-lification

This commit is contained in:
Jamie Cameron
2008-08-14 18:52:36 +00:00
parent e020da2e0b
commit bacc98141b
20 changed files with 60 additions and 66 deletions

View File

@@ -3,7 +3,6 @@
# Execute create/modify/delete commands in a batch file
require './user-lib.pl';
%access = &get_module_acl();
$access{'batch'} || &error($text{'batch_ecannot'});
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
&ReadParse();

View File

@@ -3,7 +3,6 @@
# Display a form for doing batch creation, updates or deletion from a text file
require './user-lib.pl';
%access = &get_module_acl();
$access{'batch'} || &error($text{'batch_ecannot'});
&ui_print_header(undef, $text{'batch_title'}, "");

View File

@@ -9,7 +9,6 @@ $group = $glist[$in{'num'}];
$group || &error($text{'gdel_enum'});
$| = 1;
&error_setup($text{'gdel_err'});
%access = &get_module_acl();
&can_edit_group(\%access, $group) || &error($text{'gdel_egroup'});
$access{'gdelete'} || &error($text{'gdel_egroup'});

View File

@@ -9,7 +9,6 @@ require './user-lib.pl';
$user = $ulist[$in{'num'}];
$user || &error($text{'udel_enum'});
&error_setup($text{'udel_err'});
%access = &get_module_acl();
&can_edit_user(\%access, $user) || &error($text{'udel_euser'});
$access{'udelete'} || &error($text{'udel_euser'});

View File

@@ -5,7 +5,6 @@
require './user-lib.pl';
&ReadParse();
$n = $in{'num'};
%access = &get_module_acl();
if ($n eq "") {
$access{'gcreate'}==1 || &error($text{'gedit_ecreate'});
&ui_print_header(undef, $text{'gedit_title2'}, "", "create_group");
@@ -201,5 +200,5 @@ else {
print "<input type=submit value=\"$text{'create'}\"></form><p>\n";
}
&ui_print_footer("", $text{'index_return'});
&ui_print_footer("index.cgi?mode=groups", $text{'index_return'});

View File

@@ -6,7 +6,6 @@ require './user-lib.pl';
require 'timelocal.pl';
&ReadParse();
$n = $in{'num'};
%access = &get_module_acl();
if ($n eq "") {
$access{'ucreate'} || &error($text{'uedit_ecreate'});
&ui_print_header(undef, $text{'uedit_title2'}, "", "create_user");
@@ -690,6 +689,6 @@ else {
print "<input type=submit value=\"$text{'create'}\"></form><p>\n";
}
&ui_print_footer("", $text{'index_return'});
&ui_print_footer("index.cgi?mode=users", $text{'index_return'});

View File

@@ -3,7 +3,6 @@
# Actually output a user creation batch file
require './user-lib.pl';
%access = &get_module_acl();
$access{'export'} || &error($text{'export_ecannot'});
&ReadParse();

View File

@@ -3,7 +3,6 @@
# Display a form for exporting a batch file
require './user-lib.pl';
%access = &get_module_acl();
$access{'export'} || &error($text{'export_ecannot'});
&ui_print_header(undef, $text{'export_title'}, "", "export");

View File

@@ -4,7 +4,6 @@ require './user-lib.pl';
&ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
&help_search_link("passwd group shadow gshadow", "man"));
$formno = 0;
%access = &get_module_acl();
&ReadParse();
@quarters = ( "width=25%", "width=25%", "width=25%", "width=25%" );
@@ -36,30 +35,35 @@ if ($can_users) {
print &ui_tabs_start_tab("mode", "users");
}
$match_modes = [ [ 0, $text{'index_equals'} ], [ 4, $text{'index_contains'} ],
[ 1, $text{'index_matches'} ], [ 2, $text{'index_nequals'} ],
[ 5, $text{'index_ncontains'} ], [ 3, $text{'index_nmatches'}],
[ 6, $text{'index_lower'} ], [ 7, $text{'index_higher'} ] ];
if (@ulist > $config{'display_max'}) {
# Display user search form
# Display advanced search form
print "<b>$text{'index_toomany'}</b><p>\n";
print "<form action=search_user.cgi>\n";
print &hlink("<b>$text{'index_find'}</b>","findform"),
" <select name=field>\n";
print "<option value=user selected>$text{'user'}\n";
print "<option value=real>$text{'real'}\n";
print "<option value=shell>$text{'shell'}\n";
print "<option value=home>$text{'home'}\n";
print "<option value=uid>$text{'uid'}\n";
print "<option value=group>$text{'gid'}\n";
print "<option value=gid>$text{'gidnum'}\n";
print "</select> <select name=match>\n";
print "<option value=0>$text{'index_equals'}\n";
print "<option value=4 checked>$text{'index_contains'}\n";
print "<option value=1>$text{'index_matches'}\n";
print "<option value=2>$text{'index_nequals'}\n";
print "<option value=5>$text{'index_ncontains'}\n";
print "<option value=3>$text{'index_nmatches'}\n";
print "<option value=6>$text{'index_lower'}\n";
print "<option value=7>$text{'index_higher'}\n";
print "</select> <input name=what size=15>&nbsp;&nbsp;\n";
print "<input type=submit value=\"$text{'find'}\"></form>\n";
print &ui_form_start("search_user.cgi");
print &ui_table_start($text{'index_usheader'}, undef, 2);
# Field to search
print &ui_table_row($text{'index_find'},
&ui_select("field", "user",
[ [ "user", $text{'user'} ],
[ "real", $text{'real'} ],
[ "shell", $text{'shell'} ],
[ "home", $text{'home'} ],
[ "uid", $text{'uid'} ],
[ "group", $text{'group'} ],
[ "gid", $text{'gid'} ] ])." ".
&ui_select("match", 4, $match_modes));
# Text
print &ui_table_row($text{'index_ftext'},
&ui_textbox("what", undef, 50));
print &ui_table_end();
print &ui_form_end([ [ undef, $text{'find'} ] ]);
$formno++;
}
elsif (@ulist) {
@@ -121,23 +125,23 @@ if ($can_groups) {
if (@glist > $config{'display_max'}) {
# Display group search form
print "<b>$text{'index_gtoomany'}</b><p>\n";
print "<form action=search_group.cgi>\n";
print &hlink("<b>$text{'index_gfind'}</b>","gfindform"),
" <select name=field>\n";
print "<option value=group selected>$text{'gedit_group'}\n";
print "<option value=members>$text{'gedit_members'}\n";
print "<option value=gid>$text{'gedit_gid'}\n";
print "</select> <select name=match>\n";
print "<option value=0>$text{'index_equals'}\n";
print "<option value=4 checked>$text{'index_contains'}\n";
print "<option value=1>$text{'index_matches'}\n";
print "<option value=2>$text{'index_nequals'}\n";
print "<option value=5>$text{'index_ncontains'}\n";
print "<option value=3>$text{'index_nmatches'}\n";
print "<option value=6>$text{'index_lower'}\n";
print "<option value=7>$text{'index_higher'}\n";
print "</select> <input name=what size=15>&nbsp;&nbsp;\n";
print "<input type=submit value=\"$text{'find'}\"></form>\n";
print &ui_form_start("search_group.cgi");
print &ui_table_start($text{'index_gsheader'}, undef, 2);
# Field to search
print &ui_table_row($text{'index_gfind'},
&ui_select("field", "group",
[ [ "group", $text{'gedit_group'} ],
[ "members", $text{'gedit_members'} ],
[ "gedit_gid", $text{'gedit_gid'} ] ])." ".
&ui_select("match", 4, $match_modes));
# Text
print &ui_table_row($text{'index_ftext'},
&ui_textbox("what", undef, 50));
print &ui_table_end();
print &ui_form_end([ [ undef, $text{'find'} ] ]);
$formno++;
}
elsif (@glist) {
@@ -169,7 +173,7 @@ elsif ($access{'gcreate'} == 1) {
if ($can_groups) {
print &ui_tabs_end_tab("mode", "groups");
}
print &ui_tabs_end();
print &ui_tabs_end(1);
if ($access{'logins'}) {
print &ui_hr();

View File

@@ -1,6 +1,10 @@
index_title=Users and Groups
index_toomany=There are too many users on your system to display on one page.
index_find=Find users whose
index_usheader=User search
index_gsheader=Group search
index_fmode=Match mode
index_ftext=Search text
index_gtoomany=There are too many groups on your system to display on one page.
index_gfind=Find groups whose
index_ugroup=Primary Group

View File

@@ -5,7 +5,6 @@
require './user-lib.pl';
&ReadParse();
$u = $in{'username'};
%access = &get_module_acl();
if (!$access{'logins'}) {
&error($text{'logins_elist'});
}

View File

@@ -3,7 +3,6 @@
# Display logged-in users
require './user-lib.pl';
%access = &get_module_acl();
$access{'logins'} || &error($text{'who_ecannot'});
&ui_print_header(undef, $text{'who_title'}, "");

View File

@@ -3,10 +3,9 @@
require './user-lib.pl';
&ReadParse();
%access = &get_module_acl();
%glist = map { $_->{'group'}, $_ } &list_groups();
&error_setup($text{'gmass_err'});
foreach $name (split(/\0/, $in{'d'})) {
foreach $name (split(/\0/, $in{'gd'})) {
$group = $glist{$name};
if ($group) {
&can_edit_group(\%access, $group) ||

View File

@@ -4,7 +4,6 @@
require './user-lib.pl';
&ReadParse();
%access = &get_module_acl();
%ulist = map { $_->{'user'}, $_ } &list_users();
&error_setup($text{'umass_err'});
foreach $name (split(/\0/, $in{'d'})) {

View File

@@ -6,7 +6,6 @@ $trust_unknown_referers = 1;
require './user-lib.pl';
&init_config();
&ReadParse(undef, undef, 1);
%access = &get_module_acl(undef, "");
# Build list of primary groups
&my_setpwent();

View File

@@ -6,7 +6,6 @@ $trust_unknown_referers = 1;
require './user-lib.pl';
&init_config();
&ReadParse(undef, undef, 1);
%access = &get_module_acl(undef, "");
if ($in{'multi'}) {
# selecting multiple users.

View File

@@ -6,7 +6,6 @@ require './user-lib.pl';
require 'timelocal.pl';
&error_setup($text{'gsave_err'});
&ReadParse();
%access = &get_module_acl();
# Build list of used GIDs
&build_group_used(\%gused);
@@ -168,5 +167,5 @@ delete($in{'encpass'});
# Bounce back to the list, if successful
&error(&text('gsave_eothers', $others_err)) if ($others_err);
&redirect("");
&redirect("index.cgi?mode=groups");

View File

@@ -7,7 +7,6 @@ require './user-lib.pl';
require 'timelocal.pl';
&error_setup($text{'usave_err'});
&ReadParse();
%access = &get_module_acl();
# Build list of used UIDs and GIDs
&build_user_used(\%used);
@@ -632,6 +631,6 @@ delete($in{'encpass'});
# Bounce back to the list, if everything worked
&error(&text('usave_eothers', $others_err)) if ($others_err);
&redirect("");
&redirect("index.cgi?mode=users");

View File

@@ -4,7 +4,6 @@
require './user-lib.pl';
&ReadParse();
%access = &get_module_acl();
@ulist = &list_users();
$m = $in{'match'};
$w = $in{'what'};

View File

@@ -11,6 +11,7 @@ else {
do "$gconfig{'os_type'}-lib.pl";
}
do "md5-lib.pl";
%access = &get_module_acl();
@random_password_chars = ( 'a' .. 'z', 'A' .. 'Z', '0' .. '9' );
$disable_string = $config{'lock_prepend'} eq "" ? "!" : $config{'lock_prepend'};
@@ -1997,6 +1998,7 @@ if ($anyedit) {
}
# groups_table(&groups, [form], [no-buttons], [&otherlinks])
# Prints a table of groups, possibly with checkboxes and a delete button
sub groups_table
{
local ($groups, $formno, $noboxes, $links) = @_;
@@ -2014,8 +2016,8 @@ $anyedit = 0 if ($noboxes);
local @linksrow;
if ($anyedit && $access{'gdelete'}) {
print &ui_form_start("mass_delete_group.cgi", "post");
push(@linksrow, &select_all_link("d", $formno),
&select_invert_link("d", $formno) );
push(@linksrow, &select_all_link("gd", $formno),
&select_invert_link("gd", $formno) );
}
push(@linksrow, @$links);
print &ui_links_row(\@linksrow);
@@ -2042,7 +2044,8 @@ foreach $g (@$groups) {
print &ui_columns_row(\@cols, \@tds);
}
else {
print &ui_checked_columns_row(\@cols, \@tds, "d",$g->{'group'});
print &ui_checked_columns_row(\@cols, \@tds, "gd",
$g->{'group'});
}
}
print &ui_columns_end();