& /Admin/Elements/Header, Title => 'Edit scrips' &>
<& /Elements/ListActions, actions => \@actions &>
<%$description%>
<%init>
my (@actions, $description);
my $Scrips = new RT::Scrips ($session{'CurrentUser'});
unless ($Queue =~ /^\d+$/) {
Abort("$Queue isn't a valid Queue id.");
}
unless ($Scrips->LimitToQueue($Queue)) {
Abort("Couldn't load Scrips.");
}
my $QueueObj = new RT::Queue($session{'CurrentUser'});
$QueueObj->Load($Queue);
if ($QueueObj->id) {
$description = "Modify scrips for queue '". $QueueObj->QueueId ."'";
}
else {
$description = "Modify global scrips";
}
if ($NewScripAction and $NewScripCondition) {
my $NewScrip = new RT::Scrip($session{'CurrentUser'});
my $retval = $NewScrip->Create ( ScripAction => $NewScripAction,
ScripCondition => $NewScripCondition,
Stage => 'TransactionCreate',
Queue => $Queue,
Template => $NewScripTemplate);
if (defined $retval) {
push @actions, "Scrip added to queue";
}
else {
push @actions, "Scrip could not be added to queue";
}
}
# {{{ deal with modifying and deleting existing scrips
my ($key );
foreach $key (keys %ARGS) {
# {{{ if we're trying to delete the scrip
if ($key =~ /^DeleteScrip-(\d+)/) {
my $id = $1;
my $scrip = new RT::Scrip($session{'CurrentUser'});
$scrip->Load($id);
$scrip->Delete;
}
# }}}
}
# }}}
%init>
<%ARGS>
$NewScripCondition => undef
$NewScripAction => undef
$NewScripTemplate => undef
$Queue => undef #some identifier that a Queue could
%ARGS>