]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
userlist: New plugin, lets admins see a list of users and their info.
authorJoey Hess <joey@kitenet.net>
Thu, 9 Jun 2011 14:08:02 +0000 (10:08 -0400)
committerJoey Hess <joey@kitenet.net>
Thu, 9 Jun 2011 14:10:27 +0000 (10:10 -0400)
IkiWiki/Plugin/userlist.pm [new file with mode: 0644]
debian/changelog
doc/plugins/userlist.mdwn [new file with mode: 0644]

diff --git a/IkiWiki/Plugin/userlist.pm b/IkiWiki/Plugin/userlist.pm
new file mode 100644 (file)
index 0000000..f3e5cd4
--- /dev/null
@@ -0,0 +1,73 @@
+#!/usr/bin/perl
+package IkiWiki::Plugin::userlist;
+
+use warnings;
+use strict;
+use IkiWiki 3.00;
+
+sub import {
+       hook(type => "getsetup", id => "userlist", call => \&getsetup);
+       hook(type => "sessioncgi", id => "userlist", call => \&sessioncgi);
+       hook(type => "formbuilder_setup", id => "userlist",
+               call => \&formbuilder_setup);
+}
+
+sub getsetup () {
+        return
+               plugin => {
+                       safe => 1,
+                       rebuild => 0,
+                       section => "web",
+               },
+}
+
+sub sessioncgi ($$) {
+       my $cgi=shift;
+       my $session=shift;
+
+       if ($cgi->param("do") eq "userlist") {
+               showuserlist($cgi, $session);
+               exit;
+       }
+}
+
+sub formbuilder_setup (@) {
+       my %params=@_;
+
+       my $form=$params{form};
+       if ($form->title eq "preferences" &&
+           IkiWiki::is_admin($params{session}->param("name"))) {
+               push @{$params{buttons}}, "Users";
+               if ($form->submitted && $form->submitted eq "Users") {
+                       showuserlist($params{cgi}, $params{session});
+                       exit;
+               }
+       }
+}
+
+sub showuserlist ($$) {
+       my $q=shift;
+       my $session=shift;
+
+       IkiWiki::needsignin($q, $session);
+       if (! defined $session->param("name") ||
+           ! IkiWiki::is_admin($session->param("name"))) {
+               error(gettext("you are not logged in as an admin"));
+       }
+
+       my $h="<table border=\"1\">\n";
+       $h.="<tr><th>".gettext("login")."</th><th>".gettext("email")."</th></tr>\n";
+       my $info=IkiWiki::userinfo_retrieve();
+       if (ref $info) {
+               foreach my $user (sort { $info->{$a}->{regdate} <=> $info->{$b}->{regdate} } keys %$info) {
+                       my %i=%{$info->{$user}};
+                       $h.="<tr><td>$user</td><td>".(defined $i{email} ? $i{email} : "")."</tr>\n";
+               }
+       }
+       $h.="</table>\n";
+
+       IkiWiki::printheader($session);
+       print IkiWiki::cgitemplate(undef, gettext("Users"), $h);
+}
+
+1
index 2a21cfe276f26e5bfd8191b22c4150086705ad2a..4b03db600ce572b06b80251d787a84f411932e9e 100644 (file)
@@ -1,3 +1,9 @@
+ikiwiki (3.20110609) UNRELEASED; urgency=low
+
+  * userlist: New plugin, lets admins see a list of users and their info.
+
+ -- Joey Hess <joeyh@debian.org>  Thu, 09 Jun 2011 10:06:44 -0400
+
 ikiwiki (3.20110608) unstable; urgency=high
 
   * ikiwiki-mass-rebuild: Fix tty hijacking vulnerability by using su.
diff --git a/doc/plugins/userlist.mdwn b/doc/plugins/userlist.mdwn
new file mode 100644 (file)
index 0000000..1d3d383
--- /dev/null
@@ -0,0 +1,6 @@
+[[!template id=plugin name=userlist core=0 author="[[Joey]]"]]
+[[!tag type/web]]
+
+This plugin allows wiki admins to see a list of users who have recently
+used the wiki. This can be helpful to find openids of users to grant
+permissions, or in dealing with spam.