RT 5.0.3 Documentation

RT::Lifecycle

Go to latest version →

NAME

RT::Lifecycle - class to access and manipulate lifecycles

DESCRIPTION

A lifecycle is a list of statuses that a ticket can have. There are three groups of statuses: initial, active and inactive. A lifecycle also defines possible transitions between statuses. For example, in the 'default' lifecycle, you may only change status from 'stalled' to 'open'.

It is also possible to define user-interface labels and the action a user should perform during a transition. For example, the "open -> stalled" transition would have a 'Stall' label and the action would be Comment. The action only defines what form is showed to the user, but actually performing the action is not required. The user can leave the comment box empty yet still Stall a ticket. Finally, the user can also just use the Basics or Jumbo form to change the status with the usual dropdown.

METHODS

new

Simple constructor, takes no arguments.

Load Name => NAME, Type => TYPE

Takes a name of the lifecycle and loads it. If only a Type is provided, loads the global lifecycle with statuses from all named lifecycles of that type.

Can be called as class method, returns a new object, for example:

    my $lifecycle = RT::Lifecycle->Load( Name => 'default');

Returns an object which may be a subclass of RT::Lifecycle (RT::Lifecycle::Ticket, for example) depending on the type of the lifecycle in question.

List

List available lifecycles. This list omits RT's default approvals lifecycle.

Takes: An optional parameter for lifecycle types other than tickets. Defaults to 'ticket'.

Returns: A sorted list of available lifecycles.

ListAll

Returns a list of all lifecycles, including approvals.

Takes: An optional parameter for lifecycle types other than tickets. Defaults to 'ticket'.

Returns: A sorted list of all available lifecycles.

Name

Returns name of the loaded lifecycle.

Type

Returns the type of the loaded lifecycle.

Getting statuses and validating.

Methods to get statuses in different sets or validating them.

Valid

Returns an array of all valid statuses for the current lifecycle. Statuses are not sorted alphabetically, instead initial goes first, then active and then inactive.

Takes optional list of status types, from 'initial', 'active' or 'inactive'. For example:

    $lifecycle->Valid('initial', 'active');

IsValid

Takes a status and returns true if value is a valid status for the current lifecycle. Otherwise, returns false.

Takes optional list of status types after the status, so it's possible check validity in particular sets, for example:

    # returns true if status is valid and from initial or active set
    $lifecycle->IsValid('some_status', 'initial', 'active');

See also </valid>.

StatusType

Takes a status and returns its type, one of 'initial', 'active' or 'inactive'.

Initial

Returns an array of all initial statuses for the current lifecycle.

IsInitial

Takes a status and returns true if value is a valid initial status. Otherwise, returns false.

Active

Returns an array of all active statuses for this lifecycle.

IsActive

Takes a value and returns true if value is a valid active status. Otherwise, returns false.

Inactive

Returns an array of all inactive statuses for this lifecycle.

IsInactive

Takes a value and returns true if value is a valid inactive status. Otherwise, returns false.

Default statuses

In some cases when status is not provided a default values should be used.

DefaultStatus

Takes a situation name and returns value. Name should be spelled following spelling in the RT config file.

DefaultOnCreate

Returns the status that should be used by default when ticket is created.

Transitions, rights, labels and actions.

Transitions

Takes status and returns list of statuses it can be changed to.

Is status is empty or undefined then returns list of statuses for a new ticket.

If argument is ommitted then returns a hash with all possible transitions in the following format:

    status_x => [ next_status, next_status, ... ],
    status_y => [ next_status, next_status, ... ],

IsTransition

Takes two statuses (from -> to) and returns true if it's valid transition and false otherwise.

CheckRight

Takes two statuses (from -> to) and returns the right that should be checked on the ticket.

RightsDescription [TYPE]

Returns hash with description of rights that are defined for particular transitions.

Actions

Takes a status and returns list of defined actions for the status. Each element in the list is a hash reference with the following key/value pairs:

from - either the status or *
to - next status
label - label of the action
update - 'Respond', 'Comment' or '' (empty string)

Moving tickets between lifecycles

MoveMap

Takes lifecycle as a name string or an object and returns a hash reference with move map from this cycle to provided.

HasMoveMap

Takes a lifecycle as a name string or an object and returns true if move map defined for move from this cycle to provided.

NoMoveMaps

Takes no arguments and returns hash with pairs that has no move maps.

Localization

ForLocalization

A class method that takes no arguments and returns list of strings that require translation.

CreateLifecycle( CurrentUser => undef, Name => undef, Type => undef, Clone => undef )

Create a lifecycle. To clone from an existing lifecycle, pass its Name to Clone.

Returns (STATUS, MESSAGE). STATUS is true if succeeded, otherwise false.

UpdateLifecycle( CurrentUser => undef, LifecycleObj => undef, NewConfig => undef, Maps => undef )

Update passed lifecycle to the new configuration.

Returns (STATUS, MESSAGE). STATUS is true if succeeded, otherwise false.

UpdateMaps( CurrentUser => undef, Maps => undef )

Update lifecycle maps.

Returns (STATUS, MESSAGE). STATUS is true if succeeded, otherwise false.

ValidateLifecycle( CurrentUser => undef, Lifecycle => undef, Name => undef )

Validate passed Lifecycle data structure.

Returns (STATUS, MESSAGE). STATUS is true if succeeded, otherwise false.

ValidateLifecycleMaps( CurrentUser => undef )

Validate lifecycle Maps.

Returns (STATUS, MESSAGES). STATUS is true if succeeded, otherwise false.

UpdateLifecycleLayout( CurrentUser => undef, LifecycleObj => undef, NewLayout => undef )

Update lifecycle's web admin layout.

Returns (STATUS, MESSAGE). STATUS is true if succeeded, otherwise false.

← Back to index