[dw-free] Search for several interests at once
[commit: http://hg.dwscoalition.org/dw-free/rev/0429c47708e3]
http://bugs.dwscoalition.org/show_bug.cgi?id=2821
Add search by multiple interests to directory.
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2821
Add search by multiple interests to directory.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/LJ/Directory/Constraint.pm
- cgi-bin/LJ/Directory/Constraint/Interest.pm
-------------------------------------------------------------------------------- diff -r dce155b3e09b -r 0429c47708e3 cgi-bin/LJ/Directory/Constraint.pm --- a/cgi-bin/LJ/Directory/Constraint.pm Tue Dec 28 21:19:25 2010 +0800 +++ b/cgi-bin/LJ/Directory/Constraint.pm Tue Dec 28 21:24:15 2010 +0800 @@ -38,7 +38,9 @@ sub constraints_from_formargs { foreach my $type (qw(Age Location UpdateTime Interest Trusts TrustedBy Watches WatchedBy MemberOf JournalType)) { my $class = "LJ::Directory::Constraint::$type"; my $con = eval { $class->new_from_formargs($postargs) }; - if ($con) { + if ( ref $con eq 'ARRAY' ) { + push @ret, @$con; + } elsif ( $con ) { push @ret, $con; } elsif ($@) { warn "Error loading constraint $type: $@"; diff -r dce155b3e09b -r 0429c47708e3 cgi-bin/LJ/Directory/Constraint/Interest.pm --- a/cgi-bin/LJ/Directory/Constraint/Interest.pm Tue Dec 28 21:19:25 2010 +0800 +++ b/cgi-bin/LJ/Directory/Constraint/Interest.pm Tue Dec 28 21:24:15 2010 +0800 @@ -29,8 +29,15 @@ sub new_from_formargs { sub new_from_formargs { my ($pkg, $args) = @_; return undef unless ($args->{int_like} xor $args->{intid}); - return $pkg->new(intid => $args->{intid}, - interest => $args->{int_like}); + + # handle possibility of multiple specified interests + my @ints = LJ::interest_string_to_list( $args->{int_like} ); + + if ( $args->{int_like} ) { + return [ map { $pkg->new( interest => $_ ) } @ints ]; + } else { + return $pkg->new( intid => $args->{intid} ); + } } sub cache_for { 5 * 60 } --------------------------------------------------------------------------------