collection_base.rb 1009 B

12345678910111213141516171819202122232425262728293031323334353637
  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. assets = {}
  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[ Role.to_app_model ] = []
  11. Role.all.each {|item|
  12. assets = item.assets(assets)
  13. }
  14. collections[ Group.to_app_model ] = []
  15. Group.all.each {|item|
  16. assets = item.assets(assets)
  17. }
  18. if !user.is_role('Customer')
  19. collections[ Organization.to_app_model ] = []
  20. Organization.all.each {|item|
  21. assets = item.assets(assets)
  22. }
  23. else
  24. if user.organization_id
  25. collections[ Organization.to_app_model ] = []
  26. Organization.where( :id => user.organization_id ).each {|item|
  27. assets = item.assets(assets)
  28. }
  29. end
  30. end
  31. end
  32. module_function :session
  33. end