Skip to content

Commit

Permalink
change fullsearch from get to post
Browse files Browse the repository at this point in the history
  • Loading branch information
kareila committed Feb 22, 2017
1 parent d7293bf commit 09e99f7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
23 changes: 12 additions & 11 deletions cgi-bin/DW/Controller/Support/History.pm
Expand Up @@ -29,7 +29,8 @@ DW::Routing->register_string( '/support/history', \&history_handler, app => 1 );

sub history_handler {
my $r = DW::Request->get;
my $get = $r->get_args;
my $args = $r->get_args;
$args = $r->post_args if $r->did_post;

my ( $ok, $rv ) = controller( anonymous => 0, form_auth => 1 );
return $rv unless $ok;
Expand All @@ -41,19 +42,19 @@ sub history_handler {

$vars->{fullsearch} = $fullsearch;

if ( $get->{user} || $get->{email} || $get->{userid} ) {
if ( $args->{user} || $args->{email} || $args->{userid} ) {
my $dbr = LJ::get_db_reader();
return error_ml( '/support/history.tt.error.nodatabase' ) unless $dbr;

$vars->{get_user} = ( $get->{user} ) ? 1 : 0;
$vars->{get_userid} = ( $get->{userid} ) ? 1 : 0;
$vars->{get_email} = ( $get->{email} ) ? 1 : 0;
$vars->{get_user} = ( $args->{user} ) ? 1 : 0;
$vars->{get_userid} = ( $args->{userid} ) ? 1 : 0;
$vars->{get_email} = ( $args->{email} ) ? 1 : 0;
$vars->{user} = $remote->user;

my $reqlist;
if ( $get->{user} || $get->{userid} ) {
if ( $args->{user} || $args->{userid} ) {
# get requests by a user, regardless of email (only gets user requests)
my $userid = $get->{userid} ? $get->{userid}+0 : LJ::get_userid( LJ::trim( $get->{user} ) );
my $userid = $args->{userid} ? $args->{userid}+0 : LJ::get_userid( LJ::trim( $args->{user} ) );
return error_ml( '/support/history.tt.error.invaliduser' ) unless $userid
&& ( $fullsearch || $remote->id == $userid );
$vars->{username} = LJ::ljuser( LJ::get_username( $userid ) );
Expand All @@ -62,10 +63,10 @@ sub history_handler {
'timecreate, timetouched, timelasthelp, reqemail ' .
'FROM support WHERE reqtype = \'user\' AND requserid = ?',
undef, $userid );
} elsif ( $get->{email} ) {
} elsif ( $args->{email} ) {
# try by email, note that this gets requests opened by users and anonymous
# requests, so we can view them all
my $email = LJ::trim( $get->{email} );
my $email = LJ::trim( $args->{email} );
$vars->{email} = LJ::ehtml( $email );
my %user_emails;

Expand Down Expand Up @@ -154,9 +155,9 @@ sub history_handler {
} else {
$vars->{noresults} = 1;
}
} elsif ( $get->{fulltext} ) {
} elsif ( $args->{fulltext} ) {
$rv = DW::Controller::Support::Search::do_search(
remoteid => $remote->id, query => $get->{fulltext} );
remoteid => $remote->id, query => $args->{fulltext} );
return DW::Template->render_template( 'support/search.tt', $rv );

} elsif ( ! $fullsearch ) {
Expand Down
3 changes: 2 additions & 1 deletion views/support/history.tt
Expand Up @@ -48,7 +48,7 @@ the same terms as Perl itself. For a copy of the license, please reference
</table>
[% END %]
[% IF fullsearch %]
<form method='get' action='history'>
<form method='post' action='history'>
<fieldset>
<legend>[% '.search.text' | ml %]</legend>
<div class="row">
Expand Down Expand Up @@ -108,6 +108,7 @@ the same terms as Perl itself. For a copy of the license, please reference
<div data-alert class="alert-box radius">[% '.search.onefield' | ml %]</div>
</div>
</fieldset>
[% dw.form_auth %]
</form>
[% ELSE %]
[% IF get_user %]
Expand Down

0 comments on commit 09e99f7

Please sign in to comment.