[freeside-commits] branch FREESIDE_3_BRANCH updated. 3da7f47cd4dcc0a702c9066ecad55568c749b4b8
Mark Wells
mark at 420.am
Wed Jul 17 15:44:10 PDT 2013
The branch, FREESIDE_3_BRANCH has been updated
via 3da7f47cd4dcc0a702c9066ecad55568c749b4b8 (commit)
from 1aeac01ca25d937d5aa7c06ea85d8ae151468e42 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3da7f47cd4dcc0a702c9066ecad55568c749b4b8
Author: Mark Wells <mark at freeside.biz>
Date: Wed Jul 17 15:44:04 2013 -0700
prevent deletion of auto-created RT scrips, #18184
diff --git a/FS/FS/TicketSystem.pm b/FS/FS/TicketSystem.pm
index 7b18575..96980e9 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
diff --git a/rt/share/html/Admin/Elements/EditScrips b/rt/share/html/Admin/Elements/EditScrips
index b09eca9..25cafb4 100755
--- a/rt/share/html/Admin/Elements/EditScrips
+++ b/rt/share/html/Admin/Elements/EditScrips
@@ -98,17 +98,33 @@ else {
# deal with modifying and deleting existing scrips
# we still support DeleteScrip-id format but array is preferred
+
+my @not_deleted;
foreach my $id ( grep $_, @DeleteScrip, map /^DeleteScrip-(\d+)/, keys %ARGS ) {
my $scrip = RT::Scrip->new($session{'CurrentUser'});
$scrip->Load( $id );
- my ($retval, $msg) = $scrip->Delete;
- if ($retval) {
- push @actions, loc("Scrip deleted");
- }
- else {
- push @actions, $msg;
+ my $a = $scrip->FirstAttribute('Immutable');
+ if ( defined($a) and $a->Content ) {
+ # then disable the scrip instead of deleting it
+ my ($retval, $msg) = $scrip->SetStage('Disabled');
+ if ( $retval ) {
+ push @actions, loc("Scrip disabled (cannot delete system scrips)");
+ } else {
+ push @actions, $msg;
+ push @not_deleted, $id;
+ }
+ } else { # not an immutable scrip
+ my ($retval, $msg) = $scrip->Delete;
+ if ($retval) {
+ push @actions, loc("Scrip deleted");
+ }
+ else {
+ push @actions, $msg;
+ push @not_deleted, $id;
+ }
}
}
+$DECODED_ARGS->{DeleteScrip} = \@not_deleted;
</%init>
<%ARGS>
-----------------------------------------------------------------------
Summary of changes:
FS/FS/TicketSystem.pm | 58 ++++++++++++++++++------------
rt/share/html/Admin/Elements/EditScrips | 28 ++++++++++++---
2 files changed, 57 insertions(+), 29 deletions(-)
More information about the freeside-commits
mailing list