]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/lockedit.pm
avoid internal error message when img uses just-deleted page
[git.ikiwiki.info.git] / IkiWiki / Plugin / lockedit.pm
index 742fd41f65d0cabf963be99e187e0203dbb8c200..5ffb4e6f9edd254691f4fb5b246e3afb2aeea147 100644 (file)
@@ -21,9 +21,15 @@ sub canedit ($$) { #{{{
 
        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, noimageinline => 1),
-                               IkiWiki::userlink($admin));
+                       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,14 +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,
                        fieldset => "admin",
-                       comment => "(".htmllink("", "", "PageSpec", noimageinline => 1).")");
+                       comment => "(".htmllink("", "", "ikiwiki/PageSpec", noimageinline => 1).")");
                if (! IkiWiki::is_admin($user_name)) {
                        $form->field(name => "locked_pages", type => "hidden");
                }