]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/moderatedcomments.pm
comments: Display number of comments in comment action link.
[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                         section => "auth",
19                 },
20                 moderate_users => {
21                         type => 'boolean',
22                         example => 1,
23                         description => 'Moderate comments of logged-in users?',
24                         safe => 1,
25                         rebuild => 0,
26                 },
27 }
29 sub checkcontent (@) {
30         my %params=@_;
31         
32         # only handle comments  
33         return undef unless pagespec_match($params{page}, "postcomment(*)",
34                                 location => $params{page});
36         # admins and maybe users can comment w/o moderation
37         my $session=$params{session};
38         my $user=$session->param("name") if $session;
39         return undef if defined $user && (IkiWiki::is_admin($user) ||
40                 (exists $config{moderate_users} && ! $config{moderate_users}));
42         return gettext("comment needs moderation");
43 }
45 1