|
|
|
@ -27,6 +27,36 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
{ :host => Setting.host_name, :protocol => Setting.protocol }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 贴吧新建贴吧发送邮件
|
|
|
|
|
# example Mailer.forum(forum).deliver
|
|
|
|
|
def forum_add(forum)
|
|
|
|
|
|
|
|
|
|
redmine_headers 'Forum' => forum.id
|
|
|
|
|
@forum = forum
|
|
|
|
|
@author = forum.creator
|
|
|
|
|
recipients = forum.creator.mail
|
|
|
|
|
# cc = wiki_content.page.wiki.watcher_recipients - recipients
|
|
|
|
|
|
|
|
|
|
@forum_url = url_for(:controller => 'forums', :action => 'show', :id => forum.id)
|
|
|
|
|
mail :to => recipients,:subject => "[ #{l(:label_forum)} : #{forum.name} #{l(:notice_successful_create)}]"
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def forum_message_added(memo)
|
|
|
|
|
@memo = memo
|
|
|
|
|
redmine_headers 'Memo' => memo.id
|
|
|
|
|
@forum = memo.forum
|
|
|
|
|
@author = memo.author
|
|
|
|
|
recipients ||= []
|
|
|
|
|
mems = memo.self_and_siblings
|
|
|
|
|
mems.each do |mem|
|
|
|
|
|
recipients << mem.author.mail unless recipients.include? mem.author.mail
|
|
|
|
|
end
|
|
|
|
|
# cc = wiki_content.page.wiki.watcher_recipients - recipients
|
|
|
|
|
|
|
|
|
|
@memo_url = url_for(forum_memo_url(@forum, (@memo.parent_id.nil? ? @memo : @memo.parent_id)))
|
|
|
|
|
mail :to => recipients,:subject => "[ #{l(:label_message_plural)} : #{memo.subject} #{l(:label_memo_create_succ)}]"
|
|
|
|
|
end
|
|
|
|
|
# Builds a Mail::Message object used to email recipients of the added journals for message.
|
|
|
|
|
|
|
|
|
|
# 留言分为直接留言,和对留言人留言的回复
|
|
|
|
@ -282,7 +312,7 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail }
|
|
|
|
|
when 'Course'
|
|
|
|
|
added_to_url = url_for(:controller => 'files', :action => 'index', :course_id => container)
|
|
|
|
|
added_to = "#{l(:label_course)}: #{container}"
|
|
|
|
|
added_to = "#{l(:label_course)}: #{container.name}"
|
|
|
|
|
recipients = container.notified_users.select { |user| user.allowed_to?(:view_files, container) }.collect { |u| u.mail }
|
|
|
|
|
when 'Version'
|
|
|
|
|
added_to_url = url_for(:controller => 'files', :action => 'index', :project_id => container.project)
|
|
|
|
@ -323,6 +353,8 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
# news_added(news) => Mail::Message object
|
|
|
|
|
# Mailer.news_added(news).deliver => sends an email to the news' project recipients
|
|
|
|
|
def news_added(news)
|
|
|
|
|
|
|
|
|
|
if news.project
|
|
|
|
|
redmine_headers 'Project' => news.project.identifier
|
|
|
|
|
@author = news.author
|
|
|
|
|
message_id news
|
|
|
|
@ -330,6 +362,16 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
|
|
|
|
|
mail :to => news.recipients,
|
|
|
|
|
:subject => "[#{news.project.name}] #{l(:label_news)}: #{news.title}"
|
|
|
|
|
elsif news.course
|
|
|
|
|
redmine_headers 'Course' => news.course.id
|
|
|
|
|
@author = news.author
|
|
|
|
|
message_id news
|
|
|
|
|
@news = news
|
|
|
|
|
recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail }
|
|
|
|
|
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
|
|
|
|
|
mail :to => recipients,
|
|
|
|
|
:subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Builds a Mail::Message object used to email recipients of a news' project when a news comment is added.
|
|
|
|
@ -339,6 +381,7 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
# Mailer.news_comment_added(comment) => sends an email to the news' project recipients
|
|
|
|
|
def news_comment_added(comment)
|
|
|
|
|
news = comment.commented
|
|
|
|
|
if news.project
|
|
|
|
|
redmine_headers 'Project' => news.project.identifier
|
|
|
|
|
@author = comment.author
|
|
|
|
|
message_id comment
|
|
|
|
@ -348,6 +391,18 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
mail :to => news.recipients,
|
|
|
|
|
:cc => news.watcher_recipients,
|
|
|
|
|
:subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}"
|
|
|
|
|
elsif news.course
|
|
|
|
|
redmine_headers 'Course' => news.course.id
|
|
|
|
|
@author = comment.author
|
|
|
|
|
message_id comment
|
|
|
|
|
@news = news
|
|
|
|
|
@comment = comment
|
|
|
|
|
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
|
|
|
|
|
recipients = news.course.notified_users.select { |user| user.allowed_to?(:view_files, news.course) }.collect { |u| u.mail }
|
|
|
|
|
|
|
|
|
|
mail :to => recipients,
|
|
|
|
|
:subject => "[#{news.course.name}] #{l(:label_news)}: #{news.title}"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Builds a Mail::Message object used to email the recipients of the specified message that was posted.
|
|
|
|
@ -356,6 +411,7 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
# message_posted(message) => Mail::Message object
|
|
|
|
|
# Mailer.message_posted(message).deliver => sends an email to the recipients
|
|
|
|
|
def message_posted(message)
|
|
|
|
|
if message.project
|
|
|
|
|
redmine_headers 'Project' => message.project.identifier,
|
|
|
|
|
'Topic-Id' => (message.parent_id || message.id)
|
|
|
|
|
@author = message.author
|
|
|
|
@ -368,6 +424,20 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
mail :to => recipients,
|
|
|
|
|
:cc => cc,
|
|
|
|
|
:subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}"
|
|
|
|
|
elsif message.course
|
|
|
|
|
redmine_headers 'Course' => message.course.id,
|
|
|
|
|
'Topic-Id' => (message.parent_id || message.id)
|
|
|
|
|
@author = message.author
|
|
|
|
|
message_id message
|
|
|
|
|
references message.parent unless message.parent.nil?
|
|
|
|
|
recipients = message.course.notified_users.select { |user| user.allowed_to?(:view_files, message.course) }.collect { |u| u.mail }
|
|
|
|
|
cc = ((message.root.watcher_recipients + message.board.watcher_recipients).uniq - recipients)
|
|
|
|
|
@message = message
|
|
|
|
|
@message_url = url_for(message.event_url)
|
|
|
|
|
mail :to => recipients,
|
|
|
|
|
:cc => cc,
|
|
|
|
|
:subject => "[#{message.board.course.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Builds a Mail::Message object used to email the recipients of a project of the specified wiki content was added.
|
|
|
|
|