assets.rb 687 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
  2. class History
  3. module Assets
  4. extend ActiveSupport::Concern
  5. =begin
  6. get all assets / related models for this history entry
  7. history = History.find(123)
  8. result = history.assets(assets_if_exists)
  9. returns
  10. result = {
  11. :users => {
  12. 123 => user_model_123,
  13. 1234 => user_model_1234,
  14. }
  15. }
  16. =end
  17. def assets(data)
  18. app_model = User.to_app_model
  19. if !data[ app_model ] || !data[ app_model ][ self['created_by_id'] ]
  20. user = User.lookup(id: self['created_by_id'])
  21. if user
  22. data = user.assets(data)
  23. end
  24. end
  25. data
  26. end
  27. end
  28. end