3 # This CGI generated the HTML for choosing a user or list of users.
5 $trust_unknown_referers = 1;
6 require './web-lib.pl';
8 &ReadParse(undef, undef, 2);
9 %access = &get_module_acl();
12 # selecting multiple users.
13 if ($in{'frame'} == 0) {
17 @ul = split(/\s+/, $in{'user'});
19 print "sel = new Array($len);\n";
20 print "selr = new Array($len);\n";
21 for($i=0; $i<$len; $i++) {
23 "e_escape($ul[$i], '"')."\";\n";
24 @uinfo = getpwnam($ul[$i]);
25 if (@uinfo) { print "selr[$i] = \"$uinfo[6]\";\n"; }
26 else { print "selr[$i] = \"???\";\n"; }
29 print "<title>$text{'users_title1'}</title>\n";
30 print "<frameset cols='50%,50%'>\n";
31 print "<frame src=\"/user_chooser.cgi?frame=1&multi=1\">\n";
32 print "<frameset rows='*,50' frameborder=no>\n";
33 print " <frame src=\"/user_chooser.cgi?frame=2&multi=1\">\n";
34 print " <frame src=\"/user_chooser.cgi?frame=3&multi=1\" scrolling=no>\n";
35 print "</frameset>\n";
36 print "</frameset>\n";
38 elsif ($in{'frame'} == 1) {
39 # list of all users to choose from
42 print "function adduser(u, r)\n";
44 print "top.sel[top.sel.length] = u\n";
45 print "top.selr[top.selr.length] = r\n";
46 print "top.frames[1].location = top.frames[1].location\n";
47 print "return false;\n";
50 print "<font size=+1>$text{'users_all'}</font>\n";
51 print "<table width=100%>\n";
52 foreach $u (&get_users_list()) {
53 if ($in{'user'} eq $u->[0]) { print "<tr $cb>\n"; }
54 else { print "<tr>\n"; }
55 $u->[6] =~ s/'/'/g;
56 print "<td width=20%><a href=\"\" onClick='return adduser(\"$u->[0]\", \"$u->[6]\")'>$u->[0]</a></td>\n";
57 print "<td>$u->[6]</td> </tr>\n";
62 elsif ($in{'frame'} == 2) {
65 print "<font size=+1>$text{'users_sel'}</font>\n";
71 sel2 = new Array(); selr2 = new Array();
72 for(k=0,l=0; k<top.sel.length; k++) {
75 selr2[l] = top.selr[k];
79 top.sel = sel2; top.selr = selr2;
80 top.frames[1].location = top.frames[1].location;
83 for(i=0; i<top.sel.length; i++) {
84 document.write("<tr>\n");
85 document.write("<td><a href=\"\" onClick='return sub("+i+")'>"+top.sel[i]+"</a></td>\n");
86 document.write("<td>"+top.selr[i]+"</td>\n");
93 elsif ($in{'frame'} == 3) {
94 # output OK and Cancel buttons
97 print "function qjoin(l)\n";
100 print "for(i=0; i<l.length; i++) {\n";
101 print " if (rv != '') rv += ' ';\n";
102 print " if (l[i].indexOf(' ') < 0) rv += l[i];\n";
103 print " else rv += '\"'+l[i]+'\"'\n";
105 print "return rv;\n";
109 print "<input type=button value=\"$text{'users_ok'}\" ",
110 "onClick='top.opener.ifield.value = qjoin(top.sel); ",
112 print "<input type=button value=\"$text{'users_cancel'}\" ",
113 "onClick='top.close()'>\n";
114 print " <input type=button value=\"$text{'users_clear'}\" onClick='top.sel = new Array(); top.selr = new Array(); top.frames[1].location = top.frames[1].location'>\n";
120 # selecting just one user .. display a list of all users to choose from
121 &popup_header($text{'users_title2'});
123 print "function select(f)\n";
125 print "top.opener.ifield.value = f;\n";
126 print "top.close();\n";
127 print "return false;\n";
130 print "<table width=100%>\n";
131 foreach $u (&get_users_list()) {
132 if ($in{'user'} eq $u->[0]) { print "<tr $cb>\n"; }
133 else { print "<tr>\n"; }
134 print "<td width=20%><a href=\"\" onClick='return select(\"$u->[0]\")'>$u->[0]</a></td>\n";
135 print "<td>$u->[6]</td> </tr>\n";
143 local(@uinfo, @users, %ucan, %found);
144 if ($access{'uedit_mode'} == 2 || $access{'uedit_mode'} == 3) {
145 map { $ucan{$_}++ } split(/\s+/, $access{'uedit'});
148 while(@uinfo = getpwent()) {
149 if ($access{'uedit_mode'} == 0 ||
150 $access{'uedit_mode'} == 2 && $ucan{$uinfo[0]} ||
151 $access{'uedit_mode'} == 3 && !$ucan{$uinfo[0]} ||
152 $access{'uedit_mode'} == 4 &&
153 (!$access{'uedit'} || $uinfo[2] >= $access{'uedit'}) &&
154 (!$access{'uedit2'} || $uinfo[2] <= $access{'uedit2'}) ||
155 $access{'uedit_mode'} == 5 && $uinfo[3] == $access{'uedit'}) {
156 push(@users, [ @uinfo ]) if (!$found{$uinfo[0]}++);
159 endpwent() if ($gconfig{'os_type'} ne 'hpux');
160 return sort { $a->[0] cmp $b->[0] } @users;