websetup form display done
[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 => "pagespec",
17                         example => "*/discussion",
18                         description => "PageSpec to limit which pages anonymous users can edit",
19                         description_html => htmllink("", "", "ikiwiki/PageSpec", noimageinline => 1).
20                                 " to limit which pages anonymous users can edit",
21                         safe => 1,
22                         rebuild => 0,
23                 },
24 } #}}}
25
26 sub canedit ($$$) { #{{{
27         my $page=shift;
28         my $cgi=shift;
29         my $session=shift;
30
31         my $ret;
32
33         if (exists $config{anonok_pagespec} && length $config{anonok_pagespec}) {
34                 if (pagespec_match($page, $config{anonok_pagespec},
35                                    location => $page)) {
36                         return "";
37                 }
38                 else {
39                         return undef;
40                 }
41         }
42         else {
43                 return "";
44         }
45 } #}}}
46
47 1