[Rt-commit] r6441 - in rtir/branches/2.1-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Wed Nov 15 23:57:31 EST 2006
Author: ruz
Date: Wed Nov 15 23:57:31 2006
New Revision: 6441
Modified:
rtir/branches/2.1-EXPERIMENTAL/ (props changed)
rtir/branches/2.1-EXPERIMENTAL/lib/RT/IR.pm
Log:
r1837 at cubic-pc: cubic | 2006-11-16 02:24:02 +0300
* add a replacement for html/RTIR/Elements/Type
** Ticket and TicketOBj arguments are merged into Ticket
** this function doesn't return states array anymore as
we don't use this functionality since 1.9
Modified: rtir/branches/2.1-EXPERIMENTAL/lib/RT/IR.pm
==============================================================================
--- rtir/branches/2.1-EXPERIMENTAL/lib/RT/IR.pm (original)
+++ rtir/branches/2.1-EXPERIMENTAL/lib/RT/IR.pm Wed Nov 15 23:57:31 2006
@@ -118,6 +118,49 @@
return $SLAObj;
}
+=head2 TicketType
+
+Returns type of a ticket. Takes either Ticket or Queue argument.
+Both arguments could be objects or IDs, however, name of a queue
+works too for Queue argument. If the queue argument is defined then
+the ticket is ignored even if it's defined too.
+
+=cut
+
+my %TYPE = (
+ 'incidents' => 'Incident',
+ 'incident reports' => 'Report',
+ 'investigations' => 'Investigation',
+ 'blocks' => 'Block',
+);
+
+sub TicketType {
+ my %arg = ( Queue => undef, Ticket => undef, @_);
+ if ( defined $arg{'Ticket'} && !defined $arg{'Queue'} ) {
+ my $obj;
+ if ( ref $arg{'Ticket'} ) {
+ $obj = $arg{'Ticket'};
+ }
+ else {
+ $obj = RT::Ticket->new( $RT::SystemUser );
+ $obj->Load( $args{'Ticket'} );
+ }
+ $arg{'Queue'} = $obj->QueueObj if $obj->id;
+ }
+ return undef unless defined $arg{'Queue'};
+
+ return $TYPE{ lc $arg{'Queue'}->Name } if ref $arg{'Queue'};
+ return $TYPE{ lc $arg{'Queue'} } unless $arg{'Queue'} =~ /^\d+$/;
+
+ my $obj = RT::Queue->new( $RT::SystemUser );
+ $obj->Load( $arg{'Queue'} );
+ return $TYPE{ lc $obj->Name } if $obj->id;
+
+ return undef;
+}
+
+
+
{
my %cache;
sub GetCustomField {
More information about the Rt-commit
mailing list