]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/anonok.pm
update
[git.ikiwiki.info.git] / IkiWiki / Plugin / anonok.pm
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::anonok;
4 use warnings;
5 use strict;
6 use IkiWiki 3.00;
8 sub import {
9         hook(type => "getsetup", id => "anonok", call => \&getsetup);
10         hook(type => "canedit", id => "anonok", call => \&canedit);
11 }
13 sub getsetup () {
14         return
15                 plugin => {
16                         safe => 1,
17                         rebuild => 0,
18                         section => "auth",
19                 },
20                 anonok_pagespec => {
21                         type => "pagespec",
22                         example => "*/discussion",
23                         description => "PageSpec to limit which pages anonymous users can edit",
24                         link => "ikiwiki/PageSpec",
25                         safe => 1,
26                         rebuild => 0,
27                 },
28 }
30 sub canedit ($$$) {
31         my $page=shift;
32         my $cgi=shift;
33         my $session=shift;
35         my $ret;
37         if (exists $config{anonok_pagespec} && length $config{anonok_pagespec}) {
38                 if (pagespec_match($page, $config{anonok_pagespec},
39                                    location => $page)) {
40                         return "";
41                 }
42                 else {
43                         return undef;
44                 }
45         }
46         else {
47                 return "";
48         }
49 }
51 1