summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-12-12 14:19:24 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-12-12 14:19:24 +0000
commit9e2d401f43d9136e887cb099a72ecc33d9dd88f5 (patch)
tree1f4b82a81336dfd01acd678aa569f3dda0314ea1 /app
parent1d4f28a54dec696e34f1477f440471c97d521963 (diff)
downloadredmine-9e2d401f43d9136e887cb099a72ecc33d9dd88f5.tar.gz
redmine-9e2d401f43d9136e887cb099a72ecc33d9dd88f5.zip
Moves mail_notification param to user hash param so that it can be set using the User API.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4496 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/my_controller.rb4
-rw-r--r--app/controllers/users_controller.rb15
-rw-r--r--app/views/users/_mail_notifications.html.erb6
3 files changed, 8 insertions, 17 deletions
diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb
index e552caa16..26641b527 100644
--- a/app/controllers/my_controller.rb
+++ b/app/controllers/my_controller.rb
@@ -54,12 +54,11 @@ class MyController < ApplicationController
@pref = @user.pref
if request.post?
@user.safe_attributes = params[:user]
- @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
@user.pref.save
- @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : [])
+ @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
set_language_if_valid @user.language
flash[:notice] = l(:notice_account_updated)
redirect_to :action => 'account'
@@ -67,7 +66,6 @@ class MyController < ApplicationController
end
end
@notification_options = @user.valid_notification_options
- @notification_option = @user.mail_notification #? ? 'all' : (@user.notified_projects_ids.empty? ? 'none' : 'selected')
end
# Manage user's password
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 9c7f2a17d..15ba71830 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -86,31 +86,28 @@ class UsersController < ApplicationController
def new
@notification_options = User::MAIL_NOTIFICATION_OPTIONS
- @notification_option = Setting.default_notification_option
- @user = User.new(:language => Setting.default_language)
+ @user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
@auth_sources = AuthSource.find(:all)
end
verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
def create
@notification_options = User::MAIL_NOTIFICATION_OPTIONS
- @notification_option = Setting.default_notification_option
- @user = User.new
+ @user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
@user.safe_attributes = params[:user]
@user.admin = params[:user][:admin] || false
@user.login = params[:user][:login]
@user.password, @user.password_confirmation = params[:user][:password], params[:user][:password_confirmation] unless @user.auth_source_id
# TODO: Similar to My#account
- @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
@user.pref.save
- @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : [])
+ @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
Mailer.deliver_account_information(@user, params[:password]) if params[:send_information]
@@ -126,7 +123,6 @@ class UsersController < ApplicationController
end
else
@auth_sources = AuthSource.find(:all)
- @notification_option = @user.mail_notification
# Clear password input
@user.password = @user.password_confirmation = nil
@@ -140,7 +136,6 @@ class UsersController < ApplicationController
def edit
@user = User.find(params[:id])
@notification_options = @user.valid_notification_options
- @notification_option = @user.mail_notification
@auth_sources = AuthSource.find(:all)
@membership ||= Member.new
@@ -150,7 +145,6 @@ class UsersController < ApplicationController
def update
@user = User.find(params[:id])
@notification_options = @user.valid_notification_options
- @notification_option = @user.mail_notification
@user.admin = params[:user][:admin] if params[:user][:admin]
@user.login = params[:user][:login] if params[:user][:login]
@@ -162,13 +156,12 @@ class UsersController < ApplicationController
# Was the account actived ? (do it before User#save clears the change)
was_activated = (@user.status_change == [User::STATUS_REGISTERED, User::STATUS_ACTIVE])
# TODO: Similar to My#account
- @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
@user.pref.save
- @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : [])
+ @user.notified_project_ids = (@user.mail_notification == 'selected' ? params[:notified_project_ids] : [])
if was_activated
Mailer.deliver_account_activated(@user)
diff --git a/app/views/users/_mail_notifications.html.erb b/app/views/users/_mail_notifications.html.erb
index 776bdd3f4..5a8216d2a 100644
--- a/app/views/users/_mail_notifications.html.erb
+++ b/app/views/users/_mail_notifications.html.erb
@@ -1,8 +1,8 @@
<p>
-<%= select_tag 'notification_option', options_for_select(@notification_options.collect {|o| [l(o.last), o.first]}, @notification_option),
- :onchange => 'if ($("notification_option").value == "selected") {Element.show("notified-projects")} else {Element.hide("notified-projects")}' %>
+<%= select_tag 'user[mail_notification]', options_for_select(@notification_options.collect {|o| [l(o.last), o.first]}, @user.mail_notification),
+ :onchange => 'if (this.value == "selected") {Element.show("notified-projects")} else {Element.hide("notified-projects")}' %>
</p>
-<% content_tag 'div', :id => 'notified-projects', :style => (@notification_option == 'selected' ? '' : 'display:none;') do %>
+<% content_tag 'div', :id => 'notified-projects', :style => (@user.mail_notification == 'selected' ? '' : 'display:none;') do %>
<p><% @user.projects.each do |project| %>
<label><%= check_box_tag 'notified_project_ids[]', project.id, @user.notified_projects_ids.include?(project.id) %> <%=h project.name %></label><br />
<% end %></p>