Move custom field search code into RT::SearchBuilder

This merely moves two functions as-is, in preparation for refactoring
them to be useful on non-Ticket classes.  As such, the code is placed in
_LimitCustomField, and the existing LimitCustomField implementation is
unchanged -- _LimitCustomField is still Ticket-specific.
Rename $TicketCFs variable to be more general
Simplify _CustomFieldJoin to take a key and a CF||string

The logic surrounding the arguments for _CustomFieldJoin is more complex
than necessary; simplify it by expecting either a CF name of a CF object.
Switch to a more standard paramhash for arguments

This also collapses the $cfid, $cf, $queue, and $field arguments down
into the more understandable KEY and CUSTOMFIELD.
Prevent confusion about what %args can override

As the basic arguments are delete()'d from %args, all the remains
therein are extra arguments, like ENTRYAGGREGATOR or SUBCLAUSE.  Clarify
the precedence of the arguments by moving %args to the beginning of the
Limit() call; this changes no functionality.
Generalize _CustomFieldJoin somewhat

This replaces explicit RT::Ticket ObjectTypes and LookupTypes with their
more general forms.  It also factors out the concept of listing all
applicable CFs that match a given name -- which may be additionally
limited by queues, in the case of tickets.
Add explicit subclauses to all limits

RT::Tickets assumes a subclause of "ticketsql" for all Limit and
_OpenParen / _CloseParen calls.  Allow calling on non-Tickets
collections by providing a default SUBCLAUSE name, and performing all
Limit, _OpenParen, and _CloseParen adjustments therein.
Treat CF ids as specific identifiers like objects, not as names
Switch the general LimitCustomField to the new implementation

Use the new _LimitCustomField implementation for RT::SearchBuilder's
LimitCustomField.  The former is not simply renamed to the latter
because RT::Tickets contains a LimitCustomField which acts on
"restrictions", and must continue to do so.  As such, _LimitCustomField
(and its recursive calls) must continue to occupy some other name.

This removes the (dubious and unused) ability to call LimitCustomField
with no CUSTOMFIELD provided, which searches within all custom fields.
It adds all of the complex date and IP parsing capabilities that Tickets
have enjoyed.
Refactor CF ordering into a method on SearchBuilder
SearchBuilder forces QUOTEVALUE => 0 for IS and IS NOT limits

Remove the unnecessary (and in the first hunk, misleading) QUOTEVALUEs.
Remove uses of ::Unique; our SELECT DISTINCT is sufficient

Rather than import a mixin (twice, in Tickets' case (?!)) which
unique-ifies the results, rely on our SELECT DISCINCT machinery.  The
original code was added when DistinctQuery was unimplemented for some
database handles.
Ensure that ENTRYAGGRATOR does not mistakenly OR the ordering limit with some other limit
Update style of test file, and ensure that tests run in prefictable order
Fix != conditions with an explicit column provided

Previously, the check for "or allow a row which has no value" failed to
apply if an explicit column was provided.  Refactor the parenthization
slightly, and allow the possibility of no-value even in the case of
searching through particular columns.
Tests for tickets in alternate queues, without the CF applied

A queue without the CF applied should act identically to a ticket with
no value for that CF, in all cases.
Condense IS NULL and IS NOT NULL logic

There is no hint as to why with a column specified, null tests should
act differently than without -- which the recently added tests bear out.
Simplify the logic by removing the $column check.
Factor out blessed($cf) check
Move IPAddressRange recursive call earlier
Move Date range check for DateTimes into a recursive call, earlier