Improved name spaces.
This commit is contained in:
parent
0095f24af7
commit
0dc6e96a5a
7 changed files with 255 additions and 234 deletions
|
@ -251,6 +251,9 @@ class Package < ApplicationModel
|
||||||
|
|
||||||
# prebuild assets
|
# prebuild assets
|
||||||
|
|
||||||
|
# reload new files
|
||||||
|
Package.reload_classes
|
||||||
|
|
||||||
# delete package
|
# delete package
|
||||||
record = Package.where(
|
record = Package.where(
|
||||||
:name => meta[:name],
|
:name => meta[:name],
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
module Auth
|
||||||
|
end
|
||||||
module Auth::ENV
|
module Auth::ENV
|
||||||
def self.check( user, username, password, config )
|
def self.check( user, username, password, config )
|
||||||
|
|
||||||
|
@ -14,4 +16,4 @@ module Auth::ENV
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,3 +1,5 @@
|
||||||
|
module Auth
|
||||||
|
end
|
||||||
module Auth::INTERNAL
|
module Auth::INTERNAL
|
||||||
def self.check( user, username, password, config )
|
def self.check( user, username, password, config )
|
||||||
|
|
||||||
|
@ -12,4 +14,4 @@ module Auth::INTERNAL
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,3 +1,5 @@
|
||||||
|
module Auth
|
||||||
|
end
|
||||||
module Auth::LDAP
|
module Auth::LDAP
|
||||||
def self.check( user, username, password, config )
|
def self.check( user, username, password, config )
|
||||||
|
|
||||||
|
@ -10,4 +12,4 @@ module Auth::LDAP
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,4 +1,6 @@
|
||||||
class Auth::OTRS
|
module Auth
|
||||||
|
end
|
||||||
|
module Auth::OTRS
|
||||||
def self.check( user, username, password, config )
|
def self.check( user, username, password, config )
|
||||||
|
|
||||||
endpoint = Setting.get('import_otrs_endpoint')
|
endpoint = Setting.get('import_otrs_endpoint')
|
||||||
|
@ -57,4 +59,4 @@ class Auth::OTRS
|
||||||
|
|
||||||
return user
|
return user
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,3 +1,5 @@
|
||||||
|
module Auth
|
||||||
|
end
|
||||||
module Auth::TEST
|
module Auth::TEST
|
||||||
def self.check( user, username, password, config )
|
def self.check( user, username, password, config )
|
||||||
|
|
||||||
|
@ -8,4 +10,4 @@ module Auth::TEST
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,3 +1,5 @@
|
||||||
|
module Import
|
||||||
|
end
|
||||||
module Import::OTRS
|
module Import::OTRS
|
||||||
def self.request(part)
|
def self.request(part)
|
||||||
url = Setting.get('import_otrs_endpoint') + '/' + part + ';Key=' + Setting.get('import_otrs_endpoint_key')
|
url = Setting.get('import_otrs_endpoint') + '/' + part + ';Key=' + Setting.get('import_otrs_endpoint_key')
|
||||||
|
@ -85,7 +87,8 @@ module Import::OTRS
|
||||||
result = JSON.parse( response.body )
|
result = JSON.parse( response.body )
|
||||||
result = result.reverse
|
result = result.reverse
|
||||||
|
|
||||||
thread_count = 8
|
Thread.abort_on_exception = true
|
||||||
|
thread_count = 2
|
||||||
threads = {}
|
threads = {}
|
||||||
(1..thread_count).each {|thread|
|
(1..thread_count).each {|thread|
|
||||||
threads[thread] = Thread.new {
|
threads[thread] = Thread.new {
|
||||||
|
@ -158,6 +161,10 @@ module Import::OTRS
|
||||||
}
|
}
|
||||||
|
|
||||||
result.each {|record|
|
result.each {|record|
|
||||||
|
|
||||||
|
# use transaction
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
|
|
||||||
ticket_new = {
|
ticket_new = {
|
||||||
:title => '',
|
:title => '',
|
||||||
:created_by_id => 1,
|
:created_by_id => 1,
|
||||||
|
@ -176,7 +183,7 @@ module Import::OTRS
|
||||||
#puts 'TICKET OLD ' + ticket_old.inspect
|
#puts 'TICKET OLD ' + ticket_old.inspect
|
||||||
# find user
|
# find user
|
||||||
if ticket_new[:owner]
|
if ticket_new[:owner]
|
||||||
user = User.where( :login => ticket_new[:owner] ).first
|
user = User.lookup( :login => ticket_new[:owner] )
|
||||||
if user
|
if user
|
||||||
ticket_new[:owner_id] = user.id
|
ticket_new[:owner_id] = user.id
|
||||||
else
|
else
|
||||||
|
@ -184,239 +191,240 @@ module Import::OTRS
|
||||||
end
|
end
|
||||||
ticket_new.delete(:owner)
|
ticket_new.delete(:owner)
|
||||||
end
|
end
|
||||||
if ticket_new[:customer]
|
if ticket_new[:customer]
|
||||||
user = User.where( :login => ticket_new[:customer] ).first
|
user = User.lookup( :login => ticket_new[:customer] )
|
||||||
if user
|
if user
|
||||||
ticket_new[:customer_id] = user.id
|
ticket_new[:customer_id] = user.id
|
||||||
else
|
else
|
||||||
ticket_new[:customer_id] = 1
|
ticket_new[:customer_id] = 1
|
||||||
end
|
end
|
||||||
ticket_new.delete(:customer)
|
ticket_new.delete(:customer)
|
||||||
else
|
else
|
||||||
ticket_new[:customer_id] = 1
|
ticket_new[:customer_id] = 1
|
||||||
end
|
end
|
||||||
# puts 'ttt' + ticket_new.inspect
|
# puts 'ttt' + ticket_new.inspect
|
||||||
# set state types
|
# set state types
|
||||||
if ticket_old
|
if ticket_old
|
||||||
puts "update Ticket.find(#{ticket_new[:id]})"
|
puts "update Ticket.find(#{ticket_new[:id]})"
|
||||||
ticket_old.update_attributes(ticket_new)
|
ticket_old.update_attributes(ticket_new)
|
||||||
else
|
else
|
||||||
puts "add Ticket.find(#{ticket_new[:id]})"
|
puts "add Ticket.find(#{ticket_new[:id]})"
|
||||||
ticket = Ticket.new(ticket_new)
|
ticket = Ticket.new(ticket_new)
|
||||||
ticket.id = ticket_new[:id]
|
ticket.id = ticket_new[:id]
|
||||||
ticket.save
|
ticket.save
|
||||||
end
|
|
||||||
|
|
||||||
record['Articles'].each { |article|
|
|
||||||
|
|
||||||
# get article values
|
|
||||||
article_new = {
|
|
||||||
:created_by_id => 1,
|
|
||||||
:updated_by_id => 1,
|
|
||||||
}
|
|
||||||
map[:Article].each { |key,value|
|
|
||||||
if article[key.to_s]
|
|
||||||
article_new[value] = Encode.conv( 'utf8', article[key.to_s] )
|
|
||||||
end
|
end
|
||||||
}
|
|
||||||
# create customer/sender if needed
|
record['Articles'].each { |article|
|
||||||
if article_new[:ticket_article_sender] == 'customer' && article_new[:created_by_id].to_i == 1 && !article_new[:from].empty?
|
|
||||||
# set extra headers
|
# get article values
|
||||||
begin
|
article_new = {
|
||||||
email = Mail::Address.new( article_new[:from] ).address
|
:created_by_id => 1,
|
||||||
rescue
|
:updated_by_id => 1,
|
||||||
email = article_new[:from]
|
}
|
||||||
if article_new[:from] =~ /<(.+?)>/
|
map[:Article].each { |key,value|
|
||||||
email = $1
|
if article[key.to_s]
|
||||||
|
article_new[value] = Encode.conv( 'utf8', article[key.to_s] )
|
||||||
|
end
|
||||||
|
}
|
||||||
|
# create customer/sender if needed
|
||||||
|
if article_new[:ticket_article_sender] == 'customer' && article_new[:created_by_id].to_i == 1 && !article_new[:from].empty?
|
||||||
|
# set extra headers
|
||||||
|
begin
|
||||||
|
email = Mail::Address.new( article_new[:from] ).address
|
||||||
|
rescue
|
||||||
|
email = article_new[:from]
|
||||||
|
if article_new[:from] =~ /<(.+?)>/
|
||||||
|
email = $1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
user = User.where( :email => email ).first
|
||||||
|
if !user
|
||||||
|
begin
|
||||||
|
display_name = Mail::Address.new( article_new[:from] ).display_name ||
|
||||||
|
( Mail::Address.new( article_new[:from] ).comments && Mail::Address.new( article_new[:from] ).comments[0] )
|
||||||
|
rescue
|
||||||
|
display_name = article_new[:from]
|
||||||
|
end
|
||||||
|
|
||||||
|
# do extra decoding because we needed to use field.value
|
||||||
|
display_name = Mail::Field.new( 'X-From', display_name ).to_s
|
||||||
|
|
||||||
|
roles = Role.lookup( :name => 'Customer' )
|
||||||
|
user = User.create(
|
||||||
|
:login => email,
|
||||||
|
:firstname => display_name,
|
||||||
|
:lastname => '',
|
||||||
|
:email => email,
|
||||||
|
:password => '',
|
||||||
|
:active => true,
|
||||||
|
:roles => roles,
|
||||||
|
:updated_by_id => 1,
|
||||||
|
:created_by_id => 1,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
article_new[:created_by_id] = user.id
|
||||||
end
|
end
|
||||||
end
|
|
||||||
user = User.where( :email => email ).first
|
if article_new[:ticket_article_sender] == 'customer'
|
||||||
if !user
|
article_new[:ticket_article_sender_id] = Ticket::Article::Sender.lookup( :name => 'Customer' ).id
|
||||||
begin
|
article_new.delete( :ticket_article_sender )
|
||||||
display_name = Mail::Address.new( article_new[:from] ).display_name ||
|
|
||||||
( Mail::Address.new( article_new[:from] ).comments && Mail::Address.new( article_new[:from] ).comments[0] )
|
|
||||||
rescue
|
|
||||||
display_name = article_new[:from]
|
|
||||||
end
|
end
|
||||||
|
if article_new[:ticket_article_sender] == 'agent'
|
||||||
# do extra decoding because we needed to use field.value
|
article_new[:ticket_article_sender_id] = Ticket::Article::Sender.lookup( :name => 'Agent' ).id
|
||||||
display_name = Mail::Field.new( 'X-From', display_name ).to_s
|
article_new.delete( :ticket_article_sender )
|
||||||
|
|
||||||
roles = Role.where( :name => 'Customer' )
|
|
||||||
user = User.create(
|
|
||||||
:login => email,
|
|
||||||
:firstname => display_name,
|
|
||||||
:lastname => '',
|
|
||||||
:email => email,
|
|
||||||
:password => '',
|
|
||||||
:active => true,
|
|
||||||
:roles => roles,
|
|
||||||
:updated_by_id => 1,
|
|
||||||
:created_by_id => 1,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
article_new[:created_by_id] = user.id
|
|
||||||
end
|
|
||||||
|
|
||||||
if article_new[:ticket_article_sender] == 'customer'
|
|
||||||
article_new[:ticket_article_sender_id] = Ticket::Article::Sender.lookup( :name => 'Customer' ).id
|
|
||||||
article_new.delete( :ticket_article_sender )
|
|
||||||
end
|
|
||||||
if article_new[:ticket_article_sender] == 'agent'
|
|
||||||
article_new[:ticket_article_sender_id] = Ticket::Article::Sender.lookup( :name => 'Agent' ).id
|
|
||||||
article_new.delete( :ticket_article_sender )
|
|
||||||
end
|
|
||||||
if article_new[:ticket_article_sender] == 'system'
|
|
||||||
article_new[:ticket_article_sender_id] = Ticket::Article::Sender.lookup( :name => 'System' ).id
|
|
||||||
article_new.delete( :ticket_article_sender )
|
|
||||||
end
|
|
||||||
|
|
||||||
if article_new[:ticket_article_type] == 'email-external'
|
|
||||||
article_new[:ticket_article_type_id] = Ticket::Article::Type.lookup( :name => 'email' ).id
|
|
||||||
article_new[:internal] = false
|
|
||||||
elsif article_new[:ticket_article_type] == 'email-internal'
|
|
||||||
article_new[:ticket_article_type_id] = Ticket::Article::Type.lookup( :name => 'email' ).id
|
|
||||||
article_new[:internal] = true
|
|
||||||
elsif article_new[:ticket_article_type] == 'note-external'
|
|
||||||
article_new[:ticket_article_type_id] = Ticket::Article::Type.lookup( :name => 'note' ).id
|
|
||||||
article_new[:internal] = false
|
|
||||||
elsif article_new[:ticket_article_type] == 'note-internal'
|
|
||||||
article_new[:ticket_article_type_id] = Ticket::Article::Type.lookup( :name => 'note' ).id
|
|
||||||
article_new[:internal] = true
|
|
||||||
elsif article_new[:ticket_article_type] == 'phone'
|
|
||||||
article_new[:ticket_article_type_id] = Ticket::Article::Type.lookup( :name => 'phone' ).id
|
|
||||||
article_new[:internal] = false
|
|
||||||
elsif article_new[:ticket_article_type] == 'webrequest'
|
|
||||||
article_new[:ticket_article_type_id] = Ticket::Article::Type.lookup( :name => 'web' ).id
|
|
||||||
article_new[:internal] = false
|
|
||||||
else
|
|
||||||
article_new[:ticket_article_type_id] = 9
|
|
||||||
end
|
|
||||||
article_new.delete( :ticket_article_type )
|
|
||||||
article_old = Ticket::Article.where( :id => article_new[:id] ).first
|
|
||||||
#puts 'ARTICLE OLD ' + article_old.inspect
|
|
||||||
# set state types
|
|
||||||
if article_old
|
|
||||||
puts "update Ticket::Article.find(#{article_new[:id]})"
|
|
||||||
# puts article_new.inspect
|
|
||||||
article_old.update_attributes(article_new)
|
|
||||||
else
|
|
||||||
puts "add Ticket::Article.find(#{article_new[:id]})"
|
|
||||||
article = Ticket::Article.new(article_new)
|
|
||||||
article.id = article_new[:id]
|
|
||||||
article.save
|
|
||||||
end
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
record['History'].each { |history|
|
|
||||||
# puts '-------'
|
|
||||||
# puts history.inspect
|
|
||||||
if history['HistoryType'] == 'NewTicket'
|
|
||||||
History.history_create(
|
|
||||||
:id => history['HistoryID'],
|
|
||||||
:o_id => history['TicketID'],
|
|
||||||
:history_type => 'created',
|
|
||||||
:history_object => 'Ticket',
|
|
||||||
:created_at => history['CreateTime'],
|
|
||||||
:created_by_id => history['CreateBy']
|
|
||||||
)
|
|
||||||
end
|
|
||||||
if history['HistoryType'] == 'StateUpdate'
|
|
||||||
data = history['Name']
|
|
||||||
# "%%new%%open%%"
|
|
||||||
from = nil
|
|
||||||
to = nil
|
|
||||||
if data =~ /%%(.+?)%%(.+?)%%/
|
|
||||||
from = $1
|
|
||||||
to = $2
|
|
||||||
state_from = Ticket::State.lookup( :name => from )
|
|
||||||
state_to = Ticket::State.lookup( :name => to )
|
|
||||||
if state_from
|
|
||||||
from_id = state_from.id
|
|
||||||
end
|
end
|
||||||
if state_to
|
if article_new[:ticket_article_sender] == 'system'
|
||||||
to_id = state_to.id
|
article_new[:ticket_article_sender_id] = Ticket::Article::Sender.lookup( :name => 'System' ).id
|
||||||
|
article_new.delete( :ticket_article_sender )
|
||||||
end
|
end
|
||||||
end
|
|
||||||
# puts "STATE UPDATE (#{history['HistoryID']}): -> #{from}->#{to}"
|
if article_new[:ticket_article_type] == 'email-external'
|
||||||
History.history_create(
|
article_new[:ticket_article_type_id] = Ticket::Article::Type.lookup( :name => 'email' ).id
|
||||||
:id => history['HistoryID'],
|
article_new[:internal] = false
|
||||||
:o_id => history['TicketID'],
|
elsif article_new[:ticket_article_type] == 'email-internal'
|
||||||
:history_type => 'updated',
|
article_new[:ticket_article_type_id] = Ticket::Article::Type.lookup( :name => 'email' ).id
|
||||||
:history_object => 'Ticket',
|
article_new[:internal] = true
|
||||||
:history_attribute => 'ticket_state',
|
elsif article_new[:ticket_article_type] == 'note-external'
|
||||||
:value_from => from,
|
article_new[:ticket_article_type_id] = Ticket::Article::Type.lookup( :name => 'note' ).id
|
||||||
:id_from => from_id,
|
article_new[:internal] = false
|
||||||
:value_to => to,
|
elsif article_new[:ticket_article_type] == 'note-internal'
|
||||||
:id_to => to_id,
|
article_new[:ticket_article_type_id] = Ticket::Article::Type.lookup( :name => 'note' ).id
|
||||||
:created_at => history['CreateTime'],
|
article_new[:internal] = true
|
||||||
:created_by_id => history['CreateBy']
|
elsif article_new[:ticket_article_type] == 'phone'
|
||||||
)
|
article_new[:ticket_article_type_id] = Ticket::Article::Type.lookup( :name => 'phone' ).id
|
||||||
|
article_new[:internal] = false
|
||||||
|
elsif article_new[:ticket_article_type] == 'webrequest'
|
||||||
|
article_new[:ticket_article_type_id] = Ticket::Article::Type.lookup( :name => 'web' ).id
|
||||||
|
article_new[:internal] = false
|
||||||
|
else
|
||||||
|
article_new[:ticket_article_type_id] = 9
|
||||||
|
end
|
||||||
|
article_new.delete( :ticket_article_type )
|
||||||
|
article_old = Ticket::Article.where( :id => article_new[:id] ).first
|
||||||
|
#puts 'ARTICLE OLD ' + article_old.inspect
|
||||||
|
# set state types
|
||||||
|
if article_old
|
||||||
|
puts "update Ticket::Article.find(#{article_new[:id]})"
|
||||||
|
# puts article_new.inspect
|
||||||
|
article_old.update_attributes(article_new)
|
||||||
|
else
|
||||||
|
puts "add Ticket::Article.find(#{article_new[:id]})"
|
||||||
|
article = Ticket::Article.new(article_new)
|
||||||
|
article.id = article_new[:id]
|
||||||
|
article.save
|
||||||
|
end
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
record['History'].each { |history|
|
||||||
|
# puts '-------'
|
||||||
|
# puts history.inspect
|
||||||
|
if history['HistoryType'] == 'NewTicket'
|
||||||
|
History.history_create(
|
||||||
|
:id => history['HistoryID'],
|
||||||
|
:o_id => history['TicketID'],
|
||||||
|
:history_type => 'created',
|
||||||
|
:history_object => 'Ticket',
|
||||||
|
:created_at => history['CreateTime'],
|
||||||
|
:created_by_id => history['CreateBy']
|
||||||
|
)
|
||||||
|
end
|
||||||
|
if history['HistoryType'] == 'StateUpdate'
|
||||||
|
data = history['Name']
|
||||||
|
# "%%new%%open%%"
|
||||||
|
from = nil
|
||||||
|
to = nil
|
||||||
|
if data =~ /%%(.+?)%%(.+?)%%/
|
||||||
|
from = $1
|
||||||
|
to = $2
|
||||||
|
state_from = Ticket::State.lookup( :name => from )
|
||||||
|
state_to = Ticket::State.lookup( :name => to )
|
||||||
|
if state_from
|
||||||
|
from_id = state_from.id
|
||||||
|
end
|
||||||
|
if state_to
|
||||||
|
to_id = state_to.id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# puts "STATE UPDATE (#{history['HistoryID']}): -> #{from}->#{to}"
|
||||||
|
History.history_create(
|
||||||
|
:id => history['HistoryID'],
|
||||||
|
:o_id => history['TicketID'],
|
||||||
|
:history_type => 'updated',
|
||||||
|
:history_object => 'Ticket',
|
||||||
|
:history_attribute => 'ticket_state',
|
||||||
|
:value_from => from,
|
||||||
|
:id_from => from_id,
|
||||||
|
:value_to => to,
|
||||||
|
:id_to => to_id,
|
||||||
|
:created_at => history['CreateTime'],
|
||||||
|
:created_by_id => history['CreateBy']
|
||||||
|
)
|
||||||
|
end
|
||||||
|
if history['HistoryType'] == 'Move'
|
||||||
|
data = history['Name']
|
||||||
|
# "%%Queue1%%5%%Postmaster%%1"
|
||||||
|
from = nil
|
||||||
|
to = nil
|
||||||
|
if data =~ /%%(.+?)%%(.+?)%%(.+?)%%(.+?)$/
|
||||||
|
from = $1
|
||||||
|
from_id = $2
|
||||||
|
to = $3
|
||||||
|
to_id = $4
|
||||||
|
end
|
||||||
|
History.history_create(
|
||||||
|
:id => history['HistoryID'],
|
||||||
|
:o_id => history['TicketID'],
|
||||||
|
:history_type => 'updated',
|
||||||
|
:history_object => 'Ticket',
|
||||||
|
:history_attribute => 'group',
|
||||||
|
:value_from => from,
|
||||||
|
:value_to => to,
|
||||||
|
:id_from => from_id,
|
||||||
|
:id_to => to_id,
|
||||||
|
:created_at => history['CreateTime'],
|
||||||
|
:created_by_id => history['CreateBy']
|
||||||
|
)
|
||||||
|
end
|
||||||
|
if history['HistoryType'] == 'PriorityUpdate'
|
||||||
|
data = history['Name']
|
||||||
|
# "%%3 normal%%3%%5 very high%%5"
|
||||||
|
from = nil
|
||||||
|
to = nil
|
||||||
|
if data =~ /%%(.+?)%%(.+?)%%(.+?)%%(.+?)$/
|
||||||
|
from = $1
|
||||||
|
from_id = $2
|
||||||
|
to = $3
|
||||||
|
to_id = $4
|
||||||
|
end
|
||||||
|
History.history_create(
|
||||||
|
:id => history['HistoryID'],
|
||||||
|
:o_id => history['TicketID'],
|
||||||
|
:history_type => 'updated',
|
||||||
|
:history_object => 'Ticket',
|
||||||
|
:history_attribute => 'ticket_priority',
|
||||||
|
:value_from => from,
|
||||||
|
:value_to => to,
|
||||||
|
:id_from => from_id,
|
||||||
|
:id_to => to_id,
|
||||||
|
:created_at => history['CreateTime'],
|
||||||
|
:created_by_id => history['CreateBy']
|
||||||
|
)
|
||||||
|
end
|
||||||
|
if history['ArticleID'] && history['ArticleID'] != 0
|
||||||
|
History.history_create(
|
||||||
|
:id => history['HistoryID'],
|
||||||
|
:o_id => history['ArticleID'],
|
||||||
|
:history_type => 'created',
|
||||||
|
:history_object => 'Ticket::Article',
|
||||||
|
:related_o_id => history['TicketID'],
|
||||||
|
:related_history_object => 'Ticket',
|
||||||
|
:created_at => history['CreateTime'],
|
||||||
|
:created_by_id => history['CreateBy']
|
||||||
|
)
|
||||||
|
end
|
||||||
|
}
|
||||||
end
|
end
|
||||||
if history['HistoryType'] == 'Move'
|
|
||||||
data = history['Name']
|
|
||||||
# "%%Queue1%%5%%Postmaster%%1"
|
|
||||||
from = nil
|
|
||||||
to = nil
|
|
||||||
if data =~ /%%(.+?)%%(.+?)%%(.+?)%%(.+?)$/
|
|
||||||
from = $1
|
|
||||||
from_id = $2
|
|
||||||
to = $3
|
|
||||||
to_id = $4
|
|
||||||
end
|
|
||||||
History.history_create(
|
|
||||||
:id => history['HistoryID'],
|
|
||||||
:o_id => history['TicketID'],
|
|
||||||
:history_type => 'updated',
|
|
||||||
:history_object => 'Ticket',
|
|
||||||
:history_attribute => 'group',
|
|
||||||
:value_from => from,
|
|
||||||
:value_to => to,
|
|
||||||
:id_from => from_id,
|
|
||||||
:id_to => to_id,
|
|
||||||
:created_at => history['CreateTime'],
|
|
||||||
:created_by_id => history['CreateBy']
|
|
||||||
)
|
|
||||||
end
|
|
||||||
if history['HistoryType'] == 'PriorityUpdate'
|
|
||||||
data = history['Name']
|
|
||||||
# "%%3 normal%%3%%5 very high%%5"
|
|
||||||
from = nil
|
|
||||||
to = nil
|
|
||||||
if data =~ /%%(.+?)%%(.+?)%%(.+?)%%(.+?)$/
|
|
||||||
from = $1
|
|
||||||
from_id = $2
|
|
||||||
to = $3
|
|
||||||
to_id = $4
|
|
||||||
end
|
|
||||||
History.history_create(
|
|
||||||
:id => history['HistoryID'],
|
|
||||||
:o_id => history['TicketID'],
|
|
||||||
:history_type => 'updated',
|
|
||||||
:history_object => 'Ticket',
|
|
||||||
:history_attribute => 'ticket_priority',
|
|
||||||
:value_from => from,
|
|
||||||
:value_to => to,
|
|
||||||
:id_from => from_id,
|
|
||||||
:id_to => to_id,
|
|
||||||
:created_at => history['CreateTime'],
|
|
||||||
:created_by_id => history['CreateBy']
|
|
||||||
)
|
|
||||||
end
|
|
||||||
if history['ArticleID'] && history['ArticleID'] != 0
|
|
||||||
History.history_create(
|
|
||||||
:id => history['HistoryID'],
|
|
||||||
:o_id => history['ArticleID'],
|
|
||||||
:history_type => 'created',
|
|
||||||
:history_object => 'Ticket::Article',
|
|
||||||
:related_o_id => history['TicketID'],
|
|
||||||
:related_history_object => 'Ticket',
|
|
||||||
:created_at => history['CreateTime'],
|
|
||||||
:created_by_id => history['CreateBy']
|
|
||||||
)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue