Add an ObjectTypeFromlookupType method and document RecordClassFromLookupType

RecordClassFromLookupType is useful when joining to ObjectCustomFields,
but there wasn't an existing method for code that wants to join to
ObjectCustomFieldValues, so we can borrow the code and tweak the regex a
bit.
ObjectType/RecordTypeFromLookupType as class methods

Where LookupType must be passed as an argument.
Refactor part of LimitToGlobalOrObjectId into LimitToObjectId

Useful when you only want to find CFs applied to a certain object and
not global ones too.
Decipher TicketSQL CF identifiers using a passed in LookupType

The LookupType is necessary to find the correct CF by name, as well as
to support the arcane CF.ObjectId.{CFName} syntax, for arbitrary object
types (not just ticket CFs on RT::Queue).

Potential syntax made possible, for example:

    TxnCF.{CFName}
    TxnCF.Queue.{CFName}
    ArticleCF.Class.{CFName}

The CF lookup behaviour of CF.Queue.{CFName} changes slightly due to
changes in which custom fields API is used.  Most notably, such syntax
previously exhibited the following behaviour but no longer does:

    • Disabled CFs could be found if no enabled CFs matched.
    • The existence of multiple matching CFs with the same name (& within
      the same queue) was ignored; the first was the only one used.

As CF.Queue.{CFName} is fairly arcane syntax, these changes shouldn't
affect most usage of TicketSQL.  It is unlikely that anyone using the
extended syntax is intentionally relying on any of the discontinued
behaviour noted above.  Disabled CFs, even if found, are eliminated from
results by later code.  The two behaviour changes are effectively bug
fixes.
Refactor _CustomFieldJoin to take a LookupType

… so that we can join to the correct table if not Tickets.  An
extensible registration system is introduced to determine how to join
CFs to applied objects.  The join used depends on the tuple of
(collection class, lookup type).  For example, consider that both
(RT::Ticket, RT::Queue-RT::Ticket) and (RT::Queue, RT::Queue) require no
additional join (so they return "main").

This lets _CustomFieldJoin handle joining for transaction CFs or other
CFs which may want to be searched.
Refactor _CustomFieldLimit to use a LookupType in %FIELD_METADATA

Potential new search clauses, such as searching transaction CFs, want to
match all the different ways that ticket CFs can.  It makes sense to
just wrap the limits in a LookupType change (especially since
_CustomFieldLimit happens to be recursive for IP and Date searches).
Add callbacks for before and after the query builder criteria picker
PickTicketCFs refactored from the now-generic PickCFs

PickCFs may now be used for other types of CFs.  Callback semantics
remain the same, so no extension using the callbacks in PickCFs will be
broken.
Parse CustomField.{Bar} and other aliases when adding a clause in the Query Builder

Extends the parsing from only CF.{…} to any of the accepted TicketSQL
aliases, such as CustomField.{…}.  The aliases are looked up in
%RT::Tickets::FIELD_METADATA so any additional custom field limits are
automatically recognized.
Add TxnCF.{Name} and TransactionCF.{Name} syntax to TicketSQL

Reuses all the logic of ticket CF searching.
Basic tests for searching transaction CFs
Report correct line numbers for failed tests
Meaningful negative searching is hard, comment some tests out as TODO for now

Negative searching is especially hard when there are multiple records
joining back to a ticket.
Tests for multiple transaction CFs named the same, applied to different queues
QueueCF.{Name} in TicketSQL

This makes queue CFs suddenly useful for queries such as:

    QueueCF.{Type} = 'support'

Currently it joins from Tickets to Queues in order to join to
OCFs/OCFVs, but a future optimization could remove the Tickets → Queues
join in favor of limiting on Tickets.Queue directly.
Transaction and Queue CF pickers in the Query Builder
Rename RT::CustomField->_ForObjectType to RegisterLookupType

As custom fields are extensible by plugins and this method is called
outside of RT::CustomField even in core RT, it was already implicitly
public.  Make it explicitly public and name it to match the
now-canonical name "lookup type".  This is, after all, what the column
is called.  "Register" matches the phrasing we've adopted elsewhere.

Renames and privatizes %FRIENDLY_OBJECT_TYPES as well to match.  Other
code should access lookup type and friendly names via the API.

Deprecates _ForObjectType until 4.4.
Merge branch '4.2/search-txn-and-queue-cfs'