[rt-users] Customize messagebox default reply (due to ugly $WebExternalAuth / SAML / Userid)

Ruslan Zakirov ruz at bestpractical.com
Wed Mar 27 11:59:49 EDT 2013


On Wed, Mar 27, 2013 at 6:01 PM, Marit Hoen <marit.hoen at hotmail.com> wrote:
> Hi,
>
> We are using Request Tracker 4.07 with an external SAML authentication
> solution. As a result, our user's unique username is replaced by something
> inhuman like 131145345 at sub.something.com.
>
> When a user updates a ticket (e.g. reply) the default messagebox shows
> something like:
>
> On Wed Mar 27 10:17:17 2013, 131145345 at sub.something.com wrote:
>> body text
>
> Since a user is not really familiar with "1311345 at sub.something.com" (this
> is a identifier from our SAML solution, not known by users) I would rather
> have something like the users e-mail address, not the username, e.g.:
>
> On Wed Mar 27 10:17:17 2013, john.doe at something.com wrote:
>> body text
>
> How can I customize this (or something similar) the proper way, without
> "hacking" Request Trackers code (and run into problems when upgrading)?

We recently extracted code that adds that line into a very small
method especially to allow people to override how that line is
generated. You need QuoteHeader method in lib/RT/Transaction.pm.
Quoting commit that added it:

commit e6cfc69c40da44fa367e1e7dad0deeae909819ac
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Dec 25 16:22:22 2012 +0400

    extract Transaction->QuoteHeader method

    Code that is adding "On <date> <person> wrote:" in front of
    quoted context is burried in other method, so it's hard to
    change style of the quoting. Extract it into a new method.

diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index fa0d590..47ae072 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -381,13 +381,24 @@ sub Content {
         }

         $content =~ s/^/> /gm;
-        $content = $self->loc("On [_1], [_2] wrote:",
$self->CreatedAsString, $self->CreatorObj->Name)
-          . "\n$content\n\n";
+        $content = $self->QuoteHeader . "\n$content\n\n";
     }

     return ($content);
 }

+=head2 QuoteHeader
+
+Returns text prepended to content when transaction is quoted
+(see C<Quote> argument in L</Content>). By default returns
+localized "On <date> <user name> wrote:\n".
+
+=cut
+
+sub QuoteHeader {
+    my $self = shift;
+    return $self->loc("On [_1], [_2] wrote:", $self->CreatedAsString,
$self->CreatorObj->Name);
+}


 =head2 Addresses




>
> Help is much appreciated, best regards,
>
> Marit



-- 
Best regards, Ruslan.



More information about the rt-users mailing list