Revision 723:d41bf754c0f2 vendor/plugins/redmine_bibliography/lib/bibliography
| vendor/plugins/redmine_bibliography/lib/bibliography/mailer_patch.rb | ||
|---|---|---|
| 1 |
require_dependency 'mailer' |
|
| 2 |
|
|
| 3 |
module Bibliography |
|
| 4 |
module MailerPatch |
|
| 5 |
def self.included(base) # :nodoc: |
|
| 6 |
|
|
| 7 |
# Builds a tmail object used to email the specified user that a publication was created and the user is |
|
| 8 |
# an author of that publication |
|
| 9 |
# |
|
| 10 |
# Example: |
|
| 11 |
# publication_added(user) => tmail object |
|
| 12 |
# Mailer.deliver_add_to_project(user) => sends an email to the registered user |
|
| 13 |
def publication_added(user, publication, project) |
|
| 14 |
|
|
| 15 |
@publication = publication |
|
| 16 |
@project = project |
|
| 17 |
|
|
| 18 |
set_language_if_valid user.language |
|
| 19 |
recipients user.mail |
|
| 20 |
subject l(:mail_subject_publication_added, Setting.app_title) |
|
| 21 |
body :publication_url => url_for( :controller => 'publications', :action => 'show', :id => publication.id ), |
|
| 22 |
:publication_title => publication.title |
|
| 23 |
|
|
| 24 |
render_multipart('publication_added', body)
|
|
| 25 |
|
|
| 26 |
end |
|
| 27 |
|
|
| 28 |
|
|
| 29 |
end |
|
| 30 |
end |
|
| 31 |
end |
|
| vendor/plugins/redmine_bibliography/lib/bibliography/project_publications_patch.rb | ||
|---|---|---|
| 1 |
require_dependency 'project' |
|
| 2 |
|
|
| 3 |
module Bibliography |
|
| 4 |
module ProjectPublicationsPatch |
|
| 5 |
def self.included(base) |
|
| 6 |
base.class_eval do |
|
| 7 |
has_and_belongs_to_many :publications, :uniq => true |
|
| 8 |
|
|
| 9 |
named_scope :like, lambda {|q|
|
|
| 10 |
s = "%#{q.to_s.strip.downcase}%"
|
|
| 11 |
{:conditions => ["LOWER(name) LIKE :s OR LOWER(homepage) LIKE :s", {:s => s}],
|
|
| 12 |
:order => 'name' |
|
| 13 |
} |
|
| 14 |
} |
|
| 15 |
end |
|
| 16 |
end #self.included |
|
| 17 |
|
|
| 18 |
module ProjectMethods |
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
end #ProjectMethods |
|
| 24 |
end #ProjectPublicationsPatch |
|
| 25 |
end #RedmineBibliography |
|
| vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb | ||
|---|---|---|
| 1 |
require_dependency 'user' |
|
| 2 |
|
|
| 3 |
module Bibliography |
|
| 4 |
module UserAuthorPatch |
|
| 5 |
def self.included(base) |
|
| 6 |
base.send(:include, InstanceMethods) |
|
| 7 |
extend ClassMethods |
|
| 8 |
|
|
| 9 |
end #self.included |
|
| 10 |
|
|
| 11 |
module ClassMethods |
|
| 12 |
end |
|
| 13 |
|
|
| 14 |
module InstanceMethods |
|
| 15 |
|
|
| 16 |
def institution |
|
| 17 |
unless self.ssamr_user_detail.nil? |
|
| 18 |
institution_name = self.ssamr_user_detail.institution_name |
|
| 19 |
else |
|
| 20 |
institution_name = "No Institution Set" |
|
| 21 |
end |
|
| 22 |
return institution_name |
|
| 23 |
end |
|
| 24 |
|
|
| 25 |
def get_author_info |
|
| 26 |
# TODO: DELETE THIS METHOD?? |
|
| 27 |
info = {
|
|
| 28 |
:name_on_paper => self.name, |
|
| 29 |
:email => self.mail, |
|
| 30 |
:institution => "", |
|
| 31 |
:author_user_id => self.id, |
|
| 32 |
:is_user => "1" |
|
| 33 |
} |
|
| 34 |
|
|
| 35 |
if not self.ssamr_user_detail.nil? |
|
| 36 |
info[:institution] = self.ssamr_user_detail.institution_name |
|
| 37 |
end |
|
| 38 |
|
|
| 39 |
return info |
|
| 40 |
end |
|
| 41 |
|
|
| 42 |
end #InstanceMethods |
|
| 43 |
|
|
| 44 |
end #UserPublicationsPatch |
|
| 45 |
end #RedmineBibliography |
|
Also available in: Unified diff