aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/moderatedcomments.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-10-26 13:24:27 -0400
committerJoey Hess <joey@gnu.kitenet.net>2009-10-26 13:24:27 -0400
commit8dfd5289a970e2a77499a2178c493c2c233ba27e (patch)
tree5f4906f0cf991dd0dd77316f4587f8a9b4d30994 /IkiWiki/Plugin/moderatedcomments.pm
parenta8a58a466cd787e4b75328b2e9d689168dd26ba8 (diff)
downloadikiwiki-8dfd5289a970e2a77499a2178c493c2c233ba27e.tar
ikiwiki-8dfd5289a970e2a77499a2178c493c2c233ba27e.tar.gz
moderatedcomments: New plugin to allow comment moderation w/o relying on blogspam.net.
Diffstat (limited to 'IkiWiki/Plugin/moderatedcomments.pm')
-rw-r--r--IkiWiki/Plugin/moderatedcomments.pm44
1 files changed, 44 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/moderatedcomments.pm b/IkiWiki/Plugin/moderatedcomments.pm
new file mode 100644
index 000000000..2555927b7
--- /dev/null
+++ b/IkiWiki/Plugin/moderatedcomments.pm
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+package IkiWiki::Plugin::moderatedcomments;
+
+use warnings;
+use strict;
+use IkiWiki 3.00;
+
+sub import {
+ hook(type => "getsetup", id => "moderatedcomments", call => \&getsetup);
+ hook(type => "checkcontent", id => "moderatedcomments", call => \&checkcontent);
+}
+
+sub getsetup () {
+ return
+ plugin => {
+ safe => 1,
+ rebuild => 0,
+ },
+ moderate_users => {
+ type => 'boolean',
+ example => 1,
+ description => 'Moderate comments of logged-in users?',
+ safe => 1,
+ rebuild => 0,
+ },
+}
+
+sub checkcontent (@) {
+ my %params=@_;
+
+ # only handle comments
+ return undef unless pagespec_match($params{page}, "postcomment(*)",
+ location => $params{page});
+
+ # admins and maybe users can comment w/o moderation
+ my $session=$params{session};
+ my $user=$session->param("name") if $session;
+ return undef if defined $user && (IkiWiki::is_admin($user) ||
+ (exists $config{moderate_users} && ! $config{moderate_users}));
+
+ return gettext("comment needs moderation");
+}
+
+1