]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/attachment.pm
add renamepage hooks
[git.ikiwiki.info.git] / IkiWiki / Plugin / attachment.pm
index 2a662c0d12e949ae27f5ab10982e733fd0d6cee4..e08aa36771b8bb927f9a8a5ba50189f545fae8bb 100644 (file)
@@ -16,6 +16,12 @@ sub check_canattach ($$;$) {
        my $dest=shift; # where it's going to be put, under the srcdir
        my $file=shift; # the path to the attachment currently
 
+       # Don't allow an attachment to be uploaded with the same name as an
+       # existing page.
+       if (exists $pagesources{$dest} && $pagesources{$dest} ne $dest) {
+               error(sprintf(gettext("there is already a page named %s"), $dest));
+       }
+
        # Use a special pagespec to test that the attachment is valid.
        my $allowed=1;
        foreach my $admin (@{$config{adminuser}}) {
@@ -32,7 +38,7 @@ sub check_canattach ($$;$) {
                }
        }
        if (! $allowed) {
-               error(gettext("attachment rejected")." ($allowed)");
+               error(gettext("prohibited by allowed_attachments")." ($allowed)");
        }
        else {
                return 1;
@@ -130,7 +136,7 @@ sub formbuilder (@) { #{{{
                        }
                }
 
-               $filename=IkiWiki::titlepage(
+               $filename=IkiWiki::linkpage(
                        IkiWiki::possibly_foolish_untaint(
                                attachment_location($form->field('page')).
                                IkiWiki::basename($filename)));