aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/remove.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2011-06-14 14:44:20 -0400
committerJoey Hess <joey@kitenet.net>2011-06-14 14:44:20 -0400
commit04b2a4d6762b33a199b18de4df3991ecba87db7d (patch)
tree7a0c265e488eb9b8c6ab0e9bfe095b676b859e06 /IkiWiki/Plugin/remove.pm
parentc55a32d3e18e5ed72be0dd74461f33ee5e39ef12 (diff)
downloadikiwiki-04b2a4d6762b33a199b18de4df3991ecba87db7d.tar
ikiwiki-04b2a4d6762b33a199b18de4df3991ecba87db7d.tar.gz
fix removal of helf attachments
Left out confirmation of removal for held attachments because a) they're not in the wiki yet, so confirmation is a bit unnecessary b) it would be hard c) eases later integration of jquery file upload interface Also changed where attachments of index are held (to match where they're stored in the srcdir). Note that the attachment formbuilder hook was made to run last, so that the list of attachments is not generated before removal, in the fast path w/o confirm.
Diffstat (limited to 'IkiWiki/Plugin/remove.pm')
-rw-r--r--IkiWiki/Plugin/remove.pm15
1 files changed, 11 insertions, 4 deletions
diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm
index bc481502a..5e5b83349 100644
--- a/IkiWiki/Plugin/remove.pm
+++ b/IkiWiki/Plugin/remove.pm
@@ -117,13 +117,20 @@ sub removal_confirm ($$@) {
my $session=shift;
my $attachment=shift;
my @pages=@_;
+
+ # Special case for unsaved attachments.
+ @pages=grep {
+ ! (IkiWiki::Plugin::attachment->can("remove_held_attachment") &&
+ IkiWiki::Plugin::attachment::remove_held_attachment($_))
+ } @pages;
+ return unless @pages;
foreach my $page (@pages) {
IkiWiki::check_canedit($page, $q, $session);
check_canremove($page, $q, $session);
}
- # Save current form state to allow returning to it later
+ # Save current form state to allow returning to it later
# without losing any edits.
# (But don't save what button was submitted, to avoid
# looping back to here.)
@@ -178,10 +185,10 @@ sub formbuilder (@) {
}
sub sessioncgi ($$) {
- my $q=shift;
+ my $q=shift;
if ($q->param("do") eq 'remove') {
- my $session=shift;
+ my $session=shift;
my ($form, $buttons)=confirmation_form($q, $session);
IkiWiki::decode_form_utf8($form);
@@ -192,7 +199,7 @@ sub sessioncgi ($$) {
IkiWiki::checksessionexpiry($q, $session, $q->param('sid'));
my @pages=$form->field("page");
-
+
# Validate removal by checking that the page exists,
# and that the user is allowed to edit(/remove) it.
my @files;