@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] : [])
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'
<% 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 %>