summaryrefslogtreecommitdiffstats
path: root/app/controllers/wiki_controller.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-04-21 12:19:56 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-04-21 12:19:56 +0000
commitbb44430b631eba1d33b218c97cb5d506073aeb08 (patch)
tree7e37b43149c5fceebb2a61a08f4c0d814c009615 /app/controllers/wiki_controller.rb
parent65cbd94e422ed7119edc474f2c66bdb675f32f98 (diff)
downloadredmine-bb44430b631eba1d33b218c97cb5d506073aeb08.tar.gz
redmine-bb44430b631eba1d33b218c97cb5d506073aeb08.zip
Ask user what to do with child pages when deleting a parent wiki page (#3202).
3 options are available: * move child pages as root pages * move child pages to another parent page * delete all descendants git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2676 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/wiki_controller.rb')
-rw-r--r--app/controllers/wiki_controller.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb
index 1a480e4bd..9c624462a 100644
--- a/app/controllers/wiki_controller.rb
+++ b/app/controllers/wiki_controller.rb
@@ -131,9 +131,31 @@ class WikiController < ApplicationController
render_404 unless @annotate
end
- # remove a wiki page and its history
+ # Removes a wiki page and its history
+ # Children can be either set as root pages, removed or reassigned to another parent page
def destroy
return render_403 unless editable?
+
+ @descendants_count = @page.descendants.size
+ if @descendants_count > 0
+ case params[:todo]
+ when 'nullify'
+ # Nothing to do
+ when 'destroy'
+ # Removes all its descendants
+ @page.descendants.each(&:destroy)
+ when 'reassign'
+ # Reassign children to another parent page
+ reassign_to = @wiki.pages.find_by_id(params[:reassign_to_id].to_i)
+ return unless reassign_to
+ @page.children.each do |child|
+ child.update_attribute(:parent, reassign_to)
+ end
+ else
+ @reassignable_to = @wiki.pages - @page.self_and_descendants
+ return
+ end
+ end
@page.destroy
redirect_to :action => 'special', :id => @project, :page => 'Page_index'
end