%# You should never wear your best trousers when you go out to fight for
%# freedom and liberty.
%#                 -- Henrik Ibsen
<%INIT>
my $List = RT::Queues->new($session{'CurrentUser'});
$List->OrderBy(FIELD => 'Name');
$List->UnLimit;
if ($FindDisabledQueues) {
    # "Disabled" >= 2 means totally hidden.
    $List->{'find_disabled_rows'} = 1;
    $List->Limit(
	FIELD => 'Disabled',
	VALUE => '2',
	OPERATOR => '<',
    );
}

if ($QueueString) {
    if ($QueueField eq 'Watchers') {
	$List->LimitWatcher(
	    FIELD => 'Name',
	    OPERATOR => $QueueOp,
	    VALUE => $QueueString,
	    CASESENSITIVE => 0,
	);
    }
    else {
	$List->Limit(
	    FIELD => $QueueField,
	    OPERATOR => $QueueOp,
	    VALUE => $QueueString,
	    CASESENSITIVE => 0,
	);
    }
}

return $List;

</%INIT>
<%ARGS>
$QueueString => undef
$QueueOp => '='
$QueueField => 'Name'
$FindDisabledQueues => 0
</%ARGS>
