diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/mailer.rb | 8 | ||||
-rw-r--r-- | app/models/message_observer.rb | 2 | ||||
-rw-r--r-- | app/models/setting.rb | 17 |
3 files changed, 21 insertions, 6 deletions
diff --git a/app/models/mailer.rb b/app/models/mailer.rb index b3ed16fc2..925d46ea7 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -90,6 +90,14 @@ class Mailer < ActionMailer::Base @body['url'] = url @body['added_to'] = added_to 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) set_language_if_valid(token.user.language) diff --git a/app/models/message_observer.rb b/app/models/message_observer.rb index cdf7b6ef6..1c311e25f 100644 --- a/app/models/message_observer.rb +++ b/app/models/message_observer.rb @@ -22,6 +22,6 @@ class MessageObserver < ActiveRecord::Observer # send notification to the board watchers recipients += message.board.watcher_recipients 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 diff --git a/app/models/setting.rb b/app/models/setting.rb index c09b4bdb3..d4c82191a 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -27,16 +27,23 @@ class Setting < ActiveRecord::Base # Hash used to cache setting values @cached_settings = {} @cached_cleared_on = Time.now - + + def value + v = read_attribute(:value) + # Unserialize serialized settings + v = YAML::load(v) if @@available_settings[name]['serialized'] && v.is_a?(String) + v + end + # Returns the value of the setting named name def self.[](name) - value = @cached_settings[name] - value ? value : (@cached_settings[name] = find_or_default(name).value) + v = @cached_settings[name] + v ? v : (@cached_settings[name] = find_or_default(name).value) end - def self.[]=(name, value) + def self.[]=(name, v) setting = find_or_default(name) - setting.value = (value ? value.to_s : "") + setting.value = (v ? v : "") @cached_settings[name] = nil setting.save setting.value |