trabajo-afectivo/app/models/observer/ticket/article/fillup_from_general.rb

23 lines
668 B
Ruby
Raw Normal View History

2014-02-03 19:23:00 +00:00
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
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
sender = Ticket::Article::Sender.lookup( :id => record.ticket_article_sender_id )
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