X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FTicketSystem.pm;h=d53d2f679daa514806da18f96c472e75d6cbccdc;hb=57fecbd959fd5d72b20105161b7e3df94cbedd03;hp=2a5c68f7d4beb196c63a05136ad2753bdf27feae;hpb=0d1d2630e726ab4ce32bab9c3e4a889eee43fcb4;p=freeside.git diff --git a/FS/FS/TicketSystem.pm b/FS/FS/TicketSystem.pm index 2a5c68f7d..d53d2f679 100644 --- a/FS/FS/TicketSystem.pm +++ b/FS/FS/TicketSystem.pm @@ -1,14 +1,14 @@ package FS::TicketSystem; use strict; -use vars qw( $system $AUTOLOAD ); +use vars qw( $conf $system $AUTOLOAD ); use FS::Conf; -use FS::UID; +use FS::UID qw( dbh driver_name ); -install_callback FS::UID sub { - my $conf = new FS::Conf; +FS::UID->install_callback( sub { + $conf = new FS::Conf; $system = $conf->config('ticket_system'); -}; +} ); sub AUTOLOAD { my $self = shift; @@ -27,4 +27,26 @@ sub AUTOLOAD { $self->$sub(@_); } +sub _upgrade_data { + return if $system ne 'RT_Internal'; + + my ($class, %opts) = @_; + my ($t, $exec, @fields) = map { driver_name =~ /^mysql/i ? $_ : lc($_) } + (qw( ScripConditions ExecModule + Name Description ExecModule ApplicableTransTypes + Creator Created LastUpdatedBy LastUpdated)); + my $count_sql = "SELECT COUNT(*) FROM $t WHERE $exec = 'CustomFieldChange'"; + my $sth = dbh->prepare($count_sql) or die dbh->errstr; + $sth->execute or die $sth->errstr; + my $total = $sth->fetchrow_arrayref->[0]; + return if $total > 0; + + my $insert_sql = "INSERT INTO $t (".join(',',@fields).") VALUES (". + "'On Custom Field Change', 'When a custom field is changed to some value', + 'CustomFieldChange', 'Any', 1, CURRENT_DATE, 1, CURRENT_DATE )"; + $sth = dbh->prepare($insert_sql) or die dbh->errstr; + $sth->execute or die $sth->errstr; + return; +} + 1;