fillup_from_general.rb 653 B

12345678910111213141516171819202122
  1. # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
  2. class Observer::Ticket::Article::FillupFromGeneral < ActiveRecord::Observer
  3. observe 'ticket::_article'
  4. def before_create(record)
  5. # return if we run import mode
  6. return if Setting.get('import_mode')
  7. # if sender is customer, do not change anything
  8. sender = Ticket::Article::Sender.lookup( :id => record.sender_id )
  9. return if sender == nil
  10. return if sender['name'] == 'Customer'
  11. # set from if not given
  12. if !record.from
  13. user = User.find( record.created_by_id )
  14. record.from = "#{user.firstname} #{user.lastname}"
  15. end
  16. end
  17. end