summaryrefslogtreecommitdiff
path: root/rt/share/html/Admin
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-07-17 15:43:52 -0700
committerMark Wells <mark@freeside.biz>2013-07-17 15:43:52 -0700
commit3ceb32ebb390aa8aa5fffdfc095be35ef7e54bbe (patch)
treef1015dbb03fb02482b0651b8b2a84e904859a602 /rt/share/html/Admin
parentf5dc45e3e21fc7c3948dd19072fd6448984d31de (diff)
prevent deletion of auto-created RT scrips, #18184
Diffstat (limited to 'rt/share/html/Admin')
-rwxr-xr-xrt/share/html/Admin/Elements/EditScrips28
1 files changed, 22 insertions, 6 deletions
diff --git a/rt/share/html/Admin/Elements/EditScrips b/rt/share/html/Admin/Elements/EditScrips
index b09eca910..25cafb42f 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>