|
|
|
@ -45,7 +45,6 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
MailerProxy.new(self)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# author: alan
|
|
|
|
|
# 发送邀请未注册用户加入项目邮件
|
|
|
|
|
# 功能: 在加入项目的同时自动注册用户
|
|
|
|
|
def send_invite_in_project(email, project, invitor)
|
|
|
|
@ -101,16 +100,16 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
course_ids = courses.map {|course| course.id}.join(",")
|
|
|
|
|
|
|
|
|
|
# 查询user的缺陷,包括发布的,跟踪的以及被指派的缺陷
|
|
|
|
|
sql = "select DISTINCT i.* from issues i, watchers w
|
|
|
|
|
where (i.assigned_to_id = #{user.id} or i.author_id = #{user.id}
|
|
|
|
|
or (w.watchable_type = 'Issue' and w.watchable_id = i.id and w.user_id = #{user.id}))
|
|
|
|
|
and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc"
|
|
|
|
|
# sql = "select DISTINCT i.* from issues i, watchers w
|
|
|
|
|
# where (i.assigned_to_id = #{user.id} or i.author_id = #{user.id}
|
|
|
|
|
# or (w.watchable_type = 'Issue' and w.watchable_id = i.id and w.user_id = #{user.id}))
|
|
|
|
|
# and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc"
|
|
|
|
|
sql = "select DISTINCT i.* from issues i where (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc"
|
|
|
|
|
@issues = Issue.find_by_sql(sql)
|
|
|
|
|
|
|
|
|
|
# @bids 查询课程作业,包括老师发布的作业,以及user提交作业
|
|
|
|
|
# @attachments查询课程课件更新
|
|
|
|
|
@attachments ||= []
|
|
|
|
|
|
|
|
|
|
@bids ||= [] # 老师发布的作业
|
|
|
|
|
|
|
|
|
|
unless courses.first.nil?
|
|
|
|
@ -142,9 +141,9 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
# 查询user在课程中发布的通知,项目中发的新闻
|
|
|
|
|
@course_news = (course_ids && !course_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n
|
|
|
|
|
where n.course_id in (#{course_ids})
|
|
|
|
|
and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : []
|
|
|
|
|
and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : []
|
|
|
|
|
@project_news = (project_ids && !project_ids.empty?) ? News.find_by_sql("select DISTINCT n.* from news n where n.project_id in (#{project_ids})
|
|
|
|
|
and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : []
|
|
|
|
|
and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc") : []
|
|
|
|
|
|
|
|
|
|
# 查询user在课程及个人中留言
|
|
|
|
|
@course_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT * from journals_for_messages where
|
|
|
|
@ -165,7 +164,7 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
}
|
|
|
|
|
mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}"
|
|
|
|
|
#有内容才发,没有不发
|
|
|
|
|
mail :to => user.mail,:subject => subject if has_content
|
|
|
|
|
mail :to => user.mail, :subject => subject if has_content
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 公共讨论区发帖、回帖添加邮件发送信息
|
|
|
|
@ -188,8 +187,8 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
:subject => "[ #{l(:label_message_plural)} : #{memo.subject} #{l(:label_memo_create_succ)}]",
|
|
|
|
|
:filter => true
|
|
|
|
|
end
|
|
|
|
|
# Builds a Mail::Message object used to email recipients of the added journals for message.
|
|
|
|
|
|
|
|
|
|
# Builds a Mail::Message object used to email recipients of the added journals for message.
|
|
|
|
|
# 留言分为直接留言,和对留言人留言的回复
|
|
|
|
|
# 字段说明在JournalsForMessage.rb
|
|
|
|
|
# 直接留言后 reply_id,m_parent_id 为空,相对应的at_user取值为nil
|
|
|
|
@ -511,7 +510,7 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Builds a Mail::Message object used to email recipients of a news' project when a news comment is added.
|
|
|
|
|
#
|
|
|
|
|
# 新增新闻评论时邮件通知
|
|
|
|
|
# Example:
|
|
|
|
|
# news_comment_added(comment) => Mail::Message object
|
|
|
|
|
# Mailer.news_comment_added(comment) => sends an email to the news' project recipients
|
|
|
|
@ -526,9 +525,9 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
@comment = comment
|
|
|
|
|
@news_url = url_for(:controller => 'news', :action => 'show', :id => news)
|
|
|
|
|
mail :to => news.recipients,
|
|
|
|
|
:cc => news.watcher_recipients,
|
|
|
|
|
:subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}",
|
|
|
|
|
:filter => true
|
|
|
|
|
:cc => news.watcher_recipients,
|
|
|
|
|
:subject => "Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}",
|
|
|
|
|
:filter => true
|
|
|
|
|
elsif news.course
|
|
|
|
|
redmine_headers 'Course' => news.course.id
|
|
|
|
|
@author = comment.author
|
|
|
|
@ -563,9 +562,9 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
@message = message
|
|
|
|
|
@message_url = url_for(message.event_url)
|
|
|
|
|
mail :to => recipients,
|
|
|
|
|
:cc => cc,
|
|
|
|
|
:subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}",
|
|
|
|
|
:filter => true
|
|
|
|
|
:cc => cc,
|
|
|
|
|
:subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}",
|
|
|
|
|
:filter => true
|
|
|
|
|
elsif message.course
|
|
|
|
|
redmine_headers 'Course' => message.course.id,
|
|
|
|
|
'Topic-Id' => (message.parent_id || message.id)
|
|
|
|
@ -909,10 +908,11 @@ class Mailer < ActionMailer::Base
|
|
|
|
|
if email.attachments && email.attachments.any?
|
|
|
|
|
email.attachments.each do |attachment|
|
|
|
|
|
obj.attachments << Attachment.create(:container => obj,
|
|
|
|
|
:file => attachment.decoded,
|
|
|
|
|
:filename => attachment.filename,
|
|
|
|
|
:author => user,
|
|
|
|
|
:content_type => attachment.mime_type)
|
|
|
|
|
:file => attachment.decoded,
|
|
|
|
|
:filename => attachment.filename,
|
|
|
|
|
:author => user,
|
|
|
|
|
|
|
|
|
|
:content_type => attachment.mime_type)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|