collection_base.rb 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module SessionHelper::CollectionBase
  3. module_function
  4. def session(collections, assets, user)
  5. # all base stuff
  6. collections[ Locale.to_app_model ] = Locale.where(active: true)
  7. collections[ User::OverviewSorting.to_app_model ] = User::OverviewSorting.where(user: user)
  8. collections[ Taskbar.to_app_model ] = Taskbar.where(user_id: user.id, app: :desktop)
  9. collections[ Taskbar.to_app_model ].each do |item|
  10. assets = item.assets(assets)
  11. end
  12. collections[ OnlineNotification.to_app_model ] = []
  13. OnlineNotification.list(user).each do |item|
  14. assets = item.assets(assets)
  15. end
  16. collections[ RecentView.to_app_model ] = []
  17. RecentView.list(user, 10).each do |item|
  18. assets = item.assets(assets)
  19. end
  20. collections[ Permission.to_app_model ] = []
  21. Permission.all.each do |item|
  22. assets = item.assets(assets)
  23. end
  24. collections[ Role.to_app_model ] = []
  25. Role.all.each do |item|
  26. assets = item.assets(assets)
  27. end
  28. collections[ Group.to_app_model ] = []
  29. Group.all.each do |item|
  30. assets = item.assets(assets)
  31. end
  32. collections[ Organization.to_app_model ] = []
  33. if user.organization_id
  34. Organization.where(id: user.organization_id).each do |item|
  35. assets = item.assets(assets)
  36. end
  37. end
  38. if user.permissions?(['admin.core_workflow'])
  39. collections['CoreWorkflowCustomModule'] = CoreWorkflow::Custom.list.map { |m| { name: m } }
  40. end
  41. [collections, assets]
  42. end
  43. end