activity_stream_base.rb 960 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. module ApplicationModel::ActivityStreamBase
  3. =begin
  4. log activity for this object
  5. article = Ticket::Article.find(123)
  6. result = article.activity_stream_log( 'created', user_id )
  7. # force log
  8. result = article.activity_stream_log( 'created', user_id, true )
  9. returns
  10. result = true # false
  11. =end
  12. def activity_stream_log (type, user_id, force = false)
  13. # return if we run import mode
  14. return if Setting.get('import_mode')
  15. role = self.class.activity_stream_support_config[:role]
  16. updated_at = self.updated_at
  17. if force
  18. updated_at = Time.new
  19. end
  20. ActivityStream.add(
  21. :o_id => self['id'],
  22. :type => type,
  23. :object => self.class.name,
  24. :group_id => self['group_id'],
  25. :role => role,
  26. :created_at => updated_at,
  27. :created_by_id => user_id,
  28. )
  29. end
  30. end