search_index.rb 660 B

123456789101112131415161718192021222324252627282930
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. class User
  3. module SearchIndex
  4. =begin
  5. get data to store in search index
  6. user = User.find(123)
  7. result = user.search_index_data
  8. returns
  9. result = true # false
  10. =end
  11. def search_index_data
  12. attributes = { 'fullname' => "#{ self['firstname'] } #{ self['lastname'] }" }
  13. %w(login firstname lastname phone email address city country note created_at).each { |key|
  14. if self[key] && (!self.respond_to?('empty?') || !self[key].empty?)
  15. attributes[key] = self[key]
  16. end
  17. }
  18. return if attributes.empty?
  19. attributes
  20. end
  21. end
  22. end