& /Admin/Elements/Header, Title => 'Edit scrips' &>
<& /Admin/Elements/QueueTabs, id => $QueueObj->Id &>
<& /Elements/ListActions, actions => \@actions &>
<& /Elements/TitleBoxStart, title => $description &>
Global Scrips
<& /Admin/Elements/ListGlobalScrips &>
<%init>
my (@actions, $description);
my $Scrips = new RT::Scrips ($session{'CurrentUser'});
unless ($id =~ /^\d+$/) {
Abort("$id isn't a valid Queue id.");
}
unless ($Scrips->LimitToQueue($id)) {
Abort("Couldn't load Scrips.");
}
my $QueueObj = new RT::Queue($session{'CurrentUser'});
$QueueObj->Load($id);
if ($QueueObj->id) {
$description = "Modify scrips for queue '". $QueueObj->Name ."'";
}
else {
$description = "Modify global scrips";
}
if ($NewScripAction and $NewScripCondition) {
my $NewScrip = new RT::Scrip($session{'CurrentUser'});
my ($retval, $msg) = $NewScrip->Create ( ScripAction => $NewScripAction,
ScripCondition => $NewScripCondition,
Stage => 'TransactionCreate',
Queue => $id,
Template => $NewScripTemplate);
if (defined $retval) {
push @actions, $msg;
}
else {
push @actions, $msg;
}
}
# {{{ 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);
my ($retval, $msg) = $scrip->Delete;
if ($retval) {
push @actions, 'Scrip deleted';
}
else {
push @actions, $msg;
}
}
# }}}
}
# }}}
%init>
<%ARGS>
$NewScripCondition => undef
$NewScripAction => undef
$NewScripTemplate => undef
$id => undef #some identifier that a Queue could
%ARGS>