Skip to content

Commit

Permalink
Bug 5041 Include comments search in S2 search module
Browse files Browse the repository at this point in the history
Simplified and corrected  fix.
Print_search_form method checks if comments are indexed here,
if so adds a "with comments" checkbox.
Currently comments are indexed if the journal being viewed is paid.
  • Loading branch information
LivredOr committed Jul 23, 2013
1 parent a5b8be7 commit 30d6f37
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cgi-bin/LJ/S2.pm
Expand Up @@ -2957,6 +2957,10 @@ sub print_search_form {
$search_form .= '<form method="post" action="'. $LJ::SITEROOT. '/search?user=' . $ju->user . '">';
$search_form .= LJ::form_auth();
$search_form .= '<input class="search-box" type="text" name="query" maxlength="255">';
if ( $ju->allow_comments_indexed() ) {
$search_form .= '<br/><input class="comment_search_checkbox" name="with_comments" id="with_comments" type="checkbox">';
$search_form .= '<label for="with_comments">Include comments in search results</label>';
}
$search_form .= '<input class="search-button" type="submit" value="' . $_[1] . '" />';
$search_form .= '</form></div>';

Expand Down
11 changes: 11 additions & 0 deletions cgi-bin/LJ/User.pm
Expand Up @@ -1918,6 +1918,17 @@ sub allow_search_by {
return 0;
}

# whether comments are indexed in this journal
sub allow_comments_indexed {
my ( $u ) = @_;
return 0 unless LJ::isu( $u );

# Comments are indexed in paid accounts only
return 1 if $u->is_paid;

# Otherwise comments aren't indexed
return 0;
}

sub caps {
my $u = shift;
Expand Down

0 comments on commit 30d6f37

Please sign in to comment.