summaryrefslogtreecommitdiffstats
path: root/app/controllers/my_controller.rb
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-09-28 18:22:00 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-09-28 18:22:00 +0000
commit0316af7f6bfa47ba1166eda3c5c7167229033a76 (patch)
treedb8d004f118674335919690a2f38b1b59782941b /app/controllers/my_controller.rb
parent3a3263102a7cda4be1c90168a9d32fa904d58272 (diff)
downloadredmine-0316af7f6bfa47ba1166eda3c5c7167229033a76.tar.gz
redmine-0316af7f6bfa47ba1166eda3c5c7167229033a76.zip
Converted User#mail_notification from a boolean to a string.
The string will now store which type of notification option to use. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4216 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers/my_controller.rb')
-rw-r--r--app/controllers/my_controller.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb
index f637b49b6..e430cab0e 100644
--- a/app/controllers/my_controller.rb
+++ b/app/controllers/my_controller.rb
@@ -54,7 +54,7 @@ class MyController < ApplicationController
@pref = @user.pref
if request.post?
@user.attributes = params[:user]
- @user.mail_notification = (params[:notification_option] == 'all')
+ @user.mail_notification = params[:notification_option] || 'only_my_events'
@user.pref.attributes = params[:pref]
@user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
if @user.save
@@ -66,12 +66,14 @@ class MyController < ApplicationController
return
end
end
- @notification_options = [[l(:label_user_mail_option_all), 'all'],
- [l(:label_user_mail_option_none), 'none']]
+ @notification_options = User::MAIL_NOTIFICATION_OPTIONS
# Only users that belong to more than 1 project can select projects for which they are notified
- # Note that @user.membership.size would fail since AR ignores :include association option when doing a count
- @notification_options.insert 1, [l(:label_user_mail_option_selected), 'selected'] if @user.memberships.length > 1
- @notification_option = @user.mail_notification? ? 'all' : (@user.notified_projects_ids.empty? ? 'none' : 'selected')
+ # Note that @user.membership.size would fail since AR ignores
+ # :include association option when doing a count
+ if @user.memberships.length < 1
+ @notification_options.delete_if {|option| option.first == :selected}
+ end
+ @notification_option = @user.mail_notification #? ? 'all' : (@user.notified_projects_ids.empty? ? 'none' : 'selected')
end
# Manage user's password