& /Elements/Header, Title => "Ticket #".$Ticket->Id." Updated" &>
Ticket Updates:
% for (@Actions) {
<%$_%>
% }
<& /Ticket/Elements/TicketToolBox, Ticket => $Ticket&>
<& /Ticket/Elements/ShowSummary, Ticket => $Ticket &>
<& /Elements/TitleBoxEnd &>
Ticket History
<& /Ticket/Elements/ShowHistory , Ticket => $Ticket &>
<& /Elements/TitleBoxEnd &>
<& /Elements/Footer &>
<%args>
$id => undef
$SetStatus => undef
$SetOwner => undef
$UpdateSubject => undef
$UpdateComment => undef
$Transaction => undef
$Description => undef
%args>
<%init>
my @Actions;
if (!$ARGS{'id'}) {
&mc_comp("/Elements/Error" , Why => "No ticket specified");
$m->abort;
}
use RT::Ticket;
use RT::CurrentUser;
use MIME::Entity;
my $Ticket = RT::Ticket->new($session{'CurrentUser'});
$Ticket->Load($ARGS{id}) || die "Could not load $ARGS{id}...?!?";
my @UpdateContent = split(/\r/,$ARGS{'UpdateContent'}."\n");
# This one should be first, so the new owner gets all information
if ($ARGS{'SetOwner'}
and ($ARGS{'SetOwner'} ne $Ticket->Owner->Id())) {
($Transaction, $Description)=$Ticket->SetOwner($ARGS{'SetOwner'});
push(@Actions, $Description);
}
my $Message = MIME::Entity->build ( Subject => $ARGS{'UpdateSubject'} || "",
Cc => $ARGS{'UpdateCc'} || "",
Bcc => $ARGS{'UpdateBcc'} || "",
Data => \@UpdateContent);
if ($ARGS{'UpdateType'} eq 'private') {
($Transaction, $Description) = $Ticket->Comment( CcMessageTo => $ARGS{'UpdateCc'},
BccMessageTo => $ARGS{'UpdateBcc'},
MIMEObj => $Message,
TimeTaken => $ARGS{'UpdateTimeWorked'});
push(@Actions, $Description);
}
elsif ($ARGS{'UpdateType'} eq 'response') {
($Transaction, $Description) = $Ticket->Correspond( CcMessageTo => $ARGS{'UpdateCc'},
BccMessageTo => $ARGS{'UpdateBcc'},
MIMEObj => $Message,
TimeTaken => $ARGS{'UpdateTimeWorked'});
push(@Actions, $Description);
}
if ($ARGS{'Take'}) {
($Transaction, $Description)=$Ticket->Take();
push(@Actions, $Description);
}
if ($ARGS{'SetStatus'} and ($ARGS{'SetStatus'} ne $Ticket->Status())) {
($Transaction, $Description)=$Ticket->SetStatus($ARGS{'SetStatus'});
push(@Actions, $Description);
}
# Eventually, link up the ticket (this is CUT'N'PASTE from Display.html - CUT'N'PASTE sucks!):
if (my $l=$ARGS{'Link'}) {
# There is some redundant information from the forms now - we'll
# ignore one bit of it:
my $luris=$ARGS{'LinkTo'} || $ARGS{'LinkFrom'};
my $ltyp=$ARGS{'LinkType'};
if (ref $ltyp) {
&mc_comp("/Elements/Error" , Why => "Parameter error");
$m->abort;
}
for my $luri (split (/ /,$luris)) {
my ($LinkId, $Message);
if ($l eq 'LinkTo') {
($LinkId,$Message)=$Ticket->LinkTo(Target=>$luri, Type=>$ltyp);
} elsif ($l eq 'LinkFrom') {
($LinkId,$Message)=$Ticket->LinkFrom(Base=>$luri, Type=>$ltyp);
} else {
&mc_comp("/Elements/Error" , Why => "Parameter error");
$m->abort;
}
warn $Message;
push(@Actions, $Message);
}
}
%init>