#!/usr/local/bin/perl
# my_user_chooser.cgi
# A modified version of chooser.cgi that uses the my_ functions
require './user-lib.pl';
&init_config();
&ReadParse(undef, undef, 1);
%access = &get_module_acl(undef, "");
if ($in{'multi'}) {
# selecting multiple users.
if ($in{'frame'} == 0) {
# base frame
&PrintHeader();
print "\n";
print "
$text{'users_title1'}\n";
print "\n";
}
elsif ($in{'frame'} == 1) {
# list of all users to choose from
&popup_header();
print "\n";
print "$text{'users_all'}\n";
print "\n";
foreach $u (&get_users_list()) {
if ($in{'user'} eq $u->[0]) { print "\n"; }
else { print "
\n"; }
$u->[6] =~ s/'/'/g;
print "$u->[0] | \n";
print "$u->[6] |
\n";
}
print "
\n";
&popup_footer();
}
elsif ($in{'frame'} == 2) {
# show chosen users
&popup_header();
print "$text{'users_sel'}\n";
print <<'EOF';
EOF
&popup_footer();
}
elsif ($in{'frame'} == 3) {
# output OK and Cancel buttons
&popup_header();
print "\n";
print "\n";
&popup_footer();
}
}
else {
# selecting just one user .. display a list of all users to choose from
&popup_header($text{'users_title2'});
print "\n";
print "\n";
foreach $u (&get_users_list()) {
if ($in{'user'} eq $u->[0]) { print "\n"; }
else { print "
\n"; }
print "$u->[0] | \n";
print "$u->[6] |
\n";
}
print "
\n";
&popup_footer();
}
sub get_users_list
{
local(@uinfo, @users, %ucan);
if ($access{'uedit_mode'} == 2 || $access{'uedit_mode'} == 3) {
map { $ucan{$_}++ } split(/\s+/, $access{'uedit'});
}
&my_setpwent();
while(@uinfo = &my_getpwent()) {
if ($access{'uedit_mode'} == 0 ||
$access{'uedit_mode'} == 2 && $ucan{$uinfo[0]} ||
$access{'uedit_mode'} == 3 && !$ucan{$uinfo[0]} ||
$access{'uedit_mode'} == 4 &&
(!$access{'uedit'} || $uinfo[2] >= $access{'uedit'}) &&
(!$access{'uedit2'} || $uinfo[2] <= $access{'uedit2'}) ||
$access{'uedit_mode'} == 5 && $uinfo[3] == $access{'uedit'}) {
push(@users, [ @uinfo ]);
}
}
&my_endpwent();
return sort { $a->[0] cmp $b->[0] } @users;
}