[Rt-commit] r13479 - in rt/3.8/trunk: .

kyoki at bestpractical.com kyoki at bestpractical.com
Fri Jun 20 18:01:52 EDT 2008


Author: kyoki
Date: Fri Jun 20 18:01:51 2008
New Revision: 13479

Modified:
   rt/3.8/trunk/   (props changed)
   rt/3.8/trunk/lib/RT/Record.pm

Log:
 r23238 at nyx:  kyoki | 2008-06-20 18:01:36 -0400
 RT-Ticket: 9599
 RT-Status: Resolved
 RT-Update: Correspond
 Message is now more human readable.


Modified: rt/3.8/trunk/lib/RT/Record.pm
==============================================================================
--- rt/3.8/trunk/lib/RT/Record.pm	(original)
+++ rt/3.8/trunk/lib/RT/Record.pm	Fri Jun 20 18:01:51 2008
@@ -1179,6 +1179,29 @@
 
 # }}}
 
+# {{{ sub FormatLink
+
+=head2 FormatLink
+
+Takes either a Target or a Base and returns a string of human friendly text.
+
+=cut
+
+sub FormatLink {
+    my $self = shift;
+    my %args = ( Object => undef,
+		 FallBack => '',
+		 @_
+	       );
+    my $text = "URI " . $args{FallBack};
+    if ($args{Object} && $args{Object}->isa("RT::Ticket")) {
+	$text = "Ticket " . $args{Object}->id;
+    }
+    return $text;
+}
+
+# }}}
+
 # {{{ sub _AddLink
 
 =head2 _AddLink
@@ -1190,7 +1213,6 @@
 
 =cut
 
-
 sub _AddLink {
     my $self = shift;
     my %args = ( Target => '',
@@ -1247,10 +1269,13 @@
         return ( 0, $self->loc("Link could not be created") );
     }
 
+    my $basetext = $self->FormatLink(Object => $link->BaseObj,
+				     FallBack => $args{Base});
+    my $targettext = $self->FormatLink(Object => $link->TargetObj,
+				       FallBack => $args{Target});
     my $TransString =
-      "Record $args{'Base'} $args{Type} record $args{'Target'}.";
-
-    return ( $linkid, $self->loc( "Link created ([_1])", $TransString ) );
+      "$basetext $args{Type} $targettext.";
+    return ( $linkid, $TransString ) ;
 }
 
 # }}}
@@ -1305,13 +1330,16 @@
 
     $link->LoadByParams( Base=> $args{'Base'}, Type=> $args{'Type'}, Target=>  $args{'Target'} );
     #it's a real link. 
-    if ( $link->id ) {
 
+    if ( $link->id ) {
+	my $basetext = $self->FormatLink(Object => $link->BaseObj,
+				     FallBack => $args{Base});
+	my $targettext = $self->FormatLink(Object => $link->TargetObj,
+				       FallBack => $args{Target});
         my $linkid = $link->id;
         $link->Delete();
-
-        my $TransString = "Record $args{'Base'} no longer $args{Type} record $args{'Target'}.";
-        return ( 1, $self->loc("Link deleted ([_1])", $TransString));
+        my $TransString = "$basetext no longer $args{Type} $targettext.";
+        return ( 1, $TransString);
     }
 
     #if it's not a link we can find


More information about the Rt-commit mailing list