history_log.rb 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Copyright (C) 2012-2013 Zammad Foundation, httpdata[://zammad-foundation.org/
  2. module Ticket::Article::HistoryLog
  3. =begin
  4. create log activity for this article
  5. article = Ticket::Article.find(123)
  6. result = article.history_create( 'created', user_id )
  7. returns
  8. result = true # false
  9. =end
  10. def history_create (type, user_id, data = {})
  11. # if Ticketdata[:data[:Article has changed, remember related ticket to be able
  12. # to show article changes in ticket history
  13. data[:o_id] = self['id']
  14. data[:history_type] = type
  15. data[:history_object] = self.class.name
  16. data[:related_o_id] = self['ticket_id']
  17. data[:related_history_object] = 'Ticket'
  18. data[:created_by_id] = user_id
  19. History.add(data)
  20. end
  21. =begin
  22. get log activity for this article
  23. article = Ticket::Article.find(123)
  24. result = article.history_get()
  25. returns
  26. result = [
  27. {
  28. :history_type => 'created',
  29. :history_object => 'Ticket::Article',
  30. :created_by_id => 3,
  31. :created_at => "2013-08-19 20:41:33",
  32. },
  33. {
  34. :history_type => 'updated',
  35. :history_object => 'Ticket::Article',
  36. :history_attribute => 'from',
  37. :o_id => 1,
  38. :id_to => nil,
  39. :id_from => nil,
  40. :value_from => "Some Body",
  41. :value_to => "Some Body Else",
  42. :created_by_id => 3,
  43. :created_at => "2013-08-19 20:41:33",
  44. },
  45. ]
  46. =end
  47. def history_get
  48. History.list( self.class.name, self['id'] )
  49. end
  50. end