X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/58141a0ebcdf3313a83af712b83f8acd1c08aa3b..4691a2ad39cce273231fddd9a589b4f8fdc1b063:/IkiWiki/Plugin/lockedit.pm?ds=sidebyside diff --git a/IkiWiki/Plugin/lockedit.pm b/IkiWiki/Plugin/lockedit.pm index 2b72fabe5..5ffb4e6f9 100644 --- a/IkiWiki/Plugin/lockedit.pm +++ b/IkiWiki/Plugin/lockedit.pm @@ -3,7 +3,7 @@ package IkiWiki::Plugin::lockedit; use warnings; use strict; -use IkiWiki; +use IkiWiki 2.00; sub import { #{{{ hook(type => "canedit", id => "lockedit", call => \&canedit); @@ -20,10 +20,16 @@ sub canedit ($$) { #{{{ return undef if defined $user && IkiWiki::is_admin($user); foreach my $admin (@{$config{adminuser}}) { - if (pagespec_match($page, IkiWiki::userinfo_get($admin, "locked_pages"), "")) { - return sprintf(gettext("%s is locked by %s and cannot be edited"), - htmllink("", "", $page, 1), - IkiWiki::userlink($admin)); + if (pagespec_match($page, IkiWiki::userinfo_get($admin, "locked_pages"))) { + if (! defined $user || + ! IkiWiki::userinfo_get($session->param("name"), "regdate")) { + return sub { IkiWiki::needsignin($cgi, $session) }; + } + else { + return sprintf(gettext("%s is locked by %s and cannot be edited"), + htmllink("", "", $page, noimageinline => 1), + IkiWiki::userlink($admin)); + } } } @@ -34,13 +40,14 @@ sub formbuilder_setup (@) { #{{{ my %params=@_; my $form=$params{form}; - my $session=$params{session}; - my $cgi=$params{cgi}; - my $user_name=$session->param("name"); - if ($form->title eq "preferences") { + my $session=$params{session}; + my $cgi=$params{cgi}; + my $user_name=$session->param("name"); + $form->field(name => "locked_pages", size => 50, - comment => "(".htmllink("", "", "PageSpec", 1).")"); + fieldset => "admin", + comment => "(".htmllink("", "", "ikiwiki/PageSpec", noimageinline => 1).")"); if (! IkiWiki::is_admin($user_name)) { $form->field(name => "locked_pages", type => "hidden"); }