]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/lockedit.pm
po: new po_translation_status_in_links option
[git.ikiwiki.info.git] / IkiWiki / Plugin / lockedit.pm
index 525fcb0e5d7fd0e074036421d74a3bc59b2dc33e..31a9e70cd919124beb1b01b944b000b682e210be 100644 (file)
@@ -5,15 +5,19 @@ use warnings;
 use strict;
 use IkiWiki 2.00;
 
-sub import { #{{{
+sub import {
        hook(type => "getsetup", id => "lockedit", call => \&getsetup);
        hook(type => "canedit", id => "lockedit", call => \&canedit);
        hook(type => "formbuilder_setup", id => "lockedit",
             call => \&formbuilder_setup);
-} # }}}
+}
 
-sub getsetup () { #{{{
+sub getsetup () {
        return
+               plugin => {
+                       safe => 1,
+                       rebuild => 0,
+               },
                locked_pages => {
                        type => "pagespec",
                        example => "!*/Discussion",
@@ -22,9 +26,9 @@ sub getsetup () { #{{{
                        safe => 1,
                        rebuild => 0,
                },
-} #}}}
+}
 
-sub canedit ($$) { #{{{
+sub canedit ($$) {
        my $page=shift;
        my $cgi=shift;
        my $session=shift;
@@ -33,7 +37,10 @@ sub canedit ($$) { #{{{
        return undef if defined $user && IkiWiki::is_admin($user);
 
        if (defined $config{locked_pages} && length $config{locked_pages} &&
-           pagespec_match($page, $config{locked_pages})) {
+           pagespec_match($page, $config{locked_pages},
+                   user => $session->param("name"),
+                   ip => $ENV{REMOTE_ADDR},
+           )) {
                if (! defined $user ||
                    ! IkiWiki::userinfo_get($session->param("name"), "regdate")) {
                        return sub { IkiWiki::needsignin($cgi, $session) };
@@ -47,7 +54,10 @@ sub canedit ($$) { #{{{
 
        # XXX deprecated, should be removed eventually
        foreach my $admin (@{$config{adminuser}}) {
-               if (pagespec_match($page, IkiWiki::userinfo_get($admin, "locked_pages"))) {
+               if (pagespec_match($page, IkiWiki::userinfo_get($admin, "locked_pages"),
+                   user => $session->param("name"),
+                   ip => $ENV{REMOTE_ADDR},
+               )) {
                        if (! defined $user ||
                            ! IkiWiki::userinfo_get($session->param("name"), "regdate")) {
                                return sub { IkiWiki::needsignin($cgi, $session) };
@@ -60,9 +70,9 @@ sub canedit ($$) { #{{{
        }
 
        return undef;
-} #}}}
+}
 
-sub formbuilder_setup (@) { #{{{
+sub formbuilder_setup (@) {
        my %params=@_;
 
        # XXX deprecated, should be removed eventually  
@@ -99,6 +109,6 @@ sub formbuilder_setup (@) { #{{{
                        }
                }
        }
-} #}}}
+}
 
 1