activity_stream_log.rb 886 B

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