]> source.dussan.org Git - redmine.git/commitdiff
Added an option on 'My account' for users who don't want to be notified of changes...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 12 Nov 2007 16:43:49 +0000 (16:43 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 12 Nov 2007 16:43:49 +0000 (16:43 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@899 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/my_controller.rb
app/models/mailer.rb
app/views/my/account.rhtml

index 5a1b128f9d3ede045e773ae9ae65034e0c996eba..2fa5a9d9c85965a8e933cbebf9f385cb441096e3 100644 (file)
@@ -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] : [])
index c17e2aa195501f2fdad14c794a1d6af426c32fad..aa372120df786e53551e187dbcd8940340077d0e 100644 (file)
@@ -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'
index 198ef8ffe7e310ee145b7b0ebbc9ee9485051a4e..e65f78a47518f1967788ab554cd541875e7e403d 100644 (file)
@@ -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 %>