3 # A modified version of chooser.cgi that uses the my_ functions
5 $trust_unknown_referers = 1;
6 require './user-lib.pl';
8 &ReadParse(undef, undef, 1);
11 # selecting multiple users.
12 if ($in{'frame'} == 0) {
16 @ul = split(/\s+/, $in{'user'});
18 print "sel = new Array($len);\n";
19 print "selr = new Array($len);\n";
20 for($i=0; $i<$len; $i++) {
22 "e_escape($ul[$i], '"')."\";\n";
23 @uinfo = &my_getpwnam($ul[$i]);
25 print "selr[$i] = \"".
26 "e_escape($uinfo[6], '"')."\";\n";
29 print "selr[$i] = \"???\";\n";
33 print "<title>$text{'users_title1'}</title>\n";
34 print "<frameset cols='50%,50%'>\n";
35 print "<frame src=\"my_user_chooser.cgi?frame=1&multi=1\">\n";
36 print "<frameset rows='*,50' frameborder=no>\n";
37 print " <frame src=\"my_user_chooser.cgi?frame=2&multi=1\">\n";
38 print " <frame src=\"my_user_chooser.cgi?frame=3&multi=1\" scrolling=no>\n";
39 print "</frameset>\n";
40 print "</frameset>\n";
42 elsif ($in{'frame'} == 1) {
43 # list of all users to choose from
46 print "function adduser(u, r)\n";
48 print "top.sel[top.sel.length] = u\n";
49 print "top.selr[top.selr.length] = r\n";
50 print "top.frames[1].location = top.frames[1].location\n";
51 print "return false;\n";
54 print "<font size=+1>$text{'users_all'}</font>\n";
55 print "<table width=100%>\n";
56 foreach $u (&get_users_list()) {
57 if ($in{'user'} eq $u->[0]) { print "<tr $cb>\n"; }
58 else { print "<tr>\n"; }
59 $u->[6] =~ s/'/'/g;
60 print "<td width=20%><a href=\"\" onClick='return adduser(\"$u->[0]\", \"$u->[6]\")'>$u->[0]</a></td>\n";
61 print "<td>$u->[6]</td> </tr>\n";
66 elsif ($in{'frame'} == 2) {
69 print "<font size=+1>$text{'users_sel'}</font>\n";
75 sel2 = new Array(); selr2 = new Array();
76 for(k=0,l=0; k<top.sel.length; k++) {
79 selr2[l] = top.selr[k];
83 top.sel = sel2; top.selr = selr2;
84 top.frames[1].location = top.frames[1].location;
87 for(i=0; i<top.sel.length; i++) {
88 document.write("<tr>\n");
89 document.write("<td><a href=\"\" onClick='return sub("+i+")'>"+top.sel[i]+"</a></td>\n");
90 document.write("<td>"+top.selr[i]+"</td>\n");
97 elsif ($in{'frame'} == 3) {
98 # output OK and Cancel buttons
101 print "function qjoin(l)\n";
103 print "rv = \"\";\n";
104 print "for(i=0; i<l.length; i++) {\n";
105 print " if (rv != '') rv += ' ';\n";
106 print " if (l[i].indexOf(' ') < 0) rv += l[i];\n";
107 print " else rv += '\"'+l[i]+'\"'\n";
109 print "return rv;\n";
113 print "<input type=button value=\"$text{'users_ok'}\" ",
114 "onClick='top.opener.ifield.value = qjoin(top.sel); ",
116 print "<input type=button value=\"$text{'users_cancel'}\" ",
117 "onClick='top.close()'>\n";
118 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";
124 # selecting just one user .. display a list of all users to choose from
125 &popup_header($text{'users_title2'});
127 print "function select(f)\n";
129 print "top.opener.ifield.value = f;\n";
130 print "top.close();\n";
131 print "return false;\n";
134 print "<table width=100%>\n";
135 foreach $u (&get_users_list()) {
136 if ($in{'user'} eq $u->[0]) { print "<tr $cb>\n"; }
137 else { print "<tr>\n"; }
138 print "<td width=20%><a href=\"\" onClick='return select(\"$u->[0]\")'>$u->[0]</a></td>\n";
139 print "<td>$u->[6]</td> </tr>\n";
147 local(@uinfo, @users, %ucan);
148 if ($access{'uedit_mode'} == 2 || $access{'uedit_mode'} == 3) {
149 map { $ucan{$_}++ } split(/\s+/, $access{'uedit'});
152 while(@uinfo = &my_getpwent()) {
153 if ($access{'uedit_mode'} == 0 ||
154 $access{'uedit_mode'} == 2 && $ucan{$uinfo[0]} ||
155 $access{'uedit_mode'} == 3 && !$ucan{$uinfo[0]} ||
156 $access{'uedit_mode'} == 4 &&
157 (!$access{'uedit'} || $uinfo[2] >= $access{'uedit'}) &&
158 (!$access{'uedit2'} || $uinfo[2] <= $access{'uedit2'}) ||
159 $access{'uedit_mode'} == 5 && $uinfo[3] == $access{'uedit'}) {
160 push(@users, [ @uinfo ]);
164 return sort { $a->[0] cmp $b->[0] } @users;