summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-11-12 16:43:49 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-11-12 16:43:49 +0000
commit0fe5c7b3e0d8875bff29e3a17230e94de416fa41 (patch)
treeaf4a139b892c95eea4f2688d5288a9dad4a77f95
parent843d04f0e3fa0f841dd4db68262a130714443a0a (diff)
downloadredmine-0fe5c7b3e0d8875bff29e3a17230e94de416fa41.tar.gz
redmine-0fe5c7b3e0d8875bff29e3a17230e94de416fa41.zip
Added an option on 'My account' for users who don't want to be notified of changes that they make.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@899 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/controllers/my_controller.rb1
-rw-r--r--app/models/mailer.rb8
-rw-r--r--app/views/my/account.rhtml1
3 files changed, 10 insertions, 0 deletions
diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb
index 5a1b128f9..2fa5a9d9c 100644
--- a/app/controllers/my_controller.rb
+++ b/app/controllers/my_controller.rb
@@ -56,6 +56,7 @@ class MyController < ApplicationController
@user.attributes = params[:user]
@user.mail_notification = (params[:notification_option] == 'all')
@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] : [])
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index c17e2aa19..aa372120d 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -121,6 +121,14 @@ class Mailer < ActionMailer::Base
default_url_options[:protocol] = Setting.protocol
end
+ # Overrides the create_mail method to remove the current user from the recipients and cc
+ # if he doesn't want to receive notifications about what he does
+ def create_mail
+ recipients.delete(User.current.mail) if recipients && User.current.pref[:no_self_notified]
+ cc.delete(User.current.mail) if cc && User.current.pref[:no_self_notified]
+ super
+ end
+
# Renders a message with the corresponding layout
def render_message(method_name, body)
layout = method_name.match(%r{text\.html\.(rhtml|rxml)}) ? 'layout.text.html.rhtml' : 'layout.text.plain.rhtml'
diff --git a/app/views/my/account.rhtml b/app/views/my/account.rhtml
index 198ef8ffe..e65f78a47 100644
--- a/app/views/my/account.rhtml
+++ b/app/views/my/account.rhtml
@@ -32,6 +32,7 @@
<% end %></p>
<p><em><%= l(:text_user_mail_option) %></em></p>
<% end %>
+<p><label><%= check_box_tag 'no_self_notified', 1, @user.pref[:no_self_notified] %> I don't want to be notified of changes that I make myself.</label></p>
</div>
</div>
<% end %>