[rt-users] Accessing User_Local.pm user defined methods from Mason

Paulo Filipe Andrade pauloandrade at ist.utl.pt
Fri Jan 25 13:22:46 EST 2008


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%></option>

to

 ><%$User->DisplayName%></option>

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 at ist.utl.pt






More information about the rt-users mailing list