summaryrefslogtreecommitdiffstats
path: root/app/controllers/my_controller.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-02-26 16:15:07 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-02-26 16:15:07 +0000
commit5b96d1b083a82d3ae68072c77af9521e720a3af8 (patch)
tree8fdd3b1df752b609171952d3cc5f0fa764d9add5 /app/controllers/my_controller.rb
parent4c28291a19714022a9c991984d14a26fb2413b06 (diff)
downloadredmine-5b96d1b083a82d3ae68072c77af9521e720a3af8.tar.gz
redmine-5b96d1b083a82d3ae68072c77af9521e720a3af8.zip
Allow underscore in block partial name (#2840).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2528 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/my_controller.rb')
-rw-r--r--app/controllers/my_controller.rb22
1 files changed, 12 insertions, 10 deletions
diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb
index 5e1b9d2c8..ae063d60a 100644
--- a/app/controllers/my_controller.rb
+++ b/app/controllers/my_controller.rb
@@ -108,14 +108,14 @@ class MyController < ApplicationController
session[:page_layout] = @blocks
%w(top left right).each {|f| session[:page_layout][f] ||= [] }
@block_options = []
- BLOCKS.each {|k, v| @block_options << [l(v), k]}
+ BLOCKS.each {|k, v| @block_options << [l(v), k.dasherize]}
end
# Add a block to user's page
# The block is added on top of the page
# params[:block] : id of the block to add
def add_block
- block = params[:block]
+ block = params[:block].to_s.underscore
render(:nothing => true) and return unless block && (BLOCKS.keys.include? block)
@user = User.current
# remove if already present in a group
@@ -128,7 +128,7 @@ class MyController < ApplicationController
# Remove a block to user's page
# params[:block] : id of the block to remove
def remove_block
- block = params[:block]
+ block = params[:block].to_s.underscore
# remove block in all groups
%w(top left right).each {|f| (session[:page_layout][f] ||= []).delete block }
render :nothing => true
@@ -139,13 +139,15 @@ class MyController < ApplicationController
# params[:list-(top|left|right)] : array of block ids of the group
def order_blocks
group = params[:group]
- group_items = params["list-#{group}"]
- if group_items and group_items.is_a? Array
- # remove group blocks if they are presents in other groups
- %w(top left right).each {|f|
- session[:page_layout][f] = (session[:page_layout][f] || []) - group_items
- }
- session[:page_layout][group] = group_items
+ if group.is_a?(Array)
+ group_items = params["list-#{group}"].collect(&:underscore)
+ if group_items and group_items.is_a? Array
+ # remove group blocks if they are presents in other groups
+ %w(top left right).each {|f|
+ session[:page_layout][f] = (session[:page_layout][f] || []) - group_items
+ }
+ session[:page_layout][group] = group_items
+ end
end
render :nothing => true
end