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]);
26 print "selr[$i] = \"".
27 "e_escape($uinfo[6])."\";\n"; }
30 print "selr[$i] = \"???\";\n";
34 print "<title>$text{'users_title1'}</title>\n";
35 print "<frameset cols='50%,50%'>\n";
36 print "<frame src=\"/user_chooser.cgi?frame=1&multi=1\">\n";
37 print "<frameset rows='*,50' frameborder=no>\n";
38 print " <frame src=\"/user_chooser.cgi?frame=2&multi=1\">\n";
39 print " <frame src=\"/user_chooser.cgi?frame=3&multi=1\" scrolling=no>\n";
40 print "</frameset>\n";
41 print "</frameset>\n";
43 elsif ($in{'frame'} == 1) {
44 # list of all users to choose from
47 print "function adduser(u, r)\n";
49 print "top.sel[top.sel.length] = u\n";
50 print "top.selr[top.selr.length] = r\n";
51 print "top.frames[1].location = top.frames[1].location\n";
52 print "return false;\n";
55 print "<font size=+1>$text{'users_all'}</font>\n";
56 print "<table width=100%>\n";
57 foreach $u (&get_users_list()) {
58 if ($in{'user'} eq $u->[0]) { print "<tr $cb>\n"; }
59 else { print "<tr>\n"; }
60 $u->[6] =~ s/'/'/g;
61 print "<td width=20%><a href=\"\" onClick='return adduser(\"$u->[0]\", \"$u->[6]\")'>$u->[0]</a></td>\n";
62 print "<td>$u->[6]</td> </tr>\n";
67 elsif ($in{'frame'} == 2) {
70 print "<font size=+1>$text{'users_sel'}</font>\n";
76 sel2 = new Array(); selr2 = new Array();
77 for(k=0,l=0; k<top.sel.length; k++) {
80 selr2[l] = top.selr[k];
84 top.sel = sel2; top.selr = selr2;
85 top.frames[1].location = top.frames[1].location;
88 for(i=0; i<top.sel.length; i++) {
89 document.write("<tr>\n");
90 document.write("<td><a href=\"\" onClick='return sub("+i+")'>"+top.sel[i]+"</a></td>\n");
91 document.write("<td>"+top.selr[i]+"</td>\n");
98 elsif ($in{'frame'} == 3) {
99 # output OK and Cancel buttons
102 print "function qjoin(l)\n";
104 print "rv = \"\";\n";
105 print "for(i=0; i<l.length; i++) {\n";
106 print " if (rv != '') rv += ' ';\n";
107 print " if (l[i].indexOf(' ') < 0) rv += l[i];\n";
108 print " else rv += '\"'+l[i]+'\"'\n";
110 print "return rv;\n";
114 print "<input type=button value=\"$text{'users_ok'}\" ",
115 "onClick='top.opener.ifield.value = qjoin(top.sel); ",
117 print "<input type=button value=\"$text{'users_cancel'}\" ",
118 "onClick='top.close()'>\n";
119 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";
125 # selecting just one user .. display a list of all users to choose from
126 &popup_header($text{'users_title2'});
128 print "function select(f)\n";
130 print "top.opener.ifield.value = f;\n";
131 print "top.close();\n";
132 print "return false;\n";
135 print "<table width=100%>\n";
136 foreach $u (&get_users_list()) {
137 if ($in{'user'} eq $u->[0]) { print "<tr $cb>\n"; }
138 else { print "<tr>\n"; }
139 print "<td width=20%><a href=\"\" onClick='return select(\"$u->[0]\")'>$u->[0]</a></td>\n";
140 print "<td>$u->[6]</td> </tr>\n";
148 local(@uinfo, @users, %ucan, %found);
149 if ($access{'uedit_mode'} == 2 || $access{'uedit_mode'} == 3) {
150 map { $ucan{$_}++ } split(/\s+/, $access{'uedit'});
153 while(@uinfo = getpwent()) {
154 if ($access{'uedit_mode'} == 0 ||
155 $access{'uedit_mode'} == 2 && $ucan{$uinfo[0]} ||
156 $access{'uedit_mode'} == 3 && !$ucan{$uinfo[0]} ||
157 $access{'uedit_mode'} == 4 &&
158 (!$access{'uedit'} || $uinfo[2] >= $access{'uedit'}) &&
159 (!$access{'uedit2'} || $uinfo[2] <= $access{'uedit2'}) ||
160 $access{'uedit_mode'} == 5 && $uinfo[3] == $access{'uedit'}) {
161 push(@users, [ @uinfo ]) if (!$found{$uinfo[0]}++);
164 endpwent() if ($gconfig{'os_type'} ne 'hpux');
165 return sort { $a->[0] cmp $b->[0] } @users;