3 # List all webmin users
5 require './acl-lib.pl';
6 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1);
8 # Fetch user and group lists, if possible
10 $main::error_must_die = 1;
11 @glist = &list_groups();
13 foreach $gm (@{$g->{'members'}}) {
17 @ulist = &list_users();
20 print "<b>",&text('index_eulist', "$@"),"</b><p>\n";
24 $me = $u if ($u->{'name'} eq $base_remote_user);
26 @mcan = $access{'mode'} == 1 ? @{$me->{'modules'}} :
27 $access{'mode'} == 2 ? split(/\s+/, $access{'mods'}) :
29 map { $mcan{$_}++ } @mcan;
31 if ($config{'order'}) {
32 @ulist = sort { $a->{'name'} cmp $b->{'name'} } @ulist;
33 @glist = sort { $a->{'name'} cmp $b->{'name'} } @glist;
36 foreach $m (&list_module_infos()) {
37 $modname{$m->{'dir'}} = $m->{'desc'};
39 @canulist = grep { &can_edit_user($_->{'name'}, \@glist) } @ulist;
41 # If no users, only show section heading if can create
42 if ($access{'create'}) {
43 print &ui_subheading($text{'index_users'})
44 if (!$config{'display'});
45 print "<b>$text{'index_nousers'}</b><p>\n";
46 print "<a href=edit_user.cgi>$text{'index_create'}</a>\n";
50 elsif ($config{'display'}) {
51 # Show as table of names
52 print &ui_subheading($text{'index_users'});
53 print &ui_form_start("delete_users.cgi", "post");
54 &show_name_table(\@canulist, "edit_user.cgi",
55 $access{'create'} ? $text{'index_create'} : undef,
56 $text{'index_users'}, "user");
57 print &ui_form_end([ [ "delete", $text{'index_delete'} ] ]);
62 # Show usernames and modules
63 print &ui_subheading($text{'index_users'});
65 if (!$config{'select'}) {
66 print &ui_form_start("delete_users.cgi", "post");
67 push(@rowlinks, &select_all_link("d", $form),
68 &select_invert_link("d", $form));
70 push(@rowlinks, "<a href=edit_user.cgi>$text{'index_create'}</a>")
71 if ($access{'create'});
72 print &ui_links_row(\@rowlinks);
74 print &ui_columns_start([ $text{'index_user'},
75 $text{'index_modules'} ], 100);
76 foreach $u (@canulist) {
77 if ($ingroup{$u->{'name'}}) {
78 # Is a member of a group
79 $smods = &show_modules(
80 "user", $u->{'name'}, $u->{'ownmods'}, 0,
81 &text('index_modgroups',
82 "<tt>$ingroup{$u->{'name'}}->{'name'}</tt>"));
86 # Is a stand-alone user
87 $smods = &show_modules(
88 "user", $u->{'name'}, $u->{'modules'}, 1);
90 print &ui_columns_row([ &user_link($u, "edit_user.cgi", "user"),
91 $smods ], [ "valign=top" ]);
93 print &ui_columns_end();
94 print &ui_links_row(\@rowlinks);
95 if (!$config{'select'}) {
96 print &ui_form_end([ [ "delete", $text{'index_delete'} ] ]);
103 if ($shown_users && $access{'groups'}) {
107 if ($access{'groups'}) {
108 print &ui_subheading($text{'index_groups'});
110 # No groups, so just show create link
111 print "<b>$text{'index_nogroups'}</b><p>\n";
112 print "<a href=edit_group.cgi>$text{'index_gcreate'}</a><p>\n";
114 elsif ($config{'display'}) {
115 # Show just group names
116 print &ui_form_start("delete_groups.cgi", "post");
117 &show_name_table(\@glist, "edit_group.cgi",
118 $text{'index_gcreate'},
119 $text{'index_groups'}, "group");
120 print &ui_form_end([ [ "delete", $text{'index_delete'} ] ]);
124 # Show table of groups
126 if (!$config{'select'}) {
127 print &ui_form_start("delete_groups.cgi", "post");
128 push(@rowlinks, &select_all_link("d", $form),
129 &select_invert_link("d", $form));
132 "<a href=edit_group.cgi>$text{'index_gcreate'}</a>");
133 print &ui_links_row(\@rowlinks);
135 print &ui_columns_start([ $text{'index_group'},
136 $text{'index_members'},
137 $text{'index_modules'} ], 100);
138 foreach $g (@glist) {
140 push(@cols, &user_link($g,"edit_group.cgi","group"));
141 push(@cols, join(" ", @{$g->{'members'}}));
142 if ($ingroup{'@'.$g->{'name'}}) {
143 # Is a member of some other group
144 push(@cols, &show_modules("group", $g->{'name'},
146 &text('index_modgroups',
147 "<tt>$ingroup{$g->{'name'}}->{'name'}</tt>")));
150 # Is a top-level group
151 push(@cols, &show_modules("group", $g->{'name'},
152 $g->{'modules'}, 1));
154 print &ui_columns_row(\@cols);
156 print &ui_columns_end();
157 print &ui_links_row(\@rowlinks);
158 if (!$config{'select'}) {
159 print &ui_form_end([ [ "delete", $text{'index_delete'} ] ]);
165 &get_miniserv_config(\%miniserv);
166 if ($access{'sync'} && &foreign_check("useradmin")) {
167 push(@icons, "images/convert.gif");
168 push(@links, "convert_form.cgi");
169 push(@titles, $text{'index_convert'});
171 if ($access{'sync'} && $access{'create'} && $access{'delete'}) {
172 push(@icons, "images/sync.gif");
173 push(@links, "edit_sync.cgi");
174 push(@titles, $text{'index_sync'});
176 if ($access{'unix'} && $access{'create'} && $access{'delete'}) {
177 push(@icons, "images/unix.gif");
178 push(@links, "edit_unix.cgi");
179 push(@titles, $text{'index_unix'});
181 if ($access{'sessions'} && $miniserv{'session'}) {
182 push(@icons, "images/sessions.gif");
183 push(@links, "list_sessions.cgi");
184 push(@titles, $text{'index_sessions'});
186 if (uc($ENV{'HTTPS'}) eq "ON" && $miniserv{'ca'}) {
187 push(@icons, "images/cert.gif");
188 push(@links, "cert_form.cgi");
189 push(@titles, $text{'index_cert'});
191 if ($access{'rbacenable'}) {
192 push(@icons, "images/rbac.gif");
193 push(@links, "edit_rbac.cgi");
194 push(@titles, $text{'index_rbac'});
196 if ($access{'pass'}) {
197 push(@icons, "images/pass.gif");
198 push(@links, "edit_pass.cgi");
199 push(@titles, $text{'pass_title'});
201 if ($access{'sql'}) {
202 push(@icons, "images/sql.gif");
203 push(@links, "edit_sql.cgi");
204 push(@titles, $text{'sql_title'});
209 &icons_table(\@links, \@titles, \@icons);
212 &ui_print_footer("/", $text{'index'});
214 # show_modules(type, who, &mods, show-global, prefix)
217 local ($type, $who, $mods, $global, $prefix) = @_;
219 if ($config{'select'}) {
220 # Show as drop-down menu
221 $rv .= &ui_form_start("edit_acl.cgi");
222 $rv .= $prefix."<br>\n" if ($prefix);
224 $rv .= &ui_hidden($type, $who);
225 if ($access{'acl'}) {
226 $rv .= &ui_submit($text{'index_edit'});
229 foreach my $m (sort { $modname{$a} cmp $modname{$b} } @$mods) {
231 push(@opts, [ $m, $modname{$m} ]);
234 $rv .= &ui_select("mod", undef, \@opts);
236 $rv .= &ui_form_end();
240 $rv .= $prefix."<br>\n" if ($prefix);
242 foreach my $m (sort { $modname{$a} cmp $modname{$b} } @$mods) {
244 if ($mcan{$m} && $access{'acl'}) {
245 push(@grid, "<a href='edit_acl.cgi?mod=".
246 &urlize($m)."&$type=".&urlize($who).
247 "'>$modname{$m}</a>");
250 push(@grid, $modname{$m});
254 $rv .= &ui_grid_table(\@grid, 3, 100,
255 [ "width=33%", "width=33%", "width=33%" ]);
260 # show_name_table(&users|&groups, cgi, create-text, header-text, param)
263 # Show table of users, and maybe create links
264 local @rowlinks = ( &select_all_link("d", $form),
265 &select_invert_link("d", $form) );
266 push(@rowlinks, "<a href=$_[1]>$_[2]</a>") if ($_[2]);
267 print &ui_links_row(\@rowlinks);
269 for(my $i=0; $i<@{$_[0]}; $i++) {
270 push(@links, &user_link($_[0]->[$i], $_[1], $_[4]));
272 print &ui_grid_table(\@links, 4, 100,
273 [ "width=25%", "width=25%", "width=25%", "width=25%" ], undef, $_[3]);
274 print &ui_links_row(\@rowlinks);
277 # user_link(user, cgi, param)
280 local $lck = $_[0]->{'pass'} =~ /^\!/ ? 1 : 0;
281 local $ro = $_[0]->{'readonly'};
282 return ($config{'select'} ? "" : &ui_checkbox("d", $_[0]->{'name'}, "", 0)).
285 "<a href='$_[1]?$_[2]=".&urlize($_[0]->{'name'})."'>".
286 $_[0]->{'name'}."</a>".
288 ($lck ? "</i>" : "");