2013-06-12 15:59:58 +00:00
|
|
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2012-10-18 08:10:12 +00:00
|
|
|
module ExtraCollection
|
2012-10-23 20:25:42 +00:00
|
|
|
def session( collections, user )
|
2012-10-18 08:10:12 +00:00
|
|
|
|
|
|
|
# all base stuff
|
2013-09-21 22:40:19 +00:00
|
|
|
collections[ Taskbar.to_online_model ] = Taskbar.where( :user_id => user.id )
|
|
|
|
collections[ Role.to_online_model ] = Role.all
|
|
|
|
collections[ Group.to_online_model ] = Group.all
|
2012-10-18 08:10:12 +00:00
|
|
|
|
2012-11-12 09:34:22 +00:00
|
|
|
if !user.is_role('Customer')
|
2013-09-21 22:40:19 +00:00
|
|
|
collections[ Organization.to_online_model ] = Organization.all
|
2013-07-19 14:21:44 +00:00
|
|
|
else
|
|
|
|
if user.organization_id
|
2013-09-21 22:40:19 +00:00
|
|
|
collections[ Organization.to_online_model ] = Organization.where( :id => user.organization_id )
|
2013-07-19 14:21:44 +00:00
|
|
|
end
|
2012-11-12 09:34:22 +00:00
|
|
|
end
|
2012-10-18 08:10:12 +00:00
|
|
|
end
|
2012-10-23 20:25:42 +00:00
|
|
|
def push( collections, user )
|
2012-10-23 19:12:00 +00:00
|
|
|
|
|
|
|
# all base stuff
|
2013-09-21 22:40:19 +00:00
|
|
|
collections[ Role.to_online_model ] = Role.all
|
|
|
|
collections[ Group.to_online_model ] = Group.all
|
2012-10-23 19:12:00 +00:00
|
|
|
|
2012-11-12 09:34:22 +00:00
|
|
|
if !user.is_role('Customer')
|
2013-09-21 22:40:19 +00:00
|
|
|
collections[ Organization.to_online_model ] = Organization.all
|
2013-07-19 14:21:44 +00:00
|
|
|
else
|
|
|
|
if user.organization_id
|
2013-09-21 22:40:19 +00:00
|
|
|
collections[ Organization.to_online_model ] = Organization.where( :id => user.organization_id )
|
2013-07-19 14:21:44 +00:00
|
|
|
end
|
2012-11-12 09:34:22 +00:00
|
|
|
end
|
2012-10-23 19:12:00 +00:00
|
|
|
end
|
|
|
|
module_function :session, :push
|
2013-05-31 16:56:11 +00:00
|
|
|
end
|