activity_stream_log.rb 815 B

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. module Ticket::ActivityStreamLog
  3. =begin
  4. log activity for this object
  5. ticket = Ticket.find(123)
  6. result = ticket.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. ActivityStream.add(
  16. :o_id => self['id'],
  17. :type => type,
  18. :object => self.class.name,
  19. :group_id => self['group_id'],
  20. :role => role,
  21. :created_at => self.updated_at,
  22. :created_by_id => user_id,
  23. )
  24. end
  25. end