summaryrefslogtreecommitdiff
path: root/rt/share/html/Callbacks
diff options
context:
space:
mode:
Diffstat (limited to 'rt/share/html/Callbacks')
-rw-r--r--rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Elements/Tabs/Default12
-rw-r--r--rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Modify.html/BeforeActionList15
-rw-r--r--rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Update.html/BeforeDisplay24
3 files changed, 51 insertions, 0 deletions
diff --git a/rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Elements/Tabs/Default b/rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Elements/Tabs/Default
new file mode 100644
index 000000000..2c0698ec2
--- /dev/null
+++ b/rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Elements/Tabs/Default
@@ -0,0 +1,12 @@
+<%doc>
+If mandatory fields aren't set yet, point the "Resolve" link back
+to "Ticket Basics".
+</%doc>
+<%init>
+my $TicketObj = delete($ARGS{'Ticket'});
+my $actions = $ARGS{'actions'};
+if( $m->comp('/Ticket/Elements/CheckMandatoryFields', Ticket => $TicketObj)
+ ) {
+ $actions->{'G'}->{'path'} = 'Ticket/Modify.html?id='.$TicketObj->Id.'&resolve=1';
+}
+</%init>
diff --git a/rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Modify.html/BeforeActionList b/rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Modify.html/BeforeActionList
new file mode 100644
index 000000000..4779411ce
--- /dev/null
+++ b/rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Modify.html/BeforeActionList
@@ -0,0 +1,15 @@
+<%init>
+use Data::Dumper;
+my $ARGSRef = $ARGS{'ARGSRef'};
+my $TicketObj = $ARGS{'Ticket'};
+my $results = $ARGS{'Actions'};
+if(defined($ARGSRef->{'resolve'})) {
+ 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;
+}
+</%init>
diff --git a/rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Update.html/BeforeDisplay b/rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Update.html/BeforeDisplay
new file mode 100644
index 000000000..0d69bc27b
--- /dev/null
+++ b/rt/share/html/Callbacks/CheckMandatoryFields/Ticket/Update.html/BeforeDisplay
@@ -0,0 +1,24 @@
+<%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 $TicketObj = $ARGS{'Ticket'};
+my $ARGSRef = $ARGS{'ARGSRef'};
+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>