[dw-free] Search for several interests at once
[commit: http://hg.dwscoalition.org/dw-free/rev/8753001e720b]
http://bugs.dwscoalition.org/show_bug.cgi?id=2821
Allow adding multiple (comma-separated) interests when no search results are
turned up.
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2821
Allow adding multiple (comma-separated) interests when no search results are
turned up.
Patch by
Files modified:
- cgi-bin/DW/Controller/Search/Interests.pm
--------------------------------------------------------------------------------
diff -r c49a6c4a5fa7 -r 8753001e720b cgi-bin/DW/Controller/Search/Interests.pm
--- a/cgi-bin/DW/Controller/Search/Interests.pm Mon Oct 03 02:27:20 2011 +0800
+++ b/cgi-bin/DW/Controller/Search/Interests.pm Mon Oct 03 02:37:27 2011 +0800
@@ -90,27 +90,30 @@
{ maxinterests => $maxinterests } )
if scalar( @$rints ) >= $maxinterests;
- my $intid;
+ my @intids;
if ( $mode eq "add" ) {
# adding an existing interest, so we have an intid to work with
- $intid = $args->{intid} + 0;
+ @intids = ( $args->{intid} + 0 );
} else {
# adding a new interest
- my @validate = LJ::validate_interest_list( $args->{keyword} );
- $intid = LJ::get_sitekeyword_id( $validate[0] ) if @validate;
+ my @keywords = LJ::interest_string_to_list( $args->{keyword} );
+ my @validate = LJ::validate_interest_list( @keywords );
+ @intids = map { LJ::get_sitekeyword_id( $_ ) } @validate;
}
- return error_ml( 'error.invalidform' ) unless $intid;
+ @intids = grep { $_ } @intids; # ignore any zeroes
+ return error_ml( 'error.invalidform' ) unless @intids;
# force them to either come from the interests page, or have posted the request.
# if both fail, ask them to confirm with a post form.
+ # (only uses first interest; edge case not worth the trouble to fix)
unless ( $did_post || LJ::check_referer( '/interests' ) ) {
- my $int = LJ::get_interest( $intid );
+ my $int = LJ::get_interest( $intids[0] );
LJ::text_out( \$int );
- $rv->{need_post} = { int => $int, intid => $intid };
+ $rv->{need_post} = { int => $int, intid => $intids[0] };
} else { # let the user add the interest
- $remote->interest_update( add => [$intid] );
+ $remote->interest_update( add => \@intids );
}
return DW::Template->render_template( 'interests/add.tt', $rv );
}
--------------------------------------------------------------------------------
