diff options
Diffstat (limited to 'html/Callbacks/MandatoryCustomFields/Ticket')
-rw-r--r-- | html/Callbacks/MandatoryCustomFields/Ticket/Modify.html/Default | 21 | ||||
-rw-r--r-- | html/Callbacks/MandatoryCustomFields/Ticket/Update.html/BeforeUpdate | 28 |
2 files changed, 49 insertions, 0 deletions
diff --git a/html/Callbacks/MandatoryCustomFields/Ticket/Modify.html/Default b/html/Callbacks/MandatoryCustomFields/Ticket/Modify.html/Default new file mode 100644 index 0000000..5fba7de --- /dev/null +++ b/html/Callbacks/MandatoryCustomFields/Ticket/Modify.html/Default @@ -0,0 +1,21 @@ +<%init> +my $ARGSRef = $ARGS{'ARGSRef'}; +my $TicketObj = $ARGS{'TicketObj'}; +my $results = $ARGS{'Results'}; +my $oldStatus = $TicketObj->Status(); +my $newStatus = ($ARGSRef->{'resolve'} && 'resolved') || + $ARGSRef->{'Status'} || + $ARGSRef->{'DefaultStatus'}; +if($oldStatus ne 'resolved' and + $newStatus eq 'resolved') { + my @errors = + $m->comp('/Ticket/Elements/CheckMandatoryFields', Ticket => $TicketObj); + return if !@errors; + my $msg = 'Missing required field'.(@errors > 1 ? 's' : '').': ' . + join(', ', map { $_->Name } @errors); + $m->notes( ('InvalidField-' . $_->Id) => 'Required' ) foreach @errors; + push @$results, $msg; + delete $ARGSRef->{'resolve'}; + delete $ARGSRef->{'Status'}; +} +</%init> diff --git a/html/Callbacks/MandatoryCustomFields/Ticket/Update.html/BeforeUpdate b/html/Callbacks/MandatoryCustomFields/Ticket/Update.html/BeforeUpdate new file mode 100644 index 0000000..965d00b --- /dev/null +++ b/html/Callbacks/MandatoryCustomFields/Ticket/Update.html/BeforeUpdate @@ -0,0 +1,28 @@ +<%doc> +When the user tries to change a ticket's status to "resolved" through +the Update interface, check mandatory fields. If they aren't all set, +redirect to Ticket Basics instead of updating. Note that this will +lose any comments/time/other information the user has entered. +</%doc> + +<%init> +my $oldStatus = $TicketObj->Status(); +my $newStatus = $ARGSRef->{'Status'} || $ARGSRef->{'DefaultStatus'} || ''; +if( $oldStatus ne 'resolved' and + $newStatus eq 'resolved' and + $m->comp('/Ticket/Elements/CheckMandatoryFields', + Ticket => $TicketObj + ) ) { + $m->clear_buffer; + RT::Interface::Web::Redirect( + RT->Config->Get('WebURL')."Ticket/Modify.html?id=".$TicketObj->Id."&resolve=1" + ); + $m->abort; +} +</%init> +<%args> +$ARGSRef => {} +$checks_failure => undef +$results => [] +$TicketObj => undef +</%args> |