RT 5.0.2 Documentation

RT::SearchBuilder

Go to latest version →

NAME

  RT::SearchBuilder - a baseclass for RT collection objects

SYNOPSIS

DESCRIPTION

METHODS

LimitToEnabled

Only find items that haven't been disabled

LimitToDeleted

Only find items that have been deleted.

FindAllRows

Find all matching rows, regardless of whether they are disabled or not

LimitCustomField

Takes a paramhash of key/value pairs with the following keys:

CUSTOMFIELD - CustomField id. Optional
OPERATOR - The usual Limit operators
VALUE - The value to compare against

RecordClass

Returns class name of records in this collection. This generic implementation just strips trailing 's'.

RegisterCustomFieldJoin

Takes a pair of arguments, the first a class name and the second a callback function. The class will be used to call "CustomFieldLookupType" in RT::Record. The callback will be called when limiting a collection of the caller's class by a CF of the passed class's lookup type.

The callback is passed a single argument, the current collection object ($self).

An example from RT::Tickets:

    __PACKAGE__->RegisterCustomFieldJoin(
        "RT::Transaction" => sub { $_[0]->JoinTransactions }
    );

Returns true on success, undef on failure.

_JoinForLookupType

Takes an RT::CustomField LookupType and joins this collection as appropriate to reach the object records to which LookupType applies. The object records will be of the class returned by "ObjectTypeFromLookupType" in RT::CustomField.

Returns the join alias suitable for further limiting against object properties.

Returns undef on failure.

Used by "_CustomFieldJoin".

_CustomFieldJoin

Factor out the Join of custom fields so we can use it for sorting too

Limit PARAMHASH

This Limit sub calls SUPER::Limit, but defaults "CASESENSITIVE" to 1, thus making sure that by default lots of things don't do extra work trying to match lower(colname) agaist lc($val);

We also force VALUE to NULL when the OPERATOR is IS or IS NOT. This ensures that we don't pass invalid SQL to the database or allow SQL injection attacks when we pass through user specified values.

ItemsOrderBy

If it has a SortOrder attribute, sort the array by SortOrder. Otherwise, if it has a "Name" attribute, sort alphabetically by Name Otherwise, just give up and return it in the order it came from the db.

ItemsArrayRef

Return this object's ItemsArray, in the order that ItemsOrderBy sorts it.

ColumnMapClassName

ColumnMap needs a Collection name to load the correct list display. Depluralization is hard, so provide an easy way to correct the naive algorithm that this code uses.

NewItem

Returns a new item based on "RecordClass" using the current user.

NotSetDateToNullFunction

Takes a paramhash with an optional FIELD key whose value is the name of a date column. If no FIELD is provided, a literal ? placeholder is used so the caller can fill in the field later.

Returns a SQL function which evaluates to NULL if the FIELD is set to the Unix epoch; otherwise it evaluates to FIELD. This is useful because RT currently stores unset dates as a Unix epoch timestamp instead of NULL, but NULLs are often more desireable.

← Back to index