summaryrefslogtreecommitdiff
path: root/FS/FS/TicketSystem.pm
diff options
context:
space:
mode:
authormark <mark>2010-11-30 20:24:02 +0000
committermark <mark>2010-11-30 20:24:02 +0000
commit5eb580257c6730b1512a278855bc4191c74b3f6e (patch)
tree3023c7532492c0794d362c9fdb8e57e9cfdcea5a /FS/FS/TicketSystem.pm
parent8c1ded8f571a5e4b38a5273bfa35fa6aaa57a75f (diff)
auto-insert CustomFieldChange scrip condition, from RT#10139
Diffstat (limited to 'FS/FS/TicketSystem.pm')
-rw-r--r--FS/FS/TicketSystem.pm24
1 files changed, 23 insertions, 1 deletions
diff --git a/FS/FS/TicketSystem.pm b/FS/FS/TicketSystem.pm
index a80a827..d53d2f6 100644
--- a/FS/FS/TicketSystem.pm
+++ b/FS/FS/TicketSystem.pm
@@ -3,7 +3,7 @@ package FS::TicketSystem;
use strict;
use vars qw( $conf $system $AUTOLOAD );
use FS::Conf;
-use FS::UID;
+use FS::UID qw( dbh driver_name );
FS::UID->install_callback( sub {
$conf = new FS::Conf;
@@ -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;