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