[Rt-commit] [rtir] 02/10: Override of _GroupingClass to implement RTIR::Ticket
Kevin Falcone
falcone at bestpractical.com
Mon Aug 18 16:39:17 EDT 2014
This is an automated email from the git hooks/post-receive script.
falcone pushed a commit to branch master
in repository rtir.
commit 493d77ca48683da380211fd8d67a9fad30f684b5
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Fri Jul 25 14:28:43 2014 -0400
Override of _GroupingClass to implement RTIR::Ticket
Register RTIR::Ticket 'core' groupings of Basics, Dates and People.
RTIR never shows a Links box, so we don't register that.
The rest of this code is essentially a complicated trawl to get a Queue
so we can call OurQueue and find out if this ticket is RTIR or not.
If we have a ticket, great, use the QueueObj. If not, try to find a
Queue hanging off the CustomField. If that fails, we just return what
core returned, which is just ref $record.
Generally, we'll always get a ticket, except during Creation from
RT::CustomFields::LimitToGrouping when we'll get a CustomField object
with no id but with ContextObj set for us.
---
lib/RT/IR.pm | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 5ec8ffa..c8f8d3a 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -746,6 +746,50 @@ require RT::Action::AutoOpenInactive;
};
}
+# Because you can't (easily/cleanly/prettily) merge two
+# RT::Ticket entries in %CustomFieldGroupings, add a new
+# RTIR::Ticket option.
+require RT::CustomField;
+{
+ RT::CustomField->RegisterBuiltInGroupings(
+ 'RTIR::Ticket' => [ qw(Basics Dates People) ],
+ );
+
+ no warnings 'redefine';
+ my $orig_GroupingClass = RT::CustomField->can('_GroupingClass');
+ *RT::CustomField::_GroupingClass = sub {
+ my $self = shift;
+ my $record = shift;
+
+ my $record_class = $orig_GroupingClass->($self,$record);
+
+ # we're only doing shenanigans on Tickets, which might be RTIR::Ticket
+ unless ($record_class eq 'RT::Ticket') {
+ return $record_class;
+ }
+
+ my $queue = undef;
+ # on Create we can get an empty RT::Ticket here
+ if ( ref $record && $record->Id ) {
+ $queue = $record->QueueObj->Name;
+ # if we have an empty ticket, but a real CustomField,
+ # we can pull the Queue out of the ACLEquivalenceObjects
+ } elsif ( ref $self ) {
+ for my $obj ($self->ACLEquivalenceObjects) {
+ next unless (ref $obj eq 'RT::Queue');
+ $queue = $obj->Name;
+ last;
+ }
+ }
+
+ if (RT::IR->OurQueue($queue)) {
+ return 'RTIR::Ticket';
+ } else {
+ return $record_class;
+ }
+ };
+}
+
if ( RT::IR->HasConstituency ) {
# Queue {Comment,Correspond}Address for multiple constituencies
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the rt-commit
mailing list