##// END OF EJS Templates
Now, when a user turns mail notifications off, he will still receive notifications about issue changes if he is the author or the assignee of the issue....
Jean-Philippe Lang -
r587:fd2839c833b6
parent child
Show More
@@ -1,106 +1,116
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 class Mailer < ActionMailer::Base
18 class Mailer < ActionMailer::Base
19 helper IssuesHelper
19 helper IssuesHelper
20
20
21 def account_information(user, password)
21 def account_information(user, password)
22 set_language_if_valid user.language
22 set_language_if_valid user.language
23 recipients user.mail
23 recipients user.mail
24 from Setting.mail_from
24 from Setting.mail_from
25 subject l(:mail_subject_register)
25 subject l(:mail_subject_register)
26 body :user => user, :password => password
26 body :user => user, :password => password
27 end
27 end
28
28
29 def issue_add(issue)
29 def issue_add(issue)
30 set_language_if_valid(Setting.default_language)
30 set_language_if_valid(Setting.default_language)
31 # Sends to all project members
31 # Sends to all project members
32 @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact
32 @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact
33 # Sends to author and assignee (even if they turned off mail notification)
34 @recipients << issue.author.mail
35 @recipients << issue.assigned_to.mail
36 @recipients.compact!
37 @recipients.uniq!
33 @from = Setting.mail_from
38 @from = Setting.mail_from
34 @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
39 @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
35 @body['issue'] = issue
40 @body['issue'] = issue
36 end
41 end
37
42
38 def issue_edit(journal)
43 def issue_edit(journal)
39 set_language_if_valid(Setting.default_language)
44 set_language_if_valid(Setting.default_language)
40 # Sends to all project members
45 # Sends to all project members
41 issue = journal.journalized
46 issue = journal.journalized
42 @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }.compact
47 @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }
48 # Sends to author and assignee (even if they turned off mail notification)
49 @recipients << issue.author.mail
50 @recipients << issue.assigned_to.mail
51 @recipients.compact!
52 @recipients.uniq!
43 # Watchers in cc
53 # Watchers in cc
44 @cc = issue.watcher_recipients - @recipients
54 @cc = issue.watcher_recipients - @recipients
45 @from = Setting.mail_from
55 @from = Setting.mail_from
46 @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
56 @subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] #{issue.status.name} - #{issue.subject}"
47 @body['issue'] = issue
57 @body['issue'] = issue
48 @body['journal']= journal
58 @body['journal']= journal
49 end
59 end
50
60
51 def document_add(document)
61 def document_add(document)
52 set_language_if_valid(Setting.default_language)
62 set_language_if_valid(Setting.default_language)
53 @recipients = document.project.users.collect { |u| u.mail if u.mail_notification }.compact
63 @recipients = document.project.users.collect { |u| u.mail if u.mail_notification }.compact
54 @from = Setting.mail_from
64 @from = Setting.mail_from
55 @subject = "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
65 @subject = "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
56 @body['document'] = document
66 @body['document'] = document
57 end
67 end
58
68
59 def attachments_add(attachments)
69 def attachments_add(attachments)
60 set_language_if_valid(Setting.default_language)
70 set_language_if_valid(Setting.default_language)
61 container = attachments.first.container
71 container = attachments.first.container
62 url = "http://#{Setting.host_name}/"
72 url = "http://#{Setting.host_name}/"
63 added_to = ""
73 added_to = ""
64 case container.class.to_s
74 case container.class.to_s
65 when 'Version'
75 when 'Version'
66 url << "projects/list_files/#{container.project_id}"
76 url << "projects/list_files/#{container.project_id}"
67 added_to = "#{l(:label_version)}: #{container.name}"
77 added_to = "#{l(:label_version)}: #{container.name}"
68 when 'Document'
78 when 'Document'
69 url << "documents/show/#{container.id}"
79 url << "documents/show/#{container.id}"
70 added_to = "#{l(:label_document)}: #{container.title}"
80 added_to = "#{l(:label_document)}: #{container.title}"
71 when 'Issue'
81 when 'Issue'
72 url << "issues/show/#{container.id}"
82 url << "issues/show/#{container.id}"
73 added_to = "#{container.tracker.name} ##{container.id}: #{container.subject}"
83 added_to = "#{container.tracker.name} ##{container.id}: #{container.subject}"
74 end
84 end
75 @recipients = container.project.users.collect { |u| u.mail if u.mail_notification }.compact
85 @recipients = container.project.users.collect { |u| u.mail if u.mail_notification }.compact
76 @from = Setting.mail_from
86 @from = Setting.mail_from
77 @subject = "[#{container.project.name}] #{l(:label_attachment_new)}"
87 @subject = "[#{container.project.name}] #{l(:label_attachment_new)}"
78 @body['attachments'] = attachments
88 @body['attachments'] = attachments
79 @body['url'] = url
89 @body['url'] = url
80 @body['added_to'] = added_to
90 @body['added_to'] = added_to
81 end
91 end
82
92
83 def lost_password(token)
93 def lost_password(token)
84 set_language_if_valid(token.user.language)
94 set_language_if_valid(token.user.language)
85 @recipients = token.user.mail
95 @recipients = token.user.mail
86 @from = Setting.mail_from
96 @from = Setting.mail_from
87 @subject = l(:mail_subject_lost_password)
97 @subject = l(:mail_subject_lost_password)
88 @body['token'] = token
98 @body['token'] = token
89 end
99 end
90
100
91 def register(token)
101 def register(token)
92 set_language_if_valid(token.user.language)
102 set_language_if_valid(token.user.language)
93 @recipients = token.user.mail
103 @recipients = token.user.mail
94 @from = Setting.mail_from
104 @from = Setting.mail_from
95 @subject = l(:mail_subject_register)
105 @subject = l(:mail_subject_register)
96 @body['token'] = token
106 @body['token'] = token
97 end
107 end
98
108
99 def message_posted(message, recipients)
109 def message_posted(message, recipients)
100 set_language_if_valid(Setting.default_language)
110 set_language_if_valid(Setting.default_language)
101 @recipients = recipients
111 @recipients = recipients
102 @from = Setting.mail_from
112 @from = Setting.mail_from
103 @subject = "[#{message.board.project.name} - #{message.board.name}] #{message.subject}"
113 @subject = "[#{message.board.project.name} - #{message.board.name}] #{message.subject}"
104 @body['message'] = message
114 @body['message'] = message
105 end
115 end
106 end
116 end
General Comments 0
You need to be logged in to leave comments. Login now