collection_base.rb 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. module ExtraCollection
  3. def session( collections, assets, user )
  4. # all base stuff
  5. collections[ Locale.to_app_model ] = Locale.where( active: true )
  6. collections[ Taskbar.to_app_model ] = Taskbar.where( user_id: user.id )
  7. collections[ Taskbar.to_app_model ].each {|item|
  8. assets = item.assets(assets)
  9. }
  10. collections[ OnlineNotification.to_app_model ] = OnlineNotification.list(user, 50)
  11. assets = ApplicationModel.assets_of_object_list(collections[ OnlineNotification.to_app_model ], assets)
  12. collections[ RecentView.to_app_model ] = RecentView.list(user, 10)
  13. assets = RecentView.assets_of_object_list(collections[ RecentView.to_app_model ], assets)
  14. collections[ Role.to_app_model ] = []
  15. Role.all.each {|item|
  16. assets = item.assets(assets)
  17. }
  18. collections[ Group.to_app_model ] = []
  19. Group.all.each {|item|
  20. assets = item.assets(assets)
  21. }
  22. collections[ Organization.to_app_model ] = []
  23. if user.organization_id
  24. Organization.where( id: user.organization_id ).each {|item|
  25. assets = item.assets(assets)
  26. }
  27. end
  28. [collections, assets]
  29. end
  30. module_function :session
  31. end