X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/8e92468eae9ac0ab8161a0c71ff6c6a0a8aef07a..73f4a8835876c8cb07808367cd72d9ae972893e8:/IkiWiki/Plugin/remove.pm?ds=inline diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm index ee5784f20..2b8cf0414 100644 --- a/IkiWiki/Plugin/remove.pm +++ b/IkiWiki/Plugin/remove.pm @@ -54,6 +54,25 @@ sub check_canremove ($$$) { error("renaming 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 +166,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 +187,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 +237,7 @@ sub sessioncgi ($$) { } } else { - removal_confirm($q, $session, 0, $q->param("page")); + removal_confirm($q, $session, 0, $form->field("page")); } exit 0;