]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/anonok.pm
plugin safe/rebuild controls
[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 2.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                 anonok_pagespec => {
16                         type => "pagespec",
17                         example => "*/discussion",
18                         description => "PageSpec to limit which pages anonymous users can edit",
19                         link => "ikiwiki/PageSpec",
20                         safe => 1,
21                         rebuild => 0,
22                 },
23 } #}}}
25 sub canedit ($$$) { #{{{
26         my $page=shift;
27         my $cgi=shift;
28         my $session=shift;
30         my $ret;
32         if (exists $config{anonok_pagespec} && length $config{anonok_pagespec}) {
33                 if (pagespec_match($page, $config{anonok_pagespec},
34                                    location => $page)) {
35                         return "";
36                 }
37                 else {
38                         return undef;
39                 }
40         }
41         else {
42                 return "";
43         }
44 } #}}}
46 1