3 # This CGI generated the HTML for choosing a user or list of users.
5 BEGIN { push(@INC, ".."); };
8 $trust_unknown_referers = 1;
10 &ReadParse(undef, undef, 2);
11 %access = &get_module_acl();
14 # selecting multiple users.
15 if ($in{'frame'} == 0) {
19 @ul = split(/\s+/, $in{'user'});
21 print "sel = new Array($len);\n";
22 print "selr = new Array($len);\n";
23 for($i=0; $i<$len; $i++) {
25 "e_escape($ul[$i], '"')."\";\n";
26 @uinfo = getpwnam($ul[$i]);
28 print "selr[$i] = \"".
29 "e_escape($uinfo[6])."\";\n";
32 print "selr[$i] = \"???\";\n";
36 print "<title>$text{'users_title1'}</title>\n";
37 print "<frameset cols='50%,50%'>\n";
38 print "<frame src=\"/user_chooser.cgi?frame=1&multi=1\">\n";
39 print "<frameset rows='*,50' frameborder=no>\n";
40 print " <frame src=\"/user_chooser.cgi?frame=2&multi=1\">\n";
41 print " <frame src=\"/user_chooser.cgi?frame=3&multi=1\" scrolling=no>\n";
42 print "</frameset>\n";
43 print "</frameset>\n";
45 elsif ($in{'frame'} == 1) {
46 # list of all users to choose from
49 print "function adduser(u, r)\n";
51 print "top.sel[top.sel.length] = u\n";
52 print "top.selr[top.selr.length] = r\n";
53 print "top.frames[1].location = top.frames[1].location\n";
54 print "return false;\n";
57 print "<font size=+1>$text{'users_all'}</font>\n";
58 print "<table width=100%>\n";
59 foreach $u (&get_users_list()) {
60 if ($in{'user'} eq $u->[0]) { print "<tr $cb>\n"; }
61 else { print "<tr>\n"; }
62 $u->[6] =~ s/'/'/g;
63 print "<td width=20%><a href=\"\" onClick='return adduser(\"$u->[0]\", \"$u->[6]\")'>$u->[0]</a></td>\n";
64 print "<td>$u->[6]</td> </tr>\n";
69 elsif ($in{'frame'} == 2) {
72 print "<font size=+1>$text{'users_sel'}</font>\n";
78 sel2 = new Array(); selr2 = new Array();
79 for(k=0,l=0; k<top.sel.length; k++) {
82 selr2[l] = top.selr[k];
86 top.sel = sel2; top.selr = selr2;
87 top.frames[1].location = top.frames[1].location;
90 for(i=0; i<top.sel.length; i++) {
91 document.write("<tr>\n");
92 document.write("<td><a href=\"\" onClick='return sub("+i+")'>"+top.sel[i]+"</a></td>\n");
93 document.write("<td>"+top.selr[i]+"</td>\n");
100 elsif ($in{'frame'} == 3) {
101 # output OK and Cancel buttons
104 print "function qjoin(l)\n";
106 print "rv = \"\";\n";
107 print "for(i=0; i<l.length; i++) {\n";
108 print " if (rv != '') rv += ' ';\n";
109 print " if (l[i].indexOf(' ') < 0) rv += l[i];\n";
110 print " else rv += '\"'+l[i]+'\"'\n";
112 print "return rv;\n";
116 print "<input type=button value=\"$text{'users_ok'}\" ",
117 "onClick='top.opener.ifield.value = qjoin(top.sel); ",
119 print "<input type=button value=\"$text{'users_cancel'}\" ",
120 "onClick='top.close()'>\n";
121 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";
127 # selecting just one user .. display a list of all users to choose from
128 &popup_header($text{'users_title2'});
130 print "function select(f)\n";
132 print "top.opener.ifield.value = f;\n";
133 print "top.close();\n";
134 print "return false;\n";
137 print "<table width=100%>\n";
138 foreach $u (&get_users_list()) {
139 if ($in{'user'} eq $u->[0]) { print "<tr $cb>\n"; }
140 else { print "<tr>\n"; }
141 print "<td width=20%><a href=\"\" onClick='return select(\"$u->[0]\")'>$u->[0]</a></td>\n";
142 print "<td>$u->[6]</td> </tr>\n";
150 local(@uinfo, @users, %ucan, %found);
151 if ($access{'uedit_mode'} == 2 || $access{'uedit_mode'} == 3) {
152 map { $ucan{$_}++ } split(/\s+/, $access{'uedit'});
155 while(@uinfo = getpwent()) {
156 if ($access{'uedit_mode'} == 5 && $access{'uedit'} !~ /^\d+$/) {
157 # Get group for matching by group name
158 @ginfo = getgrgid($uinfo[3]);
160 if ($access{'uedit_mode'} == 0 ||
161 $access{'uedit_mode'} == 2 && $ucan{$uinfo[0]} ||
162 $access{'uedit_mode'} == 3 && !$ucan{$uinfo[0]} ||
163 $access{'uedit_mode'} == 4 &&
164 (!$access{'uedit'} || $uinfo[2] >= $access{'uedit'}) &&
165 (!$access{'uedit2'} || $uinfo[2] <= $access{'uedit2'}) ||
166 $access{'uedit_mode'} == 5 &&
167 ($access{'uedit'} =~ /^\d+$/ && $uinfo[3] == $access{'uedit'} ||
168 $ginfo[0] eq $access{'uedit'})) {
169 push(@users, [ @uinfo ]) if (!$found{$uinfo[0]}++);
172 endpwent() if ($gconfig{'os_type'} ne 'hpux');
173 return sort { $a->[0] cmp $b->[0] } @users;