X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FAdmin%2FElements%2FEditScrips;h=127677d7937415fdd61243ebf7f51d7fd4e21f3c;hb=31f3763747b82764bb019cfab5b2a2945fc9a99d;hp=2fdcae6709fbf728ad8725c287302a433480a1e1;hpb=f3c4966ed1f6ec3db7accd6dcdd3a5a3821d72a7;p=freeside.git diff --git a/rt/share/html/Admin/Elements/EditScrips b/rt/share/html/Admin/Elements/EditScrips index 2fdcae670..127677d79 100755 --- a/rt/share/html/Admin/Elements/EditScrips +++ b/rt/share/html/Admin/Elements/EditScrips @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -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; <%ARGS>