##// END OF EJS Templates
Replaced hard-coded urls in Mailer#attachments_add...
Jean-Philippe Lang -
r658:db4781d06860
parent child
Show More
@@ -1,123 +1,123
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)
33 # Sends to author and assignee (even if they turned off mail notification)
34 @recipients << issue.author.mail if issue.author
34 @recipients << issue.author.mail if issue.author
35 @recipients << issue.assigned_to.mail if issue.assigned_to
35 @recipients << issue.assigned_to.mail if issue.assigned_to
36 @recipients.compact!
36 @recipients.compact!
37 @recipients.uniq!
37 @recipients.uniq!
38 @from = Setting.mail_from
38 @from = Setting.mail_from
39 @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}"
40 @body['issue'] = issue
40 @body['issue'] = issue
41 end
41 end
42
42
43 def issue_edit(journal)
43 def issue_edit(journal)
44 set_language_if_valid(Setting.default_language)
44 set_language_if_valid(Setting.default_language)
45 # Sends to all project members
45 # Sends to all project members
46 issue = journal.journalized
46 issue = journal.journalized
47 @recipients = issue.project.members.collect { |m| m.user.mail if m.user.mail_notification }
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)
48 # Sends to author and assignee (even if they turned off mail notification)
49 @recipients << issue.author.mail if issue.author
49 @recipients << issue.author.mail if issue.author
50 @recipients << issue.assigned_to.mail if issue.assigned_to
50 @recipients << issue.assigned_to.mail if issue.assigned_to
51 @recipients.compact!
51 @recipients.compact!
52 @recipients.uniq!
52 @recipients.uniq!
53 # Watchers in cc
53 # Watchers in cc
54 @cc = issue.watcher_recipients - @recipients
54 @cc = issue.watcher_recipients - @recipients
55 @from = Setting.mail_from
55 @from = Setting.mail_from
56 @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}"
57 @body['issue'] = issue
57 @body['issue'] = issue
58 @body['journal']= journal
58 @body['journal']= journal
59 end
59 end
60
60
61 def document_add(document)
61 def document_add(document)
62 set_language_if_valid(Setting.default_language)
62 set_language_if_valid(Setting.default_language)
63 @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
64 @from = Setting.mail_from
64 @from = Setting.mail_from
65 @subject = "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
65 @subject = "[#{document.project.name}] #{l(:label_document_new)}: #{document.title}"
66 @body['document'] = document
66 @body['document'] = document
67 end
67 end
68
68
69 def attachments_add(attachments)
69 def attachments_add(attachments)
70 set_language_if_valid(Setting.default_language)
70 set_language_if_valid(Setting.default_language)
71 container = attachments.first.container
71 container = attachments.first.container
72 url = "http://#{Setting.host_name}/"
72 url = ''
73 added_to = ""
73 added_to = ''
74 case container.class.to_s
74 case container.class.name
75 when 'Version'
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 added_to = "#{l(:label_version)}: #{container.name}"
77 added_to = "#{l(:label_version)}: #{container.name}"
78 when 'Document'
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 added_to = "#{l(:label_document)}: #{container.title}"
80 added_to = "#{l(:label_document)}: #{container.title}"
81 when 'Issue'
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 added_to = "#{container.tracker.name} ##{container.id}: #{container.subject}"
83 added_to = "#{container.tracker.name} ##{container.id}: #{container.subject}"
84 end
84 end
85 @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
86 @from = Setting.mail_from
86 @from = Setting.mail_from
87 @subject = "[#{container.project.name}] #{l(:label_attachment_new)}"
87 @subject = "[#{container.project.name}] #{l(:label_attachment_new)}"
88 @body['attachments'] = attachments
88 @body['attachments'] = attachments
89 @body['url'] = url
89 @body['url'] = url
90 @body['added_to'] = added_to
90 @body['added_to'] = added_to
91 end
91 end
92
92
93 def lost_password(token)
93 def lost_password(token)
94 set_language_if_valid(token.user.language)
94 set_language_if_valid(token.user.language)
95 @recipients = token.user.mail
95 @recipients = token.user.mail
96 @from = Setting.mail_from
96 @from = Setting.mail_from
97 @subject = l(:mail_subject_lost_password)
97 @subject = l(:mail_subject_lost_password)
98 @body['token'] = token
98 @body['token'] = token
99 end
99 end
100
100
101 def register(token)
101 def register(token)
102 set_language_if_valid(token.user.language)
102 set_language_if_valid(token.user.language)
103 @recipients = token.user.mail
103 @recipients = token.user.mail
104 @from = Setting.mail_from
104 @from = Setting.mail_from
105 @subject = l(:mail_subject_register)
105 @subject = l(:mail_subject_register)
106 @body['token'] = token
106 @body['token'] = token
107 end
107 end
108
108
109 def message_posted(message, recipients)
109 def message_posted(message, recipients)
110 set_language_if_valid(Setting.default_language)
110 set_language_if_valid(Setting.default_language)
111 @recipients = recipients
111 @recipients = recipients
112 @from = Setting.mail_from
112 @from = Setting.mail_from
113 @subject = "[#{message.board.project.name} - #{message.board.name}] #{message.subject}"
113 @subject = "[#{message.board.project.name} - #{message.board.name}] #{message.subject}"
114 @body['message'] = message
114 @body['message'] = message
115 end
115 end
116
116
117 def test(user)
117 def test(user)
118 set_language_if_valid(user.language)
118 set_language_if_valid(user.language)
119 @recipients = user.mail
119 @recipients = user.mail
120 @from = Setting.mail_from
120 @from = Setting.mail_from
121 @subject = 'Redmine'
121 @subject = 'Redmine'
122 end
122 end
123 end
123 end
General Comments 0
You need to be logged in to leave comments. Login now