2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2013-06-12 15:59:58 +00:00
|
|
|
|
2021-06-23 11:35:27 +00:00
|
|
|
module SessionHelper::CollectionBase
|
2020-10-05 14:26:25 +00:00
|
|
|
|
|
|
|
module_function
|
|
|
|
|
2021-07-16 13:38:01 +00:00
|
|
|
def session(collections, assets, user)
|
2012-10-18 08:10:12 +00:00
|
|
|
|
|
|
|
# all base stuff
|
2016-03-31 13:41:34 +00:00
|
|
|
collections[ Locale.to_app_model ] = Locale.where(active: true)
|
2015-04-27 06:20:52 +00:00
|
|
|
|
2016-03-31 13:41:34 +00:00
|
|
|
collections[ Taskbar.to_app_model ] = Taskbar.where(user_id: user.id)
|
2017-10-01 12:25:52 +00:00
|
|
|
collections[ Taskbar.to_app_model ].each do |item|
|
2014-08-02 21:54:54 +00:00
|
|
|
assets = item.assets(assets)
|
2017-10-01 12:25:52 +00:00
|
|
|
end
|
2012-10-18 08:10:12 +00:00
|
|
|
|
2018-03-20 12:16:17 +00:00
|
|
|
collections[ OnlineNotification.to_app_model ] = []
|
|
|
|
OnlineNotification.list(user, 200).each do |item|
|
|
|
|
assets = item.assets(assets)
|
|
|
|
end
|
2014-08-26 07:40:25 +00:00
|
|
|
|
2018-03-20 12:16:17 +00:00
|
|
|
collections[ RecentView.to_app_model ] = []
|
|
|
|
RecentView.list(user, 10).each do |item|
|
|
|
|
assets = item.assets(assets)
|
|
|
|
end
|
2014-08-26 14:30:16 +00:00
|
|
|
|
2016-08-12 16:39:09 +00:00
|
|
|
collections[ Permission.to_app_model ] = []
|
2017-10-01 12:25:52 +00:00
|
|
|
Permission.all.each do |item|
|
2016-08-12 16:39:09 +00:00
|
|
|
assets = item.assets(assets)
|
2017-10-01 12:25:52 +00:00
|
|
|
end
|
2016-08-12 16:39:09 +00:00
|
|
|
|
2014-08-13 00:12:38 +00:00
|
|
|
collections[ Role.to_app_model ] = []
|
2017-10-01 12:25:52 +00:00
|
|
|
Role.all.each do |item|
|
2014-08-02 21:54:54 +00:00
|
|
|
assets = item.assets(assets)
|
2017-10-01 12:25:52 +00:00
|
|
|
end
|
2014-08-02 21:54:54 +00:00
|
|
|
|
2014-08-13 00:12:38 +00:00
|
|
|
collections[ Group.to_app_model ] = []
|
2017-10-01 12:25:52 +00:00
|
|
|
Group.all.each do |item|
|
2014-08-02 21:54:54 +00:00
|
|
|
assets = item.assets(assets)
|
2017-10-01 12:25:52 +00:00
|
|
|
end
|
2015-09-23 15:22:31 +00:00
|
|
|
|
|
|
|
collections[ Organization.to_app_model ] = []
|
|
|
|
if user.organization_id
|
2017-10-01 12:25:52 +00:00
|
|
|
Organization.where(id: user.organization_id).each do |item|
|
2014-08-02 21:54:54 +00:00
|
|
|
assets = item.assets(assets)
|
2017-10-01 12:25:52 +00:00
|
|
|
end
|
2012-11-12 09:34:22 +00:00
|
|
|
end
|
2015-09-23 15:22:31 +00:00
|
|
|
|
2021-08-25 12:24:42 +00:00
|
|
|
if user.permissions?(['admin.core_workflow'])
|
|
|
|
collections['CoreWorkflowCustomModule'] = CoreWorkflow::Custom.list.map { |m| { name: m } }
|
|
|
|
end
|
|
|
|
|
2014-08-26 07:40:25 +00:00
|
|
|
[collections, assets]
|
2012-10-18 08:10:12 +00:00
|
|
|
end
|
2015-04-27 14:15:29 +00:00
|
|
|
end
|