FW: [rt-users] choosing template on the fly

Dimitry Faynerman dimitry.faynerman at hypermediasystems.com
Tue May 11 12:27:59 EDT 2004


Yep, you're correct about the strange code
I'll retest it again



-----Original Message-----
From: Ruslan U. Zakirov [mailto:cubic at acronis.ru] 
Sent: Tuesday, May 11, 2004 8:14 AM
To: Dimitry Faynerman
Cc: rt-users at lists.fsck.com
Subject: Re: FW: [rt-users] choosing template on the fly

I like your idea and solution, but I refactored it a little into _Local 
overlay file which doesn't touch Prepare sub. It use TemplateObj sub 
cause it simple and right places to do such override.

I've done only use_ok test. Could you test it? Then I or you can fill it 
in wiki page.

Comment about strange code below.

				Best regards. Ruslan.

Dimitry Faynerman wrote:
[snip]
> 
> Here's the code:
> 
> sub Prepare {
>     my $self = shift;
> 
>     # This actually populates the MIME::Entity fields in the Template
Object
> 
>     unless ( $self->TemplateObj ) {
>         $RT::Logger->warning("No template object handed to $self\n");
>     }
> 
>     # my changes start here
===============================================
>     # Use japanese template (if exists) if user's language is japanese
> 
>     my $UserObj = RT::User->new( $RT::SystemUser );
>
$UserObj->Load($self->TicketObj->Requestors->UserMembersObj->First->Id);
> 
>     if (($self->TemplateObj) &&
>         ((!$UserObj->Lang) || ($UserObj->Lang ne 'en'))) {
This 'if condition' will be true if $UserObj->Lang is not defined or 
empty string. Refactored code has slightly different condtion.


>        my $rememberEnglishId = $self->TemplateObj->Id;
>        $self->TemplateObj->Load(
>             $self->TemplateObj->Name . " (" . $UserObj->Lang . ")");
>        if (! $self->TemplateObj->Id) {
>           $self->TemplateObj->Load($rememberEnglishId);
>        }
>     }
>     # my changes end here ===============================================
> 
> 
[snip]
> -Dimitry





More information about the rt-users mailing list