[Rt-devel] Q: Fixing LinkedTo link searches

Todd Chapman todd at chaka.net
Wed Dec 21 17:10:59 EST 2005


I am looking at fixing search builder so that when
you do a search on criteria LinkedTo it works.

Currently LinkedTo is handled by sub _LinkFieldLimit
which looks to be horribly broken. For example:

sub _LinkFieldLimit {
    my $restriction;
    my $self;
    my $LinkAlias;
    my %args;
    if ( $restriction->{'TYPE'} ) {
        $self->SUPER::Limit(
            ALIAS           => $LinkAlias,
            ENTRYAGGREGATOR => 'AND',
            FIELD           => 'Type',
            OPERATOR        => '=',
            VALUE           => $restriction->{'TYPE'}
        );
    }


Nothing is ever done with %args, and how can we declare
$restriction and then access it before assigning it?

So the solution I am pursuing is using sub _LinkLimit
like the other "specific" link types but adding
some extra logic for when the link type is LinkedTo.

Here's what I can't figure out. It's really a search
builder problem, but I need the join to look like 
this:

SELECT DISTINCT main.* FROM (AT_Assets main  LEFT JOIN Links Links_1  ON ( Links_1.Target = main.URI OR Links_1.Base = main.URI))   WHERE ( ( (Links_1.LocalBase IS NULL)OR(Links_1.LocalTarget IS NULL) ) )

How do I get the OR condition in the join? I don't think
using the EXPRESSION parameter to Join is going to help
me.

Thanks.

-Todd


More information about the Rt-devel mailing list