diff options
author | Mark Wells <mark@freeside.biz> | 2013-07-17 15:43:52 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2013-07-17 15:43:52 -0700 |
commit | 3ceb32ebb390aa8aa5fffdfc095be35ef7e54bbe (patch) | |
tree | f1015dbb03fb02482b0651b8b2a84e904859a602 /FS | |
parent | f5dc45e3e21fc7c3948dd19072fd6448984d31de (diff) |
prevent deletion of auto-created RT scrips, #18184
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/TicketSystem.pm | 58 |
1 files changed, 35 insertions, 23 deletions
diff --git a/FS/FS/TicketSystem.pm b/FS/FS/TicketSystem.pm index 7b1857527..96980e96b 100644 --- a/FS/FS/TicketSystem.pm +++ b/FS/FS/TicketSystem.pm @@ -228,30 +228,42 @@ sub _upgrade_data { my $desc = $s->{'Description'}; my ($c, $a, $t) = map lc, @{ $s }{'ScripCondition', 'ScripAction', 'Template'}; - # skip existing scrips - next if ( exists($scrip{$c}{$a}{$t}) ); - if ( !exists($condition{$c}) ) { - warn "ScripCondition '$c' not found.\n"; - next; - } - if ( !exists($action{$a}) ) { - warn "ScripAction '$a' not found.\n"; - next; - } - if ( !exists($template{$t}) ) { - warn "Template '$t' not found.\n"; - next; + + if ( exists($scrip{$c}{$a}{$t}) ) { + $Scrip->Load( $scrip{$c}{$a}{$t} ); + } else { # need to create it + + if ( !exists($condition{$c}) ) { + warn "ScripCondition '$c' not found.\n"; + next; + } + if ( !exists($action{$a}) ) { + warn "ScripAction '$a' not found.\n"; + next; + } + if ( !exists($template{$t}) ) { + warn "Template '$t' not found.\n"; + next; + } + my %new_param = ( + ScripCondition => $condition{$c}->[0], + ScripAction => $action{$a}->[0], + Template => $template{$t}->[0], + Queue => 0, + Description => $desc, + ); + warn "Creating scrip: $c $a [$t]\n"; + my ($val, $msg) = $Scrip->Create(%new_param); + die $msg if !$val; + + } #if $scrip{...} + # set the Immutable attribute on them if needed + if ( !$Scrip->FirstAttribute('Immutable') ) { + my ($val, $msg) = + $Scrip->SetAttribute(Name => 'Immutable', Content => '1'); + die $msg if !$val; } - my %new_param = ( - ScripCondition => $condition{$c}->[0], - ScripAction => $action{$a}->[0], - Template => $template{$t}->[0], - Queue => 0, - Description => $desc, - ); - warn "Creating scrip: $c $a [$t]\n"; - my ($val, $msg) = $Scrip->Create(%new_param); - die $msg if !$val; + } #foreach (@Scrips) # one-time fix: accumulator fields (support time, etc.) that had values |