Add search by multiple interests to directory.
Patch by kareila.
diffs (35 lines):
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 }
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog