2014-03-07 09:51:24 +01:00
|
|
|
module FoodsoftMessages
|
|
|
|
module UserLink
|
|
|
|
def self.included(base) # :nodoc:
|
|
|
|
base.class_eval do
|
|
|
|
# modify user presentation link to writing a message for the user
|
2021-03-01 15:27:26 +01:00
|
|
|
def show_user_link(user = @current_user)
|
2015-01-14 21:15:08 +01:00
|
|
|
if user.nil? || !FoodsoftMessages.enabled?
|
2014-03-07 09:51:24 +01:00
|
|
|
show_user user
|
|
|
|
else
|
|
|
|
link_to show_user(user), new_message_path('message[mail_to]' => user.id),
|
2021-03-01 15:27:26 +01:00
|
|
|
:title => I18n.t('helpers.messages.write_message')
|
2014-03-07 09:51:24 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# modify existing helper
|
|
|
|
ActiveSupport.on_load(:after_initialize) do
|
|
|
|
ApplicationHelper.send :include, FoodsoftMessages::UserLink
|
|
|
|
end
|