<& /Elements/Header &> <& /Elements/Tabs &>

Modify a ticket

<& /Elements/ListActions, actions => \@results &> <& Elements/ModifyTicket, TicketObj => $TicketObj, %ARGS &> <%INIT> my $field; my @results; use RT::Ticket; use MIME::Entity; use RT::Interface::Web; # {{{ Load the ticket #If we get handed two ids, mason will make them an array. bleck. # We want teh first one. Just because there's no other sensible way # to deal my @id = (ref $id eq 'ARRAY') ? @{$id} : ($id); my $TicketObj = new RT::Ticket($session{'CurrentUser'}); $TicketObj->Load($id[0]) || $m->comp('/Elements/Error', Why => "Couldn't load ticket '$id'"); # }}} # {{{ Set basic fields my @fields = qw( Queue Owner Subject FinalPriority Priority Status TimeWorked TimeLeft ); #run through each field in this list. update the value if apropriate foreach $field (@fields) { my ($code, $msg); my $check = "if ((defined \$ARGS{$field}) and (\$ARGS{$field} ne \$TicketObj->$field)) { (\$code, \$msg) = \$TicketObj->Set$field(\$ARGS{'$field'}); push \@results, \"\$msg\"; }"; eval $check; if ($@) { $RT::Logger->err("Web/Ticket/Modify.html: $@\n"); } } # }}} # {{{ Set date fields my @date_fields = qw( Told Resolved Starts Started Due ); #Run through each field in this list. update the value if apropriate foreach $field (@date_fields) { my ($code, $msg); my $check = " my \$DateObj = RT::Date->new(\$session{'CurrentUser'}); #If it's something other than just whitespace if (\$ARGS{'$field'.'_Date'} ne '') { \$DateObj->Set(Format => 'unknown', Value => \$ARGS{'$field'. '_Date'}); if ((defined \$DateObj->Unix) and (\$DateObj->Unix ne \$TicketObj->@{[$field]}Obj->Unix)) { (\$code, \$msg) = \$TicketObj->Set$field(\$DateObj->ISO); push \@results, \"\$msg\"; } } "; eval $check; if ($@) { $RT::Logger->err("Web/Ticket/Modify.html Date $field update failed ".$@."\n"); } } # }}} my ($key); # {{{ Delete deletable watchers foreach $key (keys %ARGS) { if (($key =~ /^DelWatcher(\d*)$/) and ($ARGS{$key})) { $RT::Logger->debug("Deleting watcher $1\n"); my ($code, $msg) = $TicketObj->DeleteWatcher($1); push @results, $msg; } } # }}} # {{{ Add new watchers foreach $key (keys %ARGS) { #They're in this order because otherwise $1 gets clobbered :/ if ( ($ARGS{$key} =~ /^(AdminCc|Cc|Requestor)$/) and ($key =~ /^WatcherTypeUser(\d*)$/) ) { $RT::Logger->debug("Adding a watcher $1 to ".$ARGS{$key}."\n"); my ($code, $msg) = $TicketObj->AddWatcher(Type => $ARGS{$key}, Owner => $1); push @results, $msg; } } # }}} <%ARGS> $id => undef