[freeside-commits] freeside/FS/FS TicketSystem.pm,1.7,1.8
Mark Wells
mark at wavetail.420.am
Fri May 13 16:20:54 PDT 2011
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv27525/FS/FS
Modified Files:
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.7
retrieving revision 1.8
diff -u -w -d -r1.7 -r1.8
--- TicketSystem.pm 11 May 2011 16:20:12 -0000 1.7
+++ TicketSystem.pm 13 May 2011 23:20:52 -0000 1.8
@@ -38,32 +38,6 @@
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;
- }
-
- # SetPriority scrip action
- my $ScripAction = RT::ScripAction->new($CurrentUser);
- $ScripAction->LoadByCols('ExecModule' => 'SetPriority');
- if (!defined($ScripAction->Id)) {
- my ($val, $msg) = $ScripAction->Create(
- 'Name' => 'Set Priority',
- 'Description' => 'Set ticket priority',
- 'ExecModule' => 'SetPriority',
- 'Argument' => '',
- );
- die $msg if !$val;
- }
-
# EscalateQueue custom field and friends
my $CF = RT::CustomField->new($CurrentUser);
$CF->Load('EscalateQueue');
@@ -85,7 +59,7 @@
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';
@@ -95,6 +69,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 };
@@ -107,6 +82,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