Only users who "watch" the board receive notifications. To watch a board, go to the board and click on the "Watch" link.
Notifications are sent by MessageObserver observer.
GLoc was modified to use the mail template without language suffix when translated template (with language suffix) doesn't exist.
Usefull when there's no hard coded text in the mail tempate.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@531
e93f8b46-1217-0410-a6f0-
8f06a7374b81
@subject = l(:mail_subject_register)
@body['token'] = token
end
+
+ def message_posted(message, recipients)
+ set_language_if_valid(Setting.default_language)
+ @recipients = recipients
+ @from = Setting.mail_from
+ @subject = "[#{message.board.project.name} - #{message.board.name}] #{message.subject}"
+ @body['message'] = message
+ end
end
--- /dev/null
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class MessageObserver < ActiveRecord::Observer
+ def after_create(message)
+ # send notification to board watchers
+ recipients = message.board.watcher_recipients
+ Mailer.deliver_message_posted(message, recipients) unless recipients.empty?
+ end
+end
--- /dev/null
+<%= l(:field_author) %>: <%= @message.author.name %>
+<%= url_for :only_path => false, :host => Setting.host_name, :controller => 'messages', :action => 'show', :board_id => @message.board_id, :id => @message.root %>
+
+<%= @message.content %>
# Enable page/fragment caching by setting a file-based store
# (remember to create the caching directory and make it readable to the application)
# config.action_controller.fragment_cache_store = :file_store, "#{RAILS_ROOT}/cache"
-
+
# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector
+ config.active_record.observers = :message_observer
# Make Active Record use UTC-base instead of local time
# config.active_record.default_timezone = :utc
private\r
alias :render_message_without_gloc :render_message\r
def render_message(method_name, body)\r
- render_message_without_gloc("#{method_name}_#{current_language}", body)\r
+ template = File.exist?("#{template_path}/#{method_name}_#{current_language}.rhtml") ? "#{method_name}_#{current_language}" : "#{method_name}"\r
+ render_message_without_gloc(template, body)\r
end\r
end\r
end\r