[freeside-commits] freeside/FS/FS TicketSystem.pm, 1.3.12.2, 1.3.12.3
Mark Wells
mark at wavetail.420.am
Fri May 13 16:21:10 PDT 2011
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv27641/FS/FS
Modified Files:
Tag: FREESIDE_2_1_BRANCH
TicketSystem.pm
Log Message:
notify on custom field change, #11274
Index: TicketSystem.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/TicketSystem.pm,v
retrieving revision 1.3.12.2
retrieving revision 1.3.12.3
diff -u -w -d -r1.3.12.2 -r1.3.12.3
--- TicketSystem.pm 10 May 2011 23:22:58 -0000 1.3.12.2
+++ TicketSystem.pm 13 May 2011 23:21:08 -0000 1.3.12.3
@@ -28,7 +28,7 @@
}
sub _upgrade_data {
- return if $system ne 'RT_Internal';
+ return if !defined($system) || $system ne 'RT_Internal';
my ($class, %opts) = @_;
# go ahead and use the RT API for this
@@ -38,20 +38,7 @@
my $CurrentUser = $session->{'CurrentUser'}
or die 'freeside-upgrade must run as a valid RT user';
- # CustomFieldChange scrip condition
- my $ScripCondition = RT::ScripCondition->new($CurrentUser);
- $ScripCondition->LoadByCols('ExecModule' => 'CustomFieldChange');
- if (!defined($ScripCondition->Id)) {
- my ($val, $msg) = $ScripCondition->Create(
- 'Name' => 'On Custom Field Change',
- 'Description' => 'When a custom field is changed to some value',
- 'ExecModule' => 'CustomFieldChange',
- 'ApplicableTransTypes' => 'Any',
- );
- die $msg if !$val;
- }
-
- # Create any missing scrips
+ # Load from RT data file
our (@Groups, @Users, @ACL, @Queues, @ScripActions, @ScripConditions,
@Templates, @CustomFields, @Scrips, @Attributes, @Initial, @Final);
my $datafile = '%%%RT_PATH%%%/etc/initialdata';
@@ -61,6 +48,7 @@
return;
}
+ # Cache existing ScripCondition, ScripAction, and Template IDs
my $search = RT::ScripConditions->new($CurrentUser);
$search->UnLimit;
my %condition = map { lc($_->Name), $_->Id } @{ $search->ItemsArrayRef };
@@ -73,6 +61,37 @@
$search->UnLimit;
my %template = map { lc($_->Name), $_->Id } @{ $search->ItemsArrayRef };
+ # ScripConditions
+ my $ScripCondition = RT::ScripCondition->new($CurrentUser);
+ foreach my $sc (@ScripConditions) {
+ # $sc: Name, Description, ApplicableTransTypes, ExecModule, Argument
+ next if exists( $condition{ lc($sc->{Name}) } );
+ my ($val, $msg) = $ScripCondition->Create( %$sc );
+ die $msg if !$val;
+ $condition{ lc($ScripCondition->Name) } = $ScripCondition->Id;
+ }
+
+ # ScripActions
+ my $ScripAction = RT::ScripAction->new($CurrentUser);
+ foreach my $sa (@ScripActions) {
+ # $sa: Name, Description, ExecModule, Argument
+ next if exists( $action{ lc($sa->{Name}) } );
+ my ($val, $msg) = $ScripAction->Create( %$sa );
+ die $msg if !$val;
+ $action{ lc($ScripAction->Name) } = $ScripAction->Id;
+ }
+
+ # Templates
+ my $Template = RT::Template->new($CurrentUser);
+ foreach my $t (@Templates) {
+ # $t: Queue, Name, Description, Content
+ next if exists( $template{ lc($t->{Name}) } );
+ my ($val, $msg) = $Template->Create( %$t );
+ die $msg if !$val;
+ $template{ lc($Template->Name) } = $Template->Id;
+ }
+
+ # Scrips
my $Scrip = RT::Scrip->new($CurrentUser);
foreach my $s ( @Scrips ) {
my $desc = $s->{'Description'};
More information about the freeside-commits
mailing list