2 package IkiWiki::Plugin::moderatedcomments;
9 hook(type => "getsetup", id => "moderatedcomments", call => \&getsetup);
10 hook(type => "checkcontent", id => "moderatedcomments", call => \&checkcontent);
20 moderate_pagespec => {
23 description => 'PageSpec matching users or comment locations to moderate',
24 link => 'ikiwiki/PageSpec',
30 sub checkcontent (@) {
33 # only handle comments
34 return undef unless pagespec_match($params{page}, "postcomment(*)",
35 location => $params{page});
37 # backwards compatability
38 if (exists $config{moderate_users} &&
39 ! exists $config{moderate_pagespec}) {
40 $config{moderate_pagespec} = $config{moderate_users}
45 # default is to moderate all except admins
46 if (! exists $config{moderate_pagespec}) {
47 $config{moderate_pagespec}="!admin()";
50 my $session=$params{session};
51 my $user=$session->param("name") if $session;
52 if (pagespec_match($params{page}, $config{moderate_pagespec},
53 location => $params{page},
54 (defined $user ? (user => $user) : ()),
55 (defined $ENV{REMOTE_ADDR} ? (ip => $ENV{REMOTE_ADDR}) : ()),
57 return gettext("comment needs moderation");