%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
# 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>