2 package IkiWiki::Plugin::userlist;
9 hook(type => "getsetup", id => "userlist", call => \&getsetup);
10 hook(type => "sessioncgi", id => "userlist", call => \&sessioncgi);
11 hook(type => "formbuilder_setup", id => "userlist",
12 call => \&formbuilder_setup);
28 if ($cgi->param("do") eq "userlist") {
29 showuserlist($cgi, $session);
34 sub formbuilder_setup (@) {
37 my $form=$params{form};
38 if ($form->title eq "preferences" &&
39 IkiWiki::is_admin($params{session}->param("name"))) {
40 push @{$params{buttons}}, "Users";
41 if ($form->submitted && $form->submitted eq "Users") {
42 showuserlist($params{cgi}, $params{session});
48 sub showuserlist ($$) {
52 IkiWiki::needsignin($q, $session);
53 if (! defined $session->param("name") ||
54 ! IkiWiki::is_admin($session->param("name"))) {
55 error(gettext("you are not logged in as an admin"));
58 my $h="<table border=\"1\">\n";
59 $h.="<tr><th>".gettext("login")."</th><th>".gettext("email")."</th></tr>\n";
60 my $info=IkiWiki::userinfo_retrieve();
61 eval q{use HTML::Entities};
63 foreach my $user (sort { $info->{$a}->{regdate} <=> $info->{$b}->{regdate} } keys %$info) {
64 my %i=%{$info->{$user}};
65 $h.="<tr><td>".encode_entities($user)."</td><td>".
66 encode_entities(defined $i{email} ? $i{email} : "").
72 IkiWiki::printheader($session);
73 print IkiWiki::cgitemplate(undef, gettext("Users"), $h);