Accessing User_Local.pm user defined methods from Mason

Hi,
I’m trying to get the “Owner” drop downs in RT to display a name built
by the following method:

This is in User_Local.pm

no warnings qw(redefine);

sub DisplayName {
my $self = shift;
my $displayName = $self->Name;

 if($self->RealName =~ /\b(\w+)\b.*\b(\w+)\b/){
     $displayName = "$1 $2";
 }

 $displayName = (($self->NickName) ? $self->NickName :  

$displayName);

 return ($displayName);

}

1;

Then I changed Elements/SelectOwner (line 57) from

<%$User->Name%>

to

<%$User->DisplayName%>

Now, however I get an error from Mason stating:

RT::CurrentUser::DisplayName Unimplemented in HTML::Mason::Commands. (/
usr/local/share/request-tracker3.6/html/Elements/SelectOwner line 57)

I have searched a bit through the code and found that CurrentUser
defines this:

sub _CoreAccessible {
{
Name => { ‘read’ => 1 },
Gecos => { ‘read’ => 1 },
RealName => { ‘read’ => 1 },
Lang => { ‘read’ => 1 },
Password => { ‘read’ => 0, ‘write’ => 0 },
EmailAddress => { ‘read’ => 1, ‘write’ => 0 },
};

}

I don’t really know what this is, but I’m guessing it’s for database
getters and setters, which is not really what I want. I just want to
be able to access my method.
What would be the correct way to be able to access my method from mason?

I have tried adding DisplayName => { ‘read’ => 1 }, and it works…
kind of. The first user’s name in the drop down never gets displayed.
Somehow the first call to the method never goes through…
Any suggestions are welcome!

Thank you for your time

Paulo F. Andrade
pauloandrade@ist.utl.pt

Hello,

–Am 25. Januar 2008 18:22:46 +0000 schrieb Paulo Filipe Andrade
pauloandrade@ist.utl.pt:

I have tried adding DisplayName => { ‘read’ => 1 }, and it works…
kind of. The first user’s name in the drop down never gets displayed.
Somehow the first call to the method never goes through…
Any suggestions are welcome!

I am quite sure that the first user in the dropdown is “Nobody” which has
neither Nickname nor Realname. You need a fallback (e.g. to User->Name if
both are empty).

We have already a patch for the same thing (and more): We did not like that
in some cases the Emailaddress was displayed when showing a user in other
cases the Username (with or without Real Name).

So we patched most occurrences where users are displayed with a call to
DisplayName or (in some cases) FriendlyEmailAddress, methods which we
implemented in User_Overlay.pm.

I attach a link to our patch here for reference. You may find that it is
worth to modify other places of User display as well. (The patch is not yet
ready because I am not sure whether we missed some places, where a User
will be displayed - so we did not yet modify Admin pages).

http://page.mi.fu-berlin.de/pape/rt3/patches/rt/unified_user_display.patch

Regards,
Dirk.

Dr. Dirk Pape (eAS - Projektleitung Campus Management)
Freie Universitaet Berlin
Grunewaldstr. 34a, 12165 Berlin
Tel. +49 (30) 838 75143, Fax. +49 (30) 838 54654

Thanks for the patch!
You might consider using the display name when sending an email too!

lib/RT/Action/SendEmail.pm line 640

  • my $friendly_name = $self->TransactionObj->CreatorObj->RealName
  • my $friendly_name = $self->TransactionObj->CreatorObj->DisplayNameOn Jan 25, 2008, at 8:21 PM, Dirk Pape wrote:

Hello,

–Am 25. Januar 2008 18:22:46 +0000 schrieb Paulo Filipe Andrade
pauloandrade@ist.utl.pt:

I have tried adding DisplayName => { ‘read’ => 1 }, and it works…
kind of. The first user’s name in the drop down never gets displayed.
Somehow the first call to the method never goes through…
Any suggestions are welcome!

I am quite sure that the first user in the dropdown is “Nobody”
which has
neither Nickname nor Realname. You need a fallback (e.g. to User-

Name if
both are empty).

We have already a patch for the same thing (and more): We did not
like that
in some cases the Emailaddress was displayed when showing a user in
other
cases the Username (with or without Real Name).

So we patched most occurrences where users are displayed with a call
to
DisplayName or (in some cases) FriendlyEmailAddress, methods which we
implemented in User_Overlay.pm.

I attach a link to our patch here for reference. You may find that
it is
worth to modify other places of User display as well. (The patch is
not yet
ready because I am not sure whether we missed some places, where a
User
will be displayed - so we did not yet modify Admin pages).

<http://page.mi.fu-berlin.de/pape/rt3/patches/rt/unified_user_display.patch

Regards,
Dirk.


Dr. Dirk Pape (eAS - Projektleitung Campus Management)
Freie Universitaet Berlin
Grunewaldstr. 34a, 12165 Berlin
Tel. +49 (30) 838 75143, Fax. +49 (30) 838 54654


The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com