diff options
author | Matthew Somerville <matthew@mysociety.org> | 2015-07-06 17:35:35 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2015-07-07 14:13:18 +0100 |
commit | a978c0a1ad216f7004ef88b8a58b9731242155dc (patch) | |
tree | 58ec3daece503b314bb1dfe54ab2d0c0e80cb24e /perllib/FixMyStreet/App/Controller/Contact.pm | |
parent | beb7e1f345ace940c542d93768ec44bfd6f5dc21 (diff) |
Factor out all uses of param()/params.
Use a central get_param and get_param_list functions dependent on
whether we're after a scalar or a list (almost always a scalar). This
prevents any possibility of confusion where param() could return a list,
or params->{} an arrayref.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Contact.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Contact.pm | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Contact.pm b/perllib/FixMyStreet/App/Controller/Contact.pm index 222c0c242..912224649 100644 --- a/perllib/FixMyStreet/App/Controller/Contact.pm +++ b/perllib/FixMyStreet/App/Controller/Contact.pm @@ -41,8 +41,8 @@ Handle contact us form submission sub submit : Path('submit') : Args(0) { my ( $self, $c ) = @_; - if (my $testing = $c->req->params->{_test_}) { - $c->stash->{success} = $c->req->params->{success}; + if (my $testing = $c->get_param('_test_')) { + $c->stash->{success} = $c->get_param('success'); return; } @@ -66,9 +66,9 @@ generic contact request and set up things accordingly sub determine_contact_type : Private { my ( $self, $c ) = @_; - my $id = $c->req->param('id'); - my $update_id = $c->req->param('update_id'); - my $token = $c->req->param('m'); + my $id = $c->get_param('id'); + my $update_id = $c->get_param('update_id'); + my $token = $c->get_param('m'); $id = undef unless $id && $id =~ /^[1-9]\d*$/; $update_id = undef unless $update_id && $update_id =~ /^[1-9]\d*$/; @@ -116,12 +116,12 @@ sub validate : Private { foreach my $field ( keys %required ) { $field_errors{$field} = $required{$field} - unless $c->req->param($field) =~ /\S/; + unless $c->get_param($field) =~ /\S/; } unless ( $field_errors{em} ) { $field_errors{em} = _('Please enter a valid email address') - if !mySociety::EmailUtil::is_valid_email( $c->req->param('em') ); + if !mySociety::EmailUtil::is_valid_email( $c->get_param('em') ); } %field_errors = ( @@ -130,11 +130,11 @@ sub validate : Private { ); push @errors, _('Illegal ID') - if $c->req->param('id') && !$c->stash->{problem} - or $c->req->param('update_id') && !$c->stash->{update}; + if $c->get_param('id') && !$c->stash->{problem} + or $c->get_param('update_id') && !$c->stash->{update}; push @errors, _('There was a problem showing this page. Please try again later.') - if $c->req->params->{message} && $c->req->params->{message} =~ /\[url=|<a/; + if $c->get_param('message') && $c->get_param('message') =~ /\[url=|<a/; unshift @errors, _('There were problems with your report. Please see below.') @@ -211,11 +211,11 @@ sub setup_request : Private { $c->stash->{contact_email} =~ s/\@/@/; for my $param (qw/em subject message/) { - $c->stash->{$param} = $c->req->param($param); + $c->stash->{$param} = $c->get_param($param); } # name is already used in the stash for the app class name - $c->stash->{form_name} = $c->req->param('name'); + $c->stash->{form_name} = $c->get_param('name'); return 1; } |