aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Alert.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2015-07-06 17:35:35 +0100
committerMatthew Somerville <matthew@mysociety.org>2015-07-07 14:13:18 +0100
commita978c0a1ad216f7004ef88b8a58b9731242155dc (patch)
tree58ec3daece503b314bb1dfe54ab2d0c0e80cb24e /perllib/FixMyStreet/App/Controller/Alert.pm
parentbeb7e1f345ace940c542d93768ec44bfd6f5dc21 (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/Alert.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Alert.pm36
1 files changed, 18 insertions, 18 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Alert.pm b/perllib/FixMyStreet/App/Controller/Alert.pm
index 1aa70b497..6972bbc04 100644
--- a/perllib/FixMyStreet/App/Controller/Alert.pm
+++ b/perllib/FixMyStreet/App/Controller/Alert.pm
@@ -53,14 +53,14 @@ Target for subscribe form
sub subscribe : Path('subscribe') : Args(0) {
my ( $self, $c ) = @_;
- $c->detach('rss') if $c->req->param('rss');
+ $c->detach('rss') if $c->get_param('rss');
# if it exists then it's been submitted so we should
# go to subscribe email and let it work out the next step
$c->detach('subscribe_email')
- if exists $c->req->params->{'rznvy'} || $c->req->params->{'alert'};
+ if $c->get_param('rznvy') || $c->get_param('alert');
- $c->go('updates') if $c->req->params->{'id'};
+ $c->go('updates') if $c->get_param('id');
# shouldn't get to here but if we have then do something sensible
$c->go('index');
@@ -74,7 +74,7 @@ Redirects to relevant RSS feed
sub rss : Private {
my ( $self, $c ) = @_;
- my $feed = $c->req->params->{feed};
+ my $feed = $c->get_param('feed');
unless ($feed) {
$c->stash->{errors} = [ _('Please select the feed you want') ];
@@ -114,9 +114,9 @@ sub subscribe_email : Private {
$c->stash->{errors} = [];
$c->forward('process_user');
- my $type = $c->req->param('type');
+ my $type = $c->get_param('type');
push @{ $c->stash->{errors} }, _('Please select the type of alert you want')
- if $type && $type eq 'local' && !$c->req->param('feed');
+ if $type && $type eq 'local' && !$c->get_param('feed');
if (@{ $c->stash->{errors} }) {
$c->go('updates') if $type && $type eq 'updates';
$c->go('list') if $type && $type eq 'local';
@@ -145,8 +145,8 @@ sub subscribe_email : Private {
sub updates : Path('updates') : Args(0) {
my ( $self, $c ) = @_;
- $c->stash->{email} = $c->req->param('rznvy');
- $c->stash->{problem_id} = $c->req->param('id');
+ $c->stash->{email} = $c->get_param('rznvy');
+ $c->stash->{problem_id} = $c->get_param('id');
}
=head2 confirm
@@ -209,7 +209,7 @@ Set up the options in the stash required to create a problem update alert
sub set_update_alert_options : Private {
my ( $self, $c ) = @_;
- my $report_id = $c->req->param('id');
+ my $report_id = $c->get_param('id');
my $options = {
user => $c->stash->{alert_user},
@@ -229,7 +229,7 @@ Set up the options in the stash required to create a local problems alert
sub set_local_alert_options : Private {
my ( $self, $c ) = @_;
- my $feed = $c->req->param('feed');
+ my $feed = $c->get_param('feed');
my ( $type, @params, $alert );
if ( $feed =~ /^area:(?:\d+:)?(\d+)/ ) {
@@ -305,12 +305,12 @@ This will canonicalise and prettify the postcode and stick a pretty_pc and prett
sub prettify_pc : Private {
my ( $self, $c ) = @_;
- my $pretty_pc = $c->req->params->{'pc'};
+ my $pretty_pc = $c->get_param('pc');
- if ( mySociety::PostcodeUtil::is_valid_postcode( $c->req->params->{'pc'} ) )
+ if ( mySociety::PostcodeUtil::is_valid_postcode( $c->get_param('pc') ) )
{
$pretty_pc = mySociety::PostcodeUtil::canonicalise_postcode(
- $c->req->params->{'pc'} );
+ $c->get_param('pc') );
my $pretty_pc_text = $pretty_pc;
$pretty_pc_text =~ s/ //g;
$c->stash->{pretty_pc_text} = $pretty_pc_text;
@@ -336,7 +336,7 @@ sub process_user : Private {
}
# Extract all the params to a hash to make them easier to work with
- my %params = map { $_ => scalar $c->req->param($_) }
+ my %params = map { $_ => $c->get_param($_) }
( 'rznvy' ); # , 'password_register' );
# cleanup the email address
@@ -350,7 +350,7 @@ sub process_user : Private {
$c->stash->{alert_user} = $alert_user;
# # The user is trying to sign in. We only care about email from the params.
-# if ( $c->req->param('submit_sign_in') ) {
+# if ( $c->get_param('submit_sign_in') ) {
# unless ( $c->forward( '/auth/sign_in', [ $email ] ) ) {
# $c->stash->{field_errors}->{password} = _('There was a problem with your email/password combination. Please try again.');
# return 1;
@@ -498,14 +498,14 @@ Setup the variables we need for the rest of the request
sub setup_request : Private {
my ( $self, $c ) = @_;
- $c->stash->{rznvy} = $c->req->param('rznvy');
- $c->stash->{selected_feed} = $c->req->param('feed');
+ $c->stash->{rznvy} = $c->get_param('rznvy');
+ $c->stash->{selected_feed} = $c->get_param('feed');
if ( $c->user ) {
$c->stash->{rznvy} ||= $c->user->email;
}
- $c->stash->{template} = 'alert/list-ajax.html' if $c->req->param('ajax');
+ $c->stash->{template} = 'alert/list-ajax.html' if $c->get_param('ajax');
return 1;
}