trabajo-afectivo/app/models/application_model/activity_stream_base.rb

38 lines
881 B
Ruby
Raw Normal View History

2013-09-28 00:07:11 +00:00
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
module ApplicationModel::ActivityStreamBase
=begin
log activity for this object
article = Ticket::Article.find(123)
result = article.activity_stream_log( 'created', user_id )
2013-10-07 03:38:07 +00:00
# force log
result = article.activity_stream_log( 'created', user_id, true )
2013-09-28 00:07:11 +00:00
returns
result = true # false
=end
2013-10-07 03:38:07 +00:00
def activity_stream_log (type, user_id, force = false)
role = self.class.activity_stream_support_config[:role]
updated_at = self.updated_at
if force
updated_at = Time.new
end
2013-09-28 00:07:11 +00:00
ActivityStream.add(
:o_id => self['id'],
:type => type,
:object => self.class.name,
2013-09-29 21:37:49 +00:00
:group_id => self['group_id'],
:role => role,
2013-10-07 03:38:07 +00:00
:created_at => updated_at,
2013-09-28 00:07:11 +00:00
:created_by_id => user_id,
)
end
end