collection_base.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. module ExtraCollection
  3. def session( collections, user )
  4. # all base stuff
  5. collections[ Taskbar.to_app_model ] = Taskbar.where( :user_id => user.id )
  6. collections[ Role.to_app_model ] = Role.all
  7. collections[ Group.to_app_model ] = Group.all
  8. if !user.is_role('Customer')
  9. collections[ Organization.to_app_model ] = Organization.all
  10. else
  11. if user.organization_id
  12. collections[ Organization.to_app_model ] = Organization.where( :id => user.organization_id )
  13. end
  14. end
  15. end
  16. def push( collections, user )
  17. # all base stuff
  18. collections[ Role.to_app_model ] = Role.all
  19. collections[ Group.to_app_model ] = Group.all
  20. if !user.is_role('Customer')
  21. collections[ Organization.to_app_model ] = Organization.all
  22. else
  23. if user.organization_id
  24. collections[ Organization.to_app_model ] = Organization.where( :id => user.organization_id )
  25. end
  26. end
  27. end
  28. module_function :session, :push
  29. end