+ # Must exist on disk, and be a regular file.
+ my $file=$pagesources{$page};
+ if (! -e "$config{srcdir}/$file") {
+ error(sprintf(gettext("%s is not in the srcdir, so it cannot be deleted"), $file));
+ }
+ elsif (-l "$config{srcdir}/$file" && ! -f _) {
+ error(sprintf(gettext("%s is not a file"), $file));
+ }
+
+ # Must be editable.
+ IkiWiki::check_canedit($page, $q, $session);
+
+ # If a user can't upload an attachment, don't let them delete it.
+ # This is sorta overkill, but better safe than sorry.
+ if (! defined pagetype($pagesources{$page})) {
+ if (IkiWiki::Plugin::attachment->can("check_canattach")) {
+ IkiWiki::Plugin::attachment::check_canattach($session, $page, $file);
+ }
+ else {
+ error("renaming of attachments is not allowed");
+ }
+ }
+}
+
+sub formbuilder_setup (@) {