Project

General



Profile

« Previous | Next » 

Revision 899

Added an option on 'My account' for users who don't want to be notified of changes that they make.

View differences:

trunk/app/controllers/my_controller.rb
56 56
      @user.attributes = params[:user]
57 57
      @user.mail_notification = (params[:notification_option] == 'all')
58 58
      @user.pref.attributes = params[:pref]
59
      @user.pref[:no_self_notified] = (params[:no_self_notified] == '1')
59 60
      if @user.save
60 61
        @user.pref.save
61 62
        @user.notified_project_ids = (params[:notification_option] == 'selected' ? params[:notified_project_ids] : [])
trunk/app/models/mailer.rb
121 121
    default_url_options[:protocol] = Setting.protocol
122 122
  end
123 123
  
124
  # Overrides the create_mail method to remove the current user from the recipients and cc
125
  # if he doesn't want to receive notifications about what he does
126
  def create_mail
127
    recipients.delete(User.current.mail) if recipients && User.current.pref[:no_self_notified]
128
    cc.delete(User.current.mail) if cc && User.current.pref[:no_self_notified]
129
    super
130
  end
131
  
124 132
  # Renders a message with the corresponding layout
125 133
  def render_message(method_name, body)
126 134
    layout = method_name.match(%r{text\.html\.(rhtml|rxml)}) ? 'layout.text.html.rhtml' : 'layout.text.plain.rhtml'
trunk/app/views/my/account.rhtml
32 32
<% end %></p>
33 33
<p><em><%= l(:text_user_mail_option) %></em></p>
34 34
<% end %>
35
<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>
35 36
</div>
36 37
</div>
37 38
<% end %>

Also available in: Unified diff