]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/CGI.pm
web commit by Bug
[git.ikiwiki.info.git] / IkiWiki / CGI.pm
index feed00487c23fbd42ba8a7ffffd14b8b1985bce8..e219c8c1cce88317601f6f1853476e8f5b3f56d8 100644 (file)
@@ -2,6 +2,7 @@
 
 use warnings;
 use strict;
 
 use warnings;
 use strict;
+use IkiWiki;
 use IkiWiki::UserInfo;
 
 package IkiWiki;
 use IkiWiki::UserInfo;
 
 package IkiWiki;
@@ -12,7 +13,7 @@ sub page_locked ($$;$) { #{{{
        my $nonfatal=shift;
        
        my $user=$session->param("name");
        my $nonfatal=shift;
        
        my $user=$session->param("name");
-       return if length $user && is_admin($user);
+       return if defined $user && is_admin($user);
 
        foreach my $admin (@{$config{adminuser}}) {
                my $locked_pages=userinfo_get($admin, "locked_pages");
 
        foreach my $admin (@{$config{adminuser}}) {
                my $locked_pages=userinfo_get($admin, "locked_pages");
@@ -118,6 +119,7 @@ sub cgi_signin ($$) { #{{{
                                validate => sub {
                                        my $name=shift;
                                        length $name &&
                                validate => sub {
                                        my $name=shift;
                                        length $name &&
+                                       $name=~/$config{wiki_file_regexp}/ &&
                                        ! userinfo_get($name, "regdate");
                                },
                        );
                                        ! userinfo_get($name, "regdate");
                                },
                        );
@@ -359,13 +361,6 @@ sub cgi_editpage ($$) { #{{{
        if (! $form->submitted || $form->submitted eq "Preview" || 
            ! $form->validate) {
                if ($form->field("do") eq "create") {
        if (! $form->submitted || $form->submitted eq "Preview" || 
            ! $form->validate) {
                if ($form->field("do") eq "create") {
-                       if (exists $pagesources{lc($page)}) {
-                               # hmm, someone else made the page in the
-                               # meantime?
-                               print $q->redirect("$config{url}/".htmlpage($page));
-                               return;
-                       }
-                       
                        my @page_locs;
                        my $best_loc;
                        my ($from)=$form->param('from')=~/$config{wiki_file_regexp}/;
                        my @page_locs;
                        my $best_loc;
                        my ($from)=$form->param('from')=~/$config{wiki_file_regexp}/;
@@ -378,7 +373,7 @@ sub cgi_editpage ($$) { #{{{
                        }
                        else {
                                my $dir=$from."/";
                        }
                        else {
                                my $dir=$from."/";
-                               $dir=~s![^/]+/$!!;
+                               $dir=~s![^/]+/+$!!;
                                
                                if ((defined $form->param('subpage') && length $form->param('subpage')) ||
                                    $page eq 'discussion') {
                                
                                if ((defined $form->param('subpage') && length $form->param('subpage')) ||
                                    $page eq 'discussion') {
@@ -391,16 +386,23 @@ sub cgi_editpage ($$) { #{{{
                                push @page_locs, $dir.$page;
                                push @page_locs, "$from/$page";
                                while (length $dir) {
                                push @page_locs, $dir.$page;
                                push @page_locs, "$from/$page";
                                while (length $dir) {
-                                       $dir=~s![^/]+/$!!;
+                                       $dir=~s![^/]+/+$!!;
                                        push @page_locs, $dir.$page;
                                }
                                        push @page_locs, $dir.$page;
                                }
-
-                               @page_locs = grep {
-                                       ! exists $pagesources{lc($_)} &&
-                                       ! page_locked($_, $session, 1)
-                               } @page_locs;
                        }
 
                        }
 
+                       @page_locs = grep {
+                               ! exists $pagesources{lc($_)} &&
+                               ! page_locked($_, $session, 1)
+                       } @page_locs;
+                       
+                       if (! @page_locs) {
+                               # hmm, someone else made the page in the
+                               # meantime?
+                               print $q->redirect("$config{url}/".htmlpage($page));
+                               return;
+                       }
+                               
                        $form->tmpl_param("page_select", 1);
                        $form->field(name => "page", type => 'select',
                                options => \@page_locs, value => $best_loc);
                        $form->tmpl_param("page_select", 1);
                        $form->field(name => "page", type => 'select',
                                options => \@page_locs, value => $best_loc);