[Rt-commit] r2516 - in rt/branches/3.4-RELEASE: . lib/RT

jesse at bestpractical.com jesse at bestpractical.com
Sun Mar 27 00:21:36 EST 2005


Author: jesse
Date: Sun Mar 27 00:21:35 2005
New Revision: 2516

Modified:
   rt/branches/3.4-RELEASE/   (props changed)
   rt/branches/3.4-RELEASE/lib/RT/Transaction_Overlay.pm
Log:
 r10211 at hualien:  jesse | 2005-03-27 13:18:07 +0800
 * Updated RT::Transaction to return better Foo changed from "bar" to "baz" messages


Modified: rt/branches/3.4-RELEASE/lib/RT/Transaction_Overlay.pm
==============================================================================
--- rt/branches/3.4-RELEASE/lib/RT/Transaction_Overlay.pm	(original)
+++ rt/branches/3.4-RELEASE/lib/RT/Transaction_Overlay.pm	Sun Mar 27 00:21:35 2005
@@ -531,7 +531,6 @@
 sub BriefDescription {
     my $self = shift;
 
-
     #If it's a comment or a comment email record,
     #  we need to be extra special careful
     if ( $self->__Value('Type') =~ /^Comment/ ) {
@@ -541,44 +540,67 @@
     }
 
     #if they ain't got rights to see, don't let em
-    elsif ($self->__Value('ObjectType') eq "RT::Ticket") {
+    elsif ( $self->__Value('ObjectType') eq "RT::Ticket" ) {
         unless ( $self->CurrentUserHasRight('ShowTicket') ) {
             return ( $self->loc("Permission Denied") );
         }
     }
 
-    my $type = $self->Type; #cache this, rather than calling it 30 times
+    my $type = $self->Type;    #cache this, rather than calling it 30 times
 
-    if ( !defined( $type ) ) {
+    if ( !defined($type) ) {
         return $self->loc("No transaction type specified");
     }
 
     my $obj_type = $self->FriendlyObjectType;
 
     if ( $type eq 'Create' ) {
-        return ($self->loc("[_1] created", $obj_type));
+        return ( $self->loc( "[_1] created", $obj_type ) );
     }
     elsif ( $type =~ /Status/ ) {
         if ( $self->Field eq 'Status' ) {
             if ( $self->NewValue eq 'deleted' ) {
-                return ($self->loc("[_1] deleted", $obj_type));
+                return ( $self->loc( "[_1] deleted", $obj_type ) );
             }
             else {
-                return ( $self->loc("Status changed from [_1] to [_2]", $self->loc($self->OldValue), $self->loc($self->NewValue) ));
+                return (
+                    $self->loc(
+                        "Status changed from [_1] to [_2]",
+                        "'" . $self->loc( $self->OldValue ) . "'",
+                        "'" . $self->loc( $self->NewValue ) . "'"
+                    )
+                );
 
             }
         }
 
         # Generic:
-       my $no_value = $self->loc("(no value)"); 
-        return ( $self->loc( "[_1] changed from [_2] to [_3]", $self->Field , ( $self->OldValue || $no_value ) ,  $self->NewValue ));
+        my $no_value = $self->loc("(no value)");
+        return (
+            $self->loc(
+                "[_1] changed from [_2] to [_3]",
+                $self->Field,
+                ( $self->OldValue ? "'" . $self->OldValue . "'" : $no_value ),
+                "'" . $self->NewValue . "'"
+            )
+        );
     }
 
-    if (my $code = $_BriefDescriptions{$type}) {
+    if ( my $code = $_BriefDescriptions{$type} ) {
         return $code->($self);
     }
 
-    return $self->loc( "Default: [_1]/[_2] changed from [_3] to [_4]", $type, $self->Field, $self->OldValue, $self->NewValue );
+    return $self->loc(
+        "Default: [_1]/[_2] changed from [_3] to [_4]",
+        $type,
+        $self->Field,
+        (
+            $self->OldValue
+            ? "'" . $self->OldValue . "'"
+            : $self->loc("(no value)")
+        ),
+        "'" . $self->NewValue . "'"
+    );
 }
 
 %_BriefDescriptions = (
@@ -762,7 +784,7 @@
             return $self->loc( "[_1] changed from [_2] to [_3]", $self->Field, $t2->AsString, $t1->AsString );
         }
         else {
-            return $self->loc( "[_1] changed from [_2] to [_3]", $self->Field, $self->OldValue, $self->NewValue );
+            return $self->loc( "[_1] changed from [_2] to [_3]", $self->Field, ($self->OldValue? "'".$self->OldValue ."'" : $self->loc("(no value)")) , "'". $self->NewValue."'" );
         }
     },
     PurgeTransaction => sub {


More information about the Rt-commit mailing list