RT 4.0.24 Documentation

This version has reached its end of life and is out of support. Please contact us for upgrade assistance.

RT::Template

Go to latest version →

NAME

  RT::Template - RT's template object

SYNOPSIS

  use RT::Template;

DESCRIPTION

METHODS

_Value

Takes the name of a table column. Returns its value as a string, if the user passes an ACL check, otherwise returns undef.

Load <identifier>

Load a template, either by number or by name.

Note that loading templates by name using this method is ambiguous. Several queues may have template with the same name and as well global template with the same name may exist. Use "LoadGlobalTemplate" and/or LoadQueueTemplate to get precise result.

LoadGlobalTemplate NAME

Load the global template with the name NAME

LoadQueueTemplate (Queue => QUEUEID, Name => NAME)

Loads the Queue template named NAME for Queue QUEUE.

Note that this method doesn't load a global template with the same name if template in the queue doesn't exist. THe following code can be used:

    $template->LoadQueueTemplate( Queue => $queue_id, Name => $template_name );
    unless ( $template->id ) {
        $template->LoadGlobalTemplate( $template_name );
        unless ( $template->id ) {
            # no template
            ...
        }
    }
    # ok, template either queue's or global
    ...

Create

Takes a paramhash of Content, Queue, Name and Description. Name should be a unique string identifying this Template. Description and Content should be the template's title and content. Queue should be 0 for a global template and the queue # for a queue-specific template.

Returns the Template's id # if the create was successful. Returns undef for unknown database failure.

Delete

Delete this template.

IsEmpty

Returns true value if content of the template is empty, otherwise returns false.

MIMEObj

Returns MIME::Entity object parsed using "Parse" method. Returns undef if last call to "Parse" failed or never be called.

Note that content of the template is characters, but the contents of all MIME::Entity objects (including the one returned by this function, are bytes in UTF-8.

Parse

This routine performs Text::Template parsing on the template and then imports the results into a MIME::Entity so we can really use it. Use "MIMEObj" method to get the MIME::Entity object.

Takes a hash containing Argument, TicketObj, and TransactionObj and other arguments that will be available in the template's code. TicketObj and TransactionObj are not mandatory, but highly recommended.

It returns a tuple of (val, message). If val is false, the message contains an error message.

CurrentUserHasQueueRight

Helper function to call the template's queue's CurrentUserHasQueueRight with the passed in args.

SetType

If setting Type to Perl, require the ExecuteCode right.

SetContent

If changing content and the type is Perl, require the ExecuteCode right.

CompileCheck

If the template's Type is Perl, then compile check all the codeblocks to see if they are syntactically valid. We eval them in a codeblock to avoid actually executing the code.

Returns an (ok, message) pair.

CurrentUserCanRead

id

Returns the current value of id. (In the database, id is stored as int(11).)

Queue

Returns the current value of Queue. (In the database, Queue is stored as int(11).)

SetQueue VALUE

Set Queue to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, Queue will be stored as a int(11).)

QueueObj

Returns the Queue Object which has the id returned by Queue

Name

Returns the current value of Name. (In the database, Name is stored as varchar(200).)

SetName VALUE

Set Name to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, Name will be stored as a varchar(200).)

Description

Returns the current value of Description. (In the database, Description is stored as varchar(255).)

SetDescription VALUE

Set Description to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, Description will be stored as a varchar(255).)

Type

Returns the current value of Type. (In the database, Type is stored as varchar(16).)

SetType VALUE

Set Type to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, Type will be stored as a varchar(16).)

Language

Returns the current value of Language. (In the database, Language is stored as varchar(16).)

SetLanguage VALUE

Set Language to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, Language will be stored as a varchar(16).)

TranslationOf

Returns the current value of TranslationOf. (In the database, TranslationOf is stored as int(11).)

SetTranslationOf VALUE

Set TranslationOf to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, TranslationOf will be stored as a int(11).)

Content

Returns the current value of Content. (In the database, Content is stored as text.)

SetContent VALUE

Set Content to VALUE. Returns (1, 'Status message') on success and (0, 'Error Message') on failure. (In the database, Content will be stored as a text.)

LastUpdated

Returns the current value of LastUpdated. (In the database, LastUpdated is stored as datetime.)

LastUpdatedBy

Returns the current value of LastUpdatedBy. (In the database, LastUpdatedBy is stored as int(11).)

Creator

Returns the current value of Creator. (In the database, Creator is stored as int(11).)

Created

Returns the current value of Created. (In the database, Created is stored as datetime.)

← Back to index