rt 4.2.15
[freeside.git] / rt / lib / RT / Graph / Tickets.pm
index 52c4b72..1f8bebc 100644 (file)
@@ -2,7 +2,7 @@
 #
 # COPYRIGHT:
 #
-# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2018 Best Practical Solutions, LLC
 #                                          <sales@bestpractical.com>
 #
 # (Except where explicitly superseded by other copyright notices)
@@ -104,16 +104,19 @@ sub gv_escape($) {
     return $value;
 }
 
+sub loc { return HTML::Mason::Commands::loc(@_) };
+
 our (%fill_cache, @available_colors) = ();
 
 our %property_cb = (
-    Queue => sub { return $_[0]->QueueObj->Name || $_[0]->Queue },
-    CF    => sub {
+    Queue  => sub { return $_[0]->QueueObj->Name || $_[0]->Queue },
+    Status => sub { return loc($_[0]->Status) },
+    CF     => sub {
         my $values = $_[0]->CustomFieldValues( $_[1] );
         return join ', ', map $_->Content, @{ $values->ItemsArrayRef };
     },
 );
-foreach my $field (qw(Subject Status TimeLeft TimeWorked TimeEstimated)) {
+foreach my $field (qw(Subject TimeLeft TimeWorked TimeEstimated)) {
     $property_cb{ $field } = sub { return $_[0]->$field },
 }
 foreach my $field (qw(Creator LastUpdatedBy Owner)) {
@@ -163,7 +166,8 @@ sub TicketProperties {
         next if $seen{ lc $cf->Name }++;
         next if $cf->Type eq 'Image';
         if ( $first ) {
-            push @res, 'CustomFields', [];
+            push @res, 'Custom Fields', # loc
+                [];
             $first = 0;
         }
         push @{ $res[-1] }, 'CF.{'. $cf->Name .'}';
@@ -203,7 +207,8 @@ sub _PropertiesToFields {
             $RT::Logger->error("Couldn't find property handler for '$key' and '@subkeys' subkeys");
             next;
         }
-        push @fields, ($subkeys[0] || $key) .': '. $property_cb{ $key }->( $args{'Ticket'}, @subkeys );
+        my $label = $key eq 'CF' ? $subkeys[0] : loc($key);
+        push @fields, $label .': '. $property_cb{ $key }->( $args{'Ticket'}, @subkeys );
     }
 
     return @fields;
@@ -299,9 +304,12 @@ sub TicketLinks {
     }
 
     $args{'Seen'} ||= {};
-    return $args{'Graph'} if $args{'Seen'}{ $args{'Ticket'}->id }++;
-
-    $self->AddTicket( %args );
+    if ( $args{'Seen'}{ $args{'Ticket'}->id } && $args{'Seen'}{ $args{'Ticket'}->id } <= $args{'CurrentDepth'} ) {
+      return $args{'Graph'};
+    } elsif ( ! defined $args{'Seen'}{ $args{'Ticket'}->id } ) {
+      $self->AddTicket( %args );
+    }
+    $args{'Seen'}{ $args{'Ticket'}->id } = $args{'CurrentDepth'};
 
     return $args{'Graph'} if $args{'MaxDepth'} && $args{'CurrentDepth'} >= $args{'MaxDepth'};