foodsoft/plugins/messages/lib/foodsoft_messages/user_link.rb

23 lines
660 B
Ruby
Raw Permalink Normal View History

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
def show_user_link(user = @current_user)
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),
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.include FoodsoftMessages::UserLink
2014-03-07 09:51:24 +01:00
end