<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
package IkiWiki::Plugin::userlist;

use warnings;
use strict;
use IkiWiki 3.00;

sub import {
	hook(type =&gt; "getsetup", id =&gt; "userlist", call =&gt; \&amp;getsetup);
	hook(type =&gt; "sessioncgi", id =&gt; "userlist", call =&gt; \&amp;sessioncgi);
	hook(type =&gt; "formbuilder_setup", id =&gt; "userlist",
		call =&gt; \&amp;formbuilder_setup);
}

sub getsetup () {
        return
		plugin =&gt; {
			safe =&gt; 1,
			rebuild =&gt; 0,
			section =&gt; "web",
		},
}

sub sessioncgi ($$) {
	my $cgi=shift;
	my $session=shift;

	if ($cgi-&gt;param("do") eq "userlist") {
		showuserlist($cgi, $session);
		exit;
	}
}

sub formbuilder_setup (@) {
	my %params=@_;

	my $form=$params{form};
	if ($form-&gt;title eq "preferences" &amp;&amp;
	    IkiWiki::is_admin($params{session}-&gt;param("name"))) {
		push @{$params{buttons}}, "Users";
		if ($form-&gt;submitted &amp;&amp; $form-&gt;submitted eq "Users") {
			showuserlist($params{cgi}, $params{session});
			exit;
		}
	}
}

sub showuserlist ($$) {
	my $q=shift;
	my $session=shift;

	IkiWiki::needsignin($q, $session);
	if (! defined $session-&gt;param("name") ||
	    ! IkiWiki::is_admin($session-&gt;param("name"))) {
		error(gettext("you are not logged in as an admin"));
	}

	my $h="&lt;table border=\"1\"&gt;\n";
	$h.="&lt;tr&gt;&lt;th&gt;".gettext("login")."&lt;/th&gt;&lt;th&gt;".gettext("email")."&lt;/th&gt;&lt;/tr&gt;\n";
	my $info=IkiWiki::userinfo_retrieve();
	eval q{use HTML::Entities};
	if (ref $info) {
		foreach my $user (sort { $info-&gt;{$a}-&gt;{regdate} &lt;=&gt; $info-&gt;{$b}-&gt;{regdate} } keys %$info) {
			my %i=%{$info-&gt;{$user}};
			$h.="&lt;tr&gt;&lt;td&gt;".encode_entities($user)."&lt;/td&gt;&lt;td&gt;".
				encode_entities(defined $i{email} ? $i{email} : "").
				"&lt;/td&gt;&lt;/tr&gt;\n";
		}
	}
	$h.="&lt;/table&gt;\n";

	IkiWiki::printheader($session);
	print IkiWiki::cgitemplate(undef, gettext("Users"), $h);
}

1
</pre></body></html>