Extract message system to plugin.

This commit is contained in:
Robert Waltemath 2014-03-07 09:51:24 +01:00 committed by wvengen
parent fe0b17cdb0
commit 7556c753d0
45 changed files with 298 additions and 45 deletions

View file

@ -0,0 +1,6 @@
require "foodsoft_messages/engine"
require "foodsoft_messages/user_link"
require "deface"
module FoodsoftMessages
end

View file

@ -0,0 +1,11 @@
module FoodsoftMessages
class Engine < ::Rails::Engine
def navigation(primary, context)
item = SimpleNavigation::Item.new(primary, :messages, I18n.t('navigation.messages'), context.messages_path)
sub_nav = primary[:foodcoop].sub_navigation
# display right before tasks item
tasks_index = sub_nav.items.index(sub_nav[:tasks])
sub_nav.items.insert(tasks_index, item)
end
end
end

View file

@ -0,0 +1,26 @@
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?
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

View file

@ -0,0 +1,3 @@
module FoodsoftMessages
VERSION = "0.0.1"
end