trabajo-afectivo/lib/session_helper/collection_base.rb

56 lines
1.4 KiB
Ruby
Raw Normal View History

# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
module SessionHelper::CollectionBase
module_function
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 do |item|
assets = item.assets(assets)
end
2012-10-18 08:10:12 +00:00
collections[ OnlineNotification.to_app_model ] = []
OnlineNotification.list(user, 200).each do |item|
assets = item.assets(assets)
end
collections[ RecentView.to_app_model ] = []
RecentView.list(user, 10).each do |item|
assets = item.assets(assets)
end
collections[ Permission.to_app_model ] = []
Permission.all.each do |item|
assets = item.assets(assets)
end
collections[ Role.to_app_model ] = []
Role.all.each do |item|
assets = item.assets(assets)
end
collections[ Group.to_app_model ] = []
Group.all.each do |item|
assets = item.assets(assets)
end
collections[ Organization.to_app_model ] = []
if user.organization_id
Organization.where(id: user.organization_id).each do |item|
assets = item.assets(assets)
end
2012-11-12 09:34:22 +00:00
end
if user.permissions?(['admin.core_workflow'])
collections['CoreWorkflowCustomModule'] = CoreWorkflow::Custom.list.map { |m| { name: m } }
end
[collections, assets]
2012-10-18 08:10:12 +00:00
end
end