activity_stream_log.rb 807 B

123456789101112131415161718192021222324252627282930313233
  1. # Copyright (C) 2012-2013 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 !self.class.activity_stream_support_config
  12. role = self.class.activity_stream_support_config[:role]
  13. ticket = Ticket.lookup( :id => self.ticket_id )
  14. ActivityStream.add(
  15. :o_id => self['id'],
  16. :type => type,
  17. :object => self.class.name,
  18. :group_id => ticket.group_id,
  19. :role => role,
  20. :created_at => self.updated_at,
  21. :created_by_id => user_id,
  22. )
  23. end
  24. end