Documentation
</> Developer Portal

NAME

  RT::Links - A collection of Link objects

SYNOPSIS

  use RT::Links;
  my $links = RT::Links->new($CurrentUser);

DESCRIPTION

METHODS

LimitRefersTo URI

find all things that refer to URI

LimitReferredToBy URI

find all things that URI refers to

if linked to a local ticket and is deleted, then the link is invalid.

DefaultLinkType PARAMHASH

Returns the relationship first selected when a user adds a link: one of DependsOn, DependedOnBy, MemberOf, Members, RefersTo or ReferredToBy, as seen from the object being linked from.

    my $type = RT::Links->DefaultLinkType(
        CurrentUser => $current_user,
        Default     => $page_layout_default,
    );

Takes CurrentUser, required, and Default, the optional default from the Links widget's page layout. The user's LinksDefaultType preference comes first, then Default, then the $LinksDefaultType setting.

SortByActivityType RECORDS

Takes a list of linked records, such as tickets or assets. Returns two array references, not one sorted list: the active records first, then the inactive ones, each keeping the order given.

    my ( $active, $inactive ) = RT::Links->SortByActivityType(@records);
    my @active_first = ( @$active, @$inactive );

A record is inactive when its lifecycle lists its status as inactive; a record without a lifecycle counts as active. It doesn't need an RT::Links object, so call it on the class as above.

FilterLinkListing PARAMHASH

Takes the linked records of one class and returns a collection of them, filtered and ordered the way a links listing such as the Links widget shows them. Returns undef for a class with no collection, or with no ids.

    my $tickets = RT::Links->FilterLinkListing(
        CurrentUser      => $current_user,
        Class            => 'RT::Ticket',
        Ids              => \@ticket_ids,
        RelationshipType => 'ReferredToBy',
    );
CurrentUser

Required. The collection is searched as this user, so records the user can't see are left out.

Class

The record class, one of RT::Ticket, RT::Transaction, RT::Asset, RT::Article, RT::User or RT::Group.

Ids

An array reference of record ids.

RelationshipType

The relationship the records were found through, as named by the method that lists them, such as DependsOn or ReferredToBy. A ReferredToBy listing leaves out reminders, which refer to the ticket they belong to.

The search's own defaults also apply: tickets don't include deleted tickets, for example. Disabled articles are left out. Users and groups are ordered by name, and everything else by id, with active tickets and assets ahead of inactive ones.

LinkListingCount PARAMHASH

Returns how many links of an object a links listing shows: the records "FilterLinkListing" keeps, plus links to URLs. Use it to tell whether a listing has anything to show at all, before any cap on rows or default filter is applied.

    my $total = RT::Links->LinkListingCount(
        CurrentUser => $current_user,
        Object      => $ticket,
    );

Takes CurrentUser and Object, required, and Types, an optional array reference of relationship methods to count. It defaults to all of DependsOn, DependedOnBy, MemberOf, Members, RefersTo and ReferredToBy.

LinkListingFormat PARAMHASH

Returns the %LinksFormat format for linked records of one class, as an object's links listing shows them, or undef if none is configured. In list context, also returns which %LinksFormat entry the format came from: the queue's id for a queue entry, or Default.

    my ( $format, $entry ) = RT::Links->LinkListingFormat(
        Object => $ticket,
        Class  => 'RT::Asset',
    );

Object is the object whose links are listed. For a ticket, the entry for its queue applies, falling back to Default for a class that entry leaves out. Any other object, or none, uses Default. Class is the class of the linked records, such as RT::Ticket or RT::Asset.

The entry goes in the page, as a data-links-format attribute that site CSS can target. It names a queue by id, which every user can be shown, so the attribute and the layout it selects are the same for everyone, including users who can't see the queue's name.

← Back to index