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

27 lines
688 B
Ruby
Raw 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')
end
end
end
end
end
end
# modify existing helper
ActiveSupport.on_load(:after_initialize) do
ApplicationHelper.send :include, FoodsoftMessages::UserLink
end