summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/user_preference.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb
index e0b17631c..836ad3978 100644
--- a/app/models/user_preference.rb
+++ b/app/models/user_preference.rb
@@ -109,6 +109,7 @@ class UserPreference < ActiveRecord::Base
self[:my_page_settings] = arg
end
+ # Removes block from the user page layout
def remove_block(block)
block = block.to_s.underscore
%w(top left right).each do |f|
@@ -117,9 +118,12 @@ class UserPreference < ActiveRecord::Base
my_page_layout
end
+ # Adds block to the user page layout
+ # Returns nil if block is not valid or if it's already
+ # present in the user page layout
def add_block(block)
block = block.to_s.underscore
- return unless Redmine::MyPage.blocks.key?(block)
+ return unless Redmine::MyPage.valid_block?(block, my_page_layout.values.flatten)
remove_block(block)
# add it on top