2012-12-24 13:55:43 +00:00
|
|
|
class Observer::Ticket::Article::FillupFromGeneral < ActiveRecord::Observer
|
|
|
|
observe 'ticket::_article'
|
|
|
|
|
|
|
|
def before_create(record)
|
|
|
|
|
|
|
|
# return if we run import mode
|
|
|
|
return if Setting.get('import_mode')
|
|
|
|
|
|
|
|
# if sender is customer, do not change anything
|
2013-01-01 20:29:26 +00:00
|
|
|
sender = Ticket::Article::Sender.lookup( :id => record.ticket_article_sender_id )
|
2012-12-24 13:55:43 +00:00
|
|
|
return if sender == nil
|
|
|
|
return if sender['name'] == 'Customer'
|
|
|
|
|
|
|
|
# set from if not given
|
|
|
|
if !record.from
|
|
|
|
user = User.find( record.created_by_id )
|
|
|
|
record.from = "#{user.firstname} #{user.lastname}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|