comparison app/models/mailer.rb @ 909:cbb26bc654de redmine-1.3

Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author Chris Cannam
date Fri, 24 Feb 2012 19:09:32 +0000
parents cbce1fd3b1b7
children 5e80956cc792 5f33065ddc4b
comparison
equal deleted inserted replaced
908:c6c2cbd0afee 909:cbb26bc654de
72 s << "(#{issue.status.name}) " if journal.new_value_for('status_id') 72 s << "(#{issue.status.name}) " if journal.new_value_for('status_id')
73 s << issue.subject 73 s << issue.subject
74 subject s 74 subject s
75 body :issue => issue, 75 body :issue => issue,
76 :journal => journal, 76 :journal => journal,
77 :issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue) 77 :issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}")
78 78
79 render_multipart('issue_edit', body) 79 render_multipart('issue_edit', body)
80 end 80 end
81 81
82 def reminder(user, issues, days) 82 def reminder(user, issues, days)
83 set_language_if_valid user.language 83 set_language_if_valid user.language
84 recipients user.mail 84 recipients user.mail
85 subject l(:mail_subject_reminder, :count => issues.size, :days => days) 85 subject l(:mail_subject_reminder, :count => issues.size, :days => days)
86 body :issues => issues, 86 body :issues => issues,
87 :days => days, 87 :days => days,
88 :issues_url => url_for(:controller => 'issues', :action => 'index', :set_filter => 1, :assigned_to_id => user.id, :sort => 'due_date:asc') 88 :issues_url => url_for(:controller => 'issues', :action => 'index',
89 :set_filter => 1, :assigned_to_id => user.id,
90 :sort => 'due_date:asc')
89 render_multipart('reminder', body) 91 render_multipart('reminder', body)
90 end 92 end
91 93
92 # Builds a tmail object used to email users belonging to the added document's project. 94 # Builds a tmail object used to email users belonging to the added document's project.
93 # 95 #
196 message_id wiki_content 198 message_id wiki_content
197 recipients wiki_content.recipients 199 recipients wiki_content.recipients
198 cc(wiki_content.page.wiki.watcher_recipients - recipients) 200 cc(wiki_content.page.wiki.watcher_recipients - recipients)
199 subject "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :id => wiki_content.page.pretty_title)}" 201 subject "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_added, :id => wiki_content.page.pretty_title)}"
200 body :wiki_content => wiki_content, 202 body :wiki_content => wiki_content,
201 :wiki_content_url => url_for(:controller => 'wiki', :action => 'show', :project_id => wiki_content.project, :id => wiki_content.page.title) 203 :wiki_content_url => url_for(:controller => 'wiki', :action => 'show',
204 :project_id => wiki_content.project,
205 :id => wiki_content.page.title)
202 render_multipart('wiki_content_added', body) 206 render_multipart('wiki_content_added', body)
203 end 207 end
204 208
205 # Builds a tmail object used to email the recipients of a project of the specified wiki content was updated. 209 # Builds a tmail object used to email the recipients of a project of the specified wiki content was updated.
206 # 210 #
213 message_id wiki_content 217 message_id wiki_content
214 recipients wiki_content.recipients 218 recipients wiki_content.recipients
215 cc(wiki_content.page.wiki.watcher_recipients + wiki_content.page.watcher_recipients - recipients) 219 cc(wiki_content.page.wiki.watcher_recipients + wiki_content.page.watcher_recipients - recipients)
216 subject "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :id => wiki_content.page.pretty_title)}" 220 subject "[#{wiki_content.project.name}] #{l(:mail_subject_wiki_content_updated, :id => wiki_content.page.pretty_title)}"
217 body :wiki_content => wiki_content, 221 body :wiki_content => wiki_content,
218 :wiki_content_url => url_for(:controller => 'wiki', :action => 'show', :project_id => wiki_content.project, :id => wiki_content.page.title), 222 :wiki_content_url => url_for(:controller => 'wiki', :action => 'show',
219 :wiki_diff_url => url_for(:controller => 'wiki', :action => 'diff', :project_id => wiki_content.project, :id => wiki_content.page.title, :version => wiki_content.version) 223 :project_id => wiki_content.project,
224 :id => wiki_content.page.title),
225 :wiki_diff_url => url_for(:controller => 'wiki', :action => 'diff',
226 :project_id => wiki_content.project, :id => wiki_content.page.title,
227 :version => wiki_content.version)
220 render_multipart('wiki_content_updated', body) 228 render_multipart('wiki_content_updated', body)
221 end 229 end
222 230
223 # Builds a tmail object used to email the specified user their account information. 231 # Builds a tmail object used to email the specified user their account information.
224 # 232 #
243 def account_activation_request(user) 251 def account_activation_request(user)
244 # Send the email to all active administrators 252 # Send the email to all active administrators
245 recipients User.active.find(:all, :conditions => {:admin => true}).collect { |u| u.mail }.compact 253 recipients User.active.find(:all, :conditions => {:admin => true}).collect { |u| u.mail }.compact
246 subject l(:mail_subject_account_activation_request, Setting.app_title) 254 subject l(:mail_subject_account_activation_request, Setting.app_title)
247 body :user => user, 255 body :user => user,
248 :url => url_for(:controller => 'users', :action => 'index', :status => User::STATUS_REGISTERED, :sort_key => 'created_on', :sort_order => 'desc') 256 :url => url_for(:controller => 'users', :action => 'index',
257 :status => User::STATUS_REGISTERED,
258 :sort_key => 'created_on', :sort_order => 'desc')
249 render_multipart('account_activation_request', body) 259 render_multipart('account_activation_request', body)
250 end 260 end
251 261
252 # Builds a tmail object used to email the specified user that their account was activated by an administrator. 262 # Builds a tmail object used to email the specified user that their account was activated by an administrator.
253 # 263 #
366 376
367 # Common headers 377 # Common headers
368 headers 'X-Mailer' => 'Redmine', 378 headers 'X-Mailer' => 'Redmine',
369 'X-Redmine-Host' => Setting.host_name, 379 'X-Redmine-Host' => Setting.host_name,
370 'X-Redmine-Site' => Setting.app_title, 380 'X-Redmine-Site' => Setting.app_title,
371 'Precedence' => 'bulk', 381 'X-Auto-Response-Suppress' => 'OOF',
372 'Auto-Submitted' => 'auto-generated' 382 'Auto-Submitted' => 'auto-generated'
373 end 383 end
374 384
375 # Appends a Redmine header field (name is prepended with 'X-Redmine-') 385 # Appends a Redmine header field (name is prepended with 'X-Redmine-')
376 def redmine_headers(h) 386 def redmine_headers(h)
408 # https://rails.lighthouseapp.com/projects/8994/tickets/1799-actionmailer-doesnt-set-template_format-when-rendering-layouts 418 # https://rails.lighthouseapp.com/projects/8994/tickets/1799-actionmailer-doesnt-set-template_format-when-rendering-layouts
409 419
410 def render_multipart(method_name, body) 420 def render_multipart(method_name, body)
411 if Setting.plain_text_mail? 421 if Setting.plain_text_mail?
412 content_type "text/plain" 422 content_type "text/plain"
413 body render(:file => "#{method_name}.text.plain.rhtml", :body => body, :layout => 'mailer.text.plain.erb') 423 body render(:file => "#{method_name}.text.erb",
424 :body => body,
425 :layout => 'mailer.text.erb')
414 else 426 else
415 content_type "multipart/alternative" 427 content_type "multipart/alternative"
416 part :content_type => "text/plain", :body => render(:file => "#{method_name}.text.plain.rhtml", :body => body, :layout => 'mailer.text.plain.erb') 428 part :content_type => "text/plain",
417 part :content_type => "text/html", :body => render_message("#{method_name}.text.html.rhtml", body) 429 :body => render(:file => "#{method_name}.text.erb",
430 :body => body, :layout => 'mailer.text.erb')
431 part :content_type => "text/html",
432 :body => render_message("#{method_name}.html.erb", body)
418 end 433 end
419 end 434 end
420 435
421 # Makes partial rendering work with Rails 1.2 (retro-compatibility) 436 # Makes partial rendering work with Rails 1.2 (retro-compatibility)
422 def self.controller_path 437 def self.controller_path
444 @references_objects ||= [] 459 @references_objects ||= []
445 @references_objects << object 460 @references_objects << object
446 end 461 end
447 462
448 def mylogger 463 def mylogger
449 RAILS_DEFAULT_LOGGER 464 Rails.logger
450 end 465 end
451 end 466 end
452 467
453 # Patch TMail so that message_id is not overwritten 468 # Patch TMail so that message_id is not overwritten
454 module TMail 469 module TMail