# HG changeset patch # User Chris Cannam # Date 1315575338 -3600 # Node ID 1ee95265342fdd6a0de1cd6723f929f565b62c1b # Parent 0c5674b65db066082ed116e05fd6f1d7779f3748# Parent 0c872fe7779700fa0425723baf96fd8fd78ccab4 Merge diff -r 0c5674b65db0 -r 1ee95265342f vendor/plugins/redmine_bibliography/app/models/publication.rb --- a/vendor/plugins/redmine_bibliography/app/models/publication.rb Fri Sep 09 14:34:48 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb Fri Sep 09 14:35:38 2011 +0100 @@ -32,9 +32,10 @@ # Returns the mail adresses of users that should be notified def notify_authors - + self.authors.each do |author| - Mailer.deliver_added_to_new_publication(author.user, self) unless author.user.nil? + Rails.logger.debug { "Sending mail to \"#{self.title}\" publication authors." } + Mailer.deliver_publication_added(author.user, self) unless author.user.nil? end end diff -r 0c5674b65db0 -r 1ee95265342f vendor/plugins/redmine_bibliography/app/views/mailer/publication_added.text.html.rhtml --- a/vendor/plugins/redmine_bibliography/app/views/mailer/publication_added.text.html.rhtml Fri Sep 09 14:34:48 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/mailer/publication_added.text.html.rhtml Fri Sep 09 14:35:38 2011 +0100 @@ -1,2 +1,3 @@ -

<%= l(:notice_account_activated) %>

-

<%= l(:label_login) %>: <%= link_to @login_url, @login_url %>

+<%= link_to(h(@publication.title), @publication_url) %>
+
+<%= textilizable(@publication, :title, :only_path => false) %> diff -r 0c5674b65db0 -r 1ee95265342f vendor/plugins/redmine_bibliography/app/views/mailer/publication_added.text.plain.rhtml --- a/vendor/plugins/redmine_bibliography/app/views/mailer/publication_added.text.plain.rhtml Fri Sep 09 14:34:48 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/mailer/publication_added.text.plain.rhtml Fri Sep 09 14:35:38 2011 +0100 @@ -1,2 +1,3 @@ -<%= l(:notice_account_activated) %> -<%= l(:label_login) %>: <%= @login_url %> +<%= @publication.title %> +<%= @publication_url %> + diff -r 0c5674b65db0 -r 1ee95265342f vendor/plugins/redmine_bibliography/init.rb --- a/vendor/plugins/redmine_bibliography/init.rb Fri Sep 09 14:34:48 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/init.rb Fri Sep 09 14:35:38 2011 +0100 @@ -7,6 +7,7 @@ Dispatcher.to_prepare :redmine_model_dependencies do require_dependency 'project' require_dependency 'user' + require_dependency 'mailer' unless Project.included_modules.include? Bibliography::ProjectPublicationsPatch Project.send(:include, Bibliography::ProjectPublicationsPatch) @@ -15,6 +16,12 @@ unless User.included_modules.include? Bibliography::UserAuthorPatch User.send(:include, Bibliography::UserAuthorPatch) end + + unless Mailer.included_modules.include? Bibliography::MailerPatch + Mailer.send(:include, Bibliography::MailerPatch) + end + + end diff -r 0c5674b65db0 -r 1ee95265342f vendor/plugins/redmine_bibliography/lib/bibliography/mailer_patch.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/lib/bibliography/mailer_patch.rb Fri Sep 09 14:35:38 2011 +0100 @@ -0,0 +1,28 @@ +require_dependency 'mailer' + +module Bibliography + module MailerPatch + def self.included(base) # :nodoc: + + # Builds a tmail object used to email the specified user that a publication was created and the user is + # an author of that publication + # + # Example: + # publication_added(user) => tmail object + # Mailer.deliver_add_to_project(user) => sends an email to the registered user + def publication_added(user, publication) + + @publication = publication + + set_language_if_valid user.language + recipients user.mail + subject l(:mail_subject_publication_added, Setting.app_title) + body :publication_url => url_for( :controller => 'publications', :action => 'show', :id => publication.id ), + :publication_title => publication.title + render_multipart('publication_added', body) + end + + + end + end +end