Mail notification options restored (default is: issue_added and issue_updated).
Added mail notification when adding a news (disabled by default). git-svn-id: http://redmine.rubyforge.org/svn/trunk@728 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
1fa1f62018
commit
23264ec3eb
|
@ -46,6 +46,12 @@ class AdminController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def mail_options
|
def mail_options
|
||||||
|
@notifiables = %w(issue_added issue_updated news_added document_added file_added message_posted)
|
||||||
|
if request.post?
|
||||||
|
Setting.notified_events = (params[:notified_events] || [])
|
||||||
|
flash[:notice] = l(:notice_successful_update)
|
||||||
|
redirect_to :controller => 'admin', :action => 'mail_options'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_email
|
def test_email
|
||||||
|
|
|
@ -52,7 +52,7 @@ class DocumentsController < ApplicationController
|
||||||
a = Attachment.create(:container => @document, :file => file, :author => logged_in_user)
|
a = Attachment.create(:container => @document, :file => file, :author => logged_in_user)
|
||||||
@attachments << a unless a.new_record?
|
@attachments << a unless a.new_record?
|
||||||
} if params[:attachments] and params[:attachments].is_a? Array
|
} if params[:attachments] and params[:attachments].is_a? Array
|
||||||
Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? #and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? && Setting.notified_events.include?('document_added')
|
||||||
redirect_to :action => 'show', :id => @document
|
redirect_to :action => 'show', :id => @document
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ class IssuesController < ApplicationController
|
||||||
:value => a.filename) unless a.new_record?
|
:value => a.filename) unless a.new_record?
|
||||||
} if params[:attachments] and params[:attachments].is_a? Array
|
} if params[:attachments] and params[:attachments].is_a? Array
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
Mailer.deliver_issue_edit(journal) #if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated')
|
||||||
redirect_to :action => 'show', :id => @issue
|
redirect_to :action => 'show', :id => @issue
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -137,7 +137,7 @@ class IssuesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
flash[:notice] = l(:notice_successful_update)
|
flash[:notice] = l(:notice_successful_update)
|
||||||
Mailer.deliver_issue_edit(journal) #if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated')
|
||||||
redirect_to :action => 'show', :id => @issue
|
redirect_to :action => 'show', :id => @issue
|
||||||
end
|
end
|
||||||
rescue ActiveRecord::StaleObjectError
|
rescue ActiveRecord::StaleObjectError
|
||||||
|
|
|
@ -187,7 +187,7 @@ class ProjectsController < ApplicationController
|
||||||
Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0
|
Attachment.create(:container => @document, :file => a, :author => logged_in_user) unless a.size == 0
|
||||||
} if params[:attachments] and params[:attachments].is_a? Array
|
} if params[:attachments] and params[:attachments].is_a? Array
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
Mailer.deliver_document_add(@document) #if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
Mailer.deliver_document_add(@document) if Setting.notified_events.include?('document_added')
|
||||||
redirect_to :action => 'list_documents', :id => @project
|
redirect_to :action => 'list_documents', :id => @project
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -231,7 +231,7 @@ class ProjectsController < ApplicationController
|
||||||
if @issue.save
|
if @issue.save
|
||||||
@attachments.each(&:save)
|
@attachments.each(&:save)
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
Mailer.deliver_issue_add(@issue) #if Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added')
|
||||||
redirect_to :action => 'list_issues', :id => @project
|
redirect_to :action => 'list_issues', :id => @project
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -380,6 +380,7 @@ class ProjectsController < ApplicationController
|
||||||
@news.author_id = self.logged_in_user.id if self.logged_in_user
|
@news.author_id = self.logged_in_user.id if self.logged_in_user
|
||||||
if @news.save
|
if @news.save
|
||||||
flash[:notice] = l(:notice_successful_create)
|
flash[:notice] = l(:notice_successful_create)
|
||||||
|
Mailer.deliver_news_added(@news) if Setting.notified_events.include?('news_added')
|
||||||
redirect_to :action => 'list_news', :id => @project
|
redirect_to :action => 'list_news', :id => @project
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -405,7 +406,7 @@ class ProjectsController < ApplicationController
|
||||||
a = Attachment.create(:container => @version, :file => file, :author => logged_in_user)
|
a = Attachment.create(:container => @version, :file => file, :author => logged_in_user)
|
||||||
@attachments << a unless a.new_record?
|
@attachments << a unless a.new_record?
|
||||||
} if params[:attachments] and params[:attachments].is_a? Array
|
} if params[:attachments] and params[:attachments].is_a? Array
|
||||||
Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? #and Permission.find_by_controller_and_action(params[:controller], params[:action]).mail_enabled?
|
Mailer.deliver_attachments_add(@attachments) if !@attachments.empty? && Setting.notified_events.include?('file_added')
|
||||||
redirect_to :controller => 'projects', :action => 'list_files', :id => @project
|
redirect_to :controller => 'projects', :action => 'list_files', :id => @project
|
||||||
end
|
end
|
||||||
@versions = @project.versions.sort
|
@versions = @project.versions.sort
|
||||||
|
|
|
@ -90,6 +90,14 @@ class Mailer < ActionMailer::Base
|
||||||
@body['url'] = url
|
@body['url'] = url
|
||||||
@body['added_to'] = added_to
|
@body['added_to'] = added_to
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def news_added(news)
|
||||||
|
set_language_if_valid(Setting.default_language)
|
||||||
|
@recipients = news.project.users.collect { |u| u.mail if u.mail_notification }.compact
|
||||||
|
@from = Setting.mail_from
|
||||||
|
@subject = "[#{news.project.name}] #{l(:label_news)}: #{news.title}"
|
||||||
|
@body['news'] = news
|
||||||
|
end
|
||||||
|
|
||||||
def lost_password(token)
|
def lost_password(token)
|
||||||
set_language_if_valid(token.user.language)
|
set_language_if_valid(token.user.language)
|
||||||
|
|
|
@ -22,6 +22,6 @@ class MessageObserver < ActiveRecord::Observer
|
||||||
# send notification to the board watchers
|
# send notification to the board watchers
|
||||||
recipients += message.board.watcher_recipients
|
recipients += message.board.watcher_recipients
|
||||||
recipients = recipients.compact.uniq
|
recipients = recipients.compact.uniq
|
||||||
Mailer.deliver_message_posted(message, recipients) unless recipients.empty?
|
Mailer.deliver_message_posted(message, recipients) if !recipients.empty? && Setting.notified_events.include?('message_posted')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,16 +27,23 @@ class Setting < ActiveRecord::Base
|
||||||
# Hash used to cache setting values
|
# Hash used to cache setting values
|
||||||
@cached_settings = {}
|
@cached_settings = {}
|
||||||
@cached_cleared_on = Time.now
|
@cached_cleared_on = Time.now
|
||||||
|
|
||||||
# Returns the value of the setting named name
|
def value
|
||||||
def self.[](name)
|
v = read_attribute(:value)
|
||||||
value = @cached_settings[name]
|
# Unserialize serialized settings
|
||||||
value ? value : (@cached_settings[name] = find_or_default(name).value)
|
v = YAML::load(v) if @@available_settings[name]['serialized'] && v.is_a?(String)
|
||||||
|
v
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.[]=(name, value)
|
# Returns the value of the setting named name
|
||||||
|
def self.[](name)
|
||||||
|
v = @cached_settings[name]
|
||||||
|
v ? v : (@cached_settings[name] = find_or_default(name).value)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.[]=(name, v)
|
||||||
setting = find_or_default(name)
|
setting = find_or_default(name)
|
||||||
setting.value = (value ? value.to_s : "")
|
setting.value = (v ? v : "")
|
||||||
@cached_settings[name] = nil
|
@cached_settings[name] = nil
|
||||||
setting.save
|
setting.save
|
||||||
setting.value
|
setting.value
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
<div class="contextual">
|
||||||
|
<%= link_to l(:label_send_test_email), :action => 'test_email' %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h2><%=l(:field_mail_notification)%></h2>
|
<h2><%=l(:field_mail_notification)%></h2>
|
||||||
|
|
||||||
<%= link_to l(:label_send_test_email), :action => 'test_email' %>
|
<% form_tag({:action => 'mail_options'}, :id => 'mail-options-form') do %>
|
||||||
|
|
||||||
|
<fieldset class="box"><legend><%=l(:text_select_mail_notifications)%></legend>
|
||||||
|
<% @notifiables.each do |notifiable| %>
|
||||||
|
<p><label><%= check_box_tag "notified_events[]", notifiable, Setting.notified_events.include?(notifiable) %>
|
||||||
|
<%= notifiable.humanize %></label></p>
|
||||||
|
<% end %>
|
||||||
|
<div class="clear"></div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<p><%= check_all_links('mail-options-form') %></p>
|
||||||
|
<%= submit_tag l(:button_save) %>
|
||||||
|
<% end %>
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
<%= @news.title %>
|
||||||
|
<%= url_for :only_path => false, :host => Setting.host_name, :controller => 'news', :action => 'show', :id => @news %>
|
||||||
|
<%= @news.author.name %>
|
||||||
|
|
||||||
|
<%= @news.description %>
|
||||||
|
|
|
@ -74,3 +74,9 @@ date_format:
|
||||||
default: 0
|
default: 0
|
||||||
cross_project_issue_relations:
|
cross_project_issue_relations:
|
||||||
default: 0
|
default: 0
|
||||||
|
notified_events:
|
||||||
|
serialized: true
|
||||||
|
default: --
|
||||||
|
- issue_added
|
||||||
|
- issue_updated
|
||||||
|
|
Loading…
Reference in New Issue