]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/moderatedcomments.pm
403 response may be a "not found" too
[git.ikiwiki.info.git] / IkiWiki / Plugin / moderatedcomments.pm
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::moderatedcomments;
4 use warnings;
5 use strict;
6 use IkiWiki 3.00;
8 sub import {
9         hook(type => "getsetup", id => "moderatedcomments",  call => \&getsetup);
10         hook(type => "checkcontent", id => "moderatedcomments", call => \&checkcontent);
11 }
13 sub getsetup () {
14         return
15                 plugin => {
16                         safe => 1,
17                         rebuild => 0,
18                 },
19                 moderate_users => {
20                         type => 'boolean',
21                         example => 1,
22                         description => 'Moderate comments of logged-in users?',
23                         safe => 1,
24                         rebuild => 0,
25                 },
26 }
28 sub checkcontent (@) {
29         my %params=@_;
30         
31         # only handle comments  
32         return undef unless pagespec_match($params{page}, "postcomment(*)",
33                                 location => $params{page});
35         # admins and maybe users can comment w/o moderation
36         my $session=$params{session};
37         my $user=$session->param("name") if $session;
38         return undef if defined $user && (IkiWiki::is_admin($user) ||
39                 (exists $config{moderate_users} && ! $config{moderate_users}));
41         return gettext("comment needs moderation");
42 }
44 1