trabajo-afectivo/app/controllers/sessions/collection_base.rb

46 lines
1.4 KiB
Ruby
Raw Normal View History

2014-02-03 19:24:49 +00:00
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
2012-10-18 08:10:12 +00:00
module ExtraCollection
def session( collections, assets, user )
2012-10-18 08:10:12 +00:00
# all base stuff
collections[ Locale.to_app_model ] = Locale.where( active: true )
2015-04-27 06:20:52 +00:00
collections[ Taskbar.to_app_model ] = Taskbar.where( user_id: user.id )
collections[ Taskbar.to_app_model ].each {|item|
assets = item.assets(assets)
}
2012-10-18 08:10:12 +00:00
2015-04-01 20:14:25 +00:00
collections[ OnlineNotification.to_app_model ] = OnlineNotification.list(user, 30)
assets = ApplicationModel.assets_of_object_list(collections[ OnlineNotification.to_app_model ], assets)
collections[ RecentView.to_app_model ] = RecentView.list(user, 10)
assets = RecentView.assets_of_object_list(collections[ RecentView.to_app_model ], assets)
collections[ Role.to_app_model ] = []
Role.all.each {|item|
assets = item.assets(assets)
}
collections[ Group.to_app_model ] = []
Group.all.each {|item|
assets = item.assets(assets)
}
if !user.role?(Z_ROLENAME_CUSTOMER)
collections[ Organization.to_app_model ] = []
Organization.all.each {|item|
assets = item.assets(assets)
}
2013-07-19 14:21:44 +00:00
else
if user.organization_id
collections[ Organization.to_app_model ] = []
Organization.where( id: user.organization_id ).each {|item|
assets = item.assets(assets)
}
2013-07-19 14:21:44 +00:00
end
2012-11-12 09:34:22 +00:00
end
[collections, assets]
2012-10-18 08:10:12 +00:00
end
module_function :session
end