]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/remove.pm
fix the other half of the filecheck filename bug
[ikiwiki.git] / IkiWiki / Plugin / remove.pm
index 21989aff3ff1c812af0ca83f5d8ecd72046393aa..0fc180f699ce0b2071067404bf3845b2a60b3a9e 100644 (file)
@@ -18,6 +18,7 @@ sub getsetup () {
                plugin => {
                        safe => 1,
                        rebuild => 0,
+                       section => "web",
                },
 }
 
@@ -48,12 +49,31 @@ sub check_canremove ($$$) {
        # 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);
+                       IkiWiki::Plugin::attachment::check_canattach($session, $page, "$config{srcdir}/$file");
                }
                else {
-                       error("renaming of attachments is not allowed");
+                       error("removal of attachments is not allowed");
                }
        }
+
+       my $canremove;
+       IkiWiki::run_hooks(canremove => sub {
+               return if defined $canremove;
+               my $ret=shift->(page => $page, cgi => $q, session => $session);
+               if (defined $ret) {
+                       if ($ret eq "") {
+                               $canremove=1;
+                       }
+                       elsif (ref $ret eq 'CODE') {
+                               $ret->();
+                               $canremove=0;
+                       }
+                       elsif (defined $ret) {
+                               error($ret);
+                               $canremove=0;
+                       }
+               }
+       });
 }
 
 sub formbuilder_setup (@) {
@@ -147,7 +167,7 @@ sub formbuilder (@) {
                        removal_confirm($q, $session, 0, $form->field("page"));
                }
                elsif ($form->submitted eq "Remove Attachments") {
-                       my @selected=$q->param("attachment_select");
+                       my @selected=map { Encode::decode_utf8($_) } $q->param("attachment_select");
                        if (! @selected) {
                                error(gettext("Please select the attachments to remove."));
                        }
@@ -168,7 +188,7 @@ sub sessioncgi ($$) {
                        postremove($session);
                }
                elsif ($form->submitted eq 'Remove' && $form->validate) {
-                       my @pages=$q->param("page");
+                       my @pages=$form->field("page");
        
                        # Validate removal by checking that the page exists,
                        # and that the user is allowed to edit(/remove) it.
@@ -218,7 +238,7 @@ sub sessioncgi ($$) {
                        }
                }
                else {
-                       IkiWiki::showform($form, $buttons, $session, $q);
+                       removal_confirm($q, $session, 0, $form->field("page"));
                }
 
                exit 0;