]> sipb.mit.edu Git - ikiwiki.git/blob - IkiWiki/Plugin/anonok.pm
fix cgiurl check
[ikiwiki.git] / IkiWiki / Plugin / anonok.pm
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::anonok;
3
4 use warnings;
5 use strict;
6 use IkiWiki 2.00;
7
8 sub import { #{{{
9         hook(type => "getsetup", id => "anonok", call => \&getsetup);
10         hook(type => "canedit", id => "anonok", call => \&canedit);
11 } # }}}
12
13 sub getsetup () { #{{{
14         return
15                 anonok_pagespec => {
16                         type => "string",
17                         example => "*/discussion",
18                         description => "PageSpec to limit which pages anonymous users can edit",
19                         safe => 1,
20                         rebuild => 0,
21                 },
22 } #}}}
23
24 sub canedit ($$$) { #{{{
25         my $page=shift;
26         my $cgi=shift;
27         my $session=shift;
28
29         my $ret;
30
31         if (exists $config{anonok_pagespec} && length $config{anonok_pagespec}) {
32                 if (pagespec_match($page, $config{anonok_pagespec},
33                                    location => $page)) {
34                         return "";
35                 }
36                 else {
37                         return undef;
38                 }
39         }
40         else {
41                 return "";
42         }
43 } #}}}
44
45 1