aboutsummaryrefslogtreecommitdiffstats
path: root/perllib
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
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')
-rw-r--r--perllib/FixMyStreet/App.pm49
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm192
-rw-r--r--perllib/FixMyStreet/App/Controller/Alert.pm36
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm33
-rw-r--r--perllib/FixMyStreet/App/Controller/Auth.pm33
-rw-r--r--perllib/FixMyStreet/App/Controller/Contact.pm24
-rw-r--r--perllib/FixMyStreet/App/Controller/Dashboard.pm14
-rw-r--r--perllib/FixMyStreet/App/Controller/JSON.pm6
-rw-r--r--perllib/FixMyStreet/App/Controller/Location.pm8
-rw-r--r--perllib/FixMyStreet/App/Controller/Moderate.pm26
-rw-r--r--perllib/FixMyStreet/App/Controller/My.pm6
-rw-r--r--perllib/FixMyStreet/App/Controller/Open311.pm24
-rw-r--r--perllib/FixMyStreet/App/Controller/Photo.pm2
-rwxr-xr-xperllib/FixMyStreet/App/Controller/Questionnaire.pm16
-rw-r--r--perllib/FixMyStreet/App/Controller/Report.pm6
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm53
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm44
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm10
-rw-r--r--perllib/FixMyStreet/App/Controller/Root.pm2
-rwxr-xr-xperllib/FixMyStreet/App/Controller/Rss.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Tokens.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/EmptyHomes.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/FixMyStreet.pm6
-rw-r--r--perllib/FixMyStreet/Cobrand/SeeSomething.pm20
-rw-r--r--perllib/FixMyStreet/Cobrand/UK.pm6
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm10
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm68
-rw-r--r--perllib/FixMyStreet/Map.pm4
-rw-r--r--perllib/FixMyStreet/Map/Google.pm10
-rw-r--r--perllib/FixMyStreet/Map/OSM.pm12
-rw-r--r--perllib/FixMyStreet/Map/Zurich.pm14
31 files changed, 393 insertions, 347 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm
index 2fff79cec..866f1f462 100644
--- a/perllib/FixMyStreet/App.pm
+++ b/perllib/FixMyStreet/App.pm
@@ -195,7 +195,7 @@ sub setup_request {
Memcached::set_namespace( FixMyStreet->config('FMS_DB_NAME') . ":" );
- FixMyStreet::Map::set_map_class( $cobrand->map_type || $c->req->param('map_override') );
+ FixMyStreet::Map::set_map_class( $cobrand->map_type || $c->get_param('map_override') );
unless ( FixMyStreet->config('MAPIT_URL') ) {
my $port = $c->req->uri->port;
@@ -529,6 +529,53 @@ sub is_abuser {
return $c->model('DB::Abuse')->search( { email => [ $email, $domain ] } )->first;
}
+=head2 get_param
+
+ $param = $c->get_param('name');
+
+Return the parameter passed in the request, or undef if not present. Like
+req->param() in a scalar context, this will return the first parameter if
+multiple were provided; unlike req->param it will always return a scalar,
+never a list, in order to avoid possible security issues.
+
+=cut
+
+sub get_param {
+ my ($c, $param) = @_;
+ my $value = $c->req->params->{$param};
+ return $value->[0] if ref $value;
+ return $value;
+}
+
+=head2 get_param_list
+
+ @params = $c->get_param_list('name');
+
+Return the parameters passed in the request, as a list. This will always return
+a list, with an empty list if no parameter is present.
+
+=cut
+
+sub get_param_list {
+ my ($c, $param) = @_;
+ my $value = $c->req->params->{$param};
+ return @$value if ref $value;
+ return ($value);
+}
+
+=head2 set_param
+
+ $c->set_param('name', 'My Name');
+
+Sets the query parameter to the passed variable.
+
+=cut
+
+sub set_param {
+ my ($c, $param, $value) = @_;
+ $c->req->params->{$param} = $value;
+}
+
=head1 SEE ALSO
L<FixMyStreet::App::Controller::Root>, L<Catalyst>
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index 790e22e8c..76ee3447f 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -246,14 +246,14 @@ sub bodies : Path('bodies') : Args(0) {
$c->stash->{edit_activity} = $edit_activity;
- my $posted = $c->req->param('posted') || '';
+ my $posted = $c->get_param('posted') || '';
if ( $posted eq 'body' ) {
$c->forward('check_for_super_user');
$c->forward('check_token');
my $params = $c->forward('body_params');
my $body = $c->model('DB::Body')->create( $params );
- my $area_ids = $c->req->params->{area_ids};
+ my $area_ids = $c->get_param('area_ids');
if ($area_ids) {
$area_ids = [ $area_ids ] unless ref $area_ids;
foreach (@$area_ids) {
@@ -314,7 +314,7 @@ sub body : Path('body') : Args(1) {
$c->forward( 'fetch_all_bodies' );
$c->forward( 'body_form_dropdowns' );
- if ( $c->req->param('posted') ) {
+ if ( $c->get_param('posted') ) {
$c->log->debug( 'posted' );
$c->forward('update_contacts');
}
@@ -334,7 +334,7 @@ sub check_for_super_user : Private {
sub update_contacts : Private {
my ( $self, $c ) = @_;
- my $posted = $c->req->param('posted');
+ my $posted = $c->get_param('posted');
my $editor = $c->forward('get_user');
if ( $posted eq 'new' ) {
@@ -342,11 +342,11 @@ sub update_contacts : Private {
my %errors;
- my $category = $self->trim( $c->req->param( 'category' ) );
+ my $category = $self->trim( $c->get_param('category') );
$errors{category} = _("Please choose a category") unless $category;
- my $email = $self->trim( $c->req->param( 'email' ) );
+ my $email = $self->trim( $c->get_param('email') );
$errors{email} = _('Please enter a valid email') unless is_valid_email($email);
- $errors{note} = _('Please enter a message') unless $c->req->param('note');
+ $errors{note} = _('Please enter a message') unless $c->get_param('note');
$category = 'Empty property' if $c->cobrand->moniker eq 'emptyhomes';
@@ -358,16 +358,16 @@ sub update_contacts : Private {
);
$contact->email( $email );
- $contact->confirmed( $c->req->param('confirmed') ? 1 : 0 );
- $contact->deleted( $c->req->param('deleted') ? 1 : 0 );
- $contact->non_public( $c->req->param('non_public') ? 1 : 0 );
- $contact->note( $c->req->param('note') );
+ $contact->confirmed( $c->get_param('confirmed') ? 1 : 0 );
+ $contact->deleted( $c->get_param('deleted') ? 1 : 0 );
+ $contact->non_public( $c->get_param('non_public') ? 1 : 0 );
+ $contact->note( $c->get_param('note') );
$contact->whenedited( \'ms_current_timestamp()' );
$contact->editor( $editor );
- $contact->endpoint( $c->req->param('endpoint') );
- $contact->jurisdiction( $c->req->param('jurisdiction') );
- $contact->api_key( $c->req->param('api_key') );
- $contact->send_method( $c->req->param('send_method') );
+ $contact->endpoint( $c->get_param('endpoint') );
+ $contact->jurisdiction( $c->get_param('jurisdiction') );
+ $contact->api_key( $c->get_param('api_key') );
+ $contact->send_method( $c->get_param('send_method') );
if ( %errors ) {
$c->stash->{updated} = _('Please correct the errors below');
@@ -386,7 +386,7 @@ sub update_contacts : Private {
} elsif ( $posted eq 'update' ) {
$c->forward('check_token');
- my @categories = $c->req->param('confirmed');
+ my @categories = $c->get_param_list('confirmed');
my $contacts = $c->model('DB::Contact')->search(
{
@@ -413,7 +413,7 @@ sub update_contacts : Private {
$c->stash->{body}->update( $params );
my @current = $c->stash->{body}->body_areas->all;
my %current = map { $_->area_id => 1 } @current;
- my $area_ids = $c->req->params->{area_ids};
+ my $area_ids = $c->get_param('area_ids');
if ($area_ids) {
$area_ids = [ $area_ids ] unless ref $area_ids;
foreach (@$area_ids) {
@@ -442,7 +442,7 @@ sub body_params : Private {
parent => undef,
deleted => 0,
);
- my %params = map { $_ => $c->req->param($_) || $defaults{$_} } @fields;
+ my %params = map { $_ => $c->get_param($_) || $defaults{$_} } @fields;
return \%params;
}
@@ -453,7 +453,7 @@ sub display_contacts : Private {
$c->stash->{contacts} = $contacts;
$c->stash->{live_contacts} = $contacts->search({ deleted => 0 });
- if ( $c->req->param('text') && $c->req->param('text') == 1 ) {
+ if ( $c->get_param('text') && $c->get_param('text') == 1 ) {
$c->stash->{template} = 'admin/council_contacts.txt';
$c->res->content_type('text/plain; charset=utf-8');
return 1;
@@ -532,16 +532,16 @@ sub reports : Path('reports') {
}
}
- my $order = $c->req->params->{o} || 'created';
- my $dir = defined $c->req->params->{d} ? $c->req->params->{d} : 1;
+ my $order = $c->get_param('o') || 'created';
+ my $dir = defined $c->get_param('d') ? $c->get_param('d') : 1;
$c->stash->{order} = $order;
$c->stash->{dir} = $dir;
$order .= ' desc' if $dir;
- my $p_page = $c->req->params->{p} || 1;
- my $u_page = $c->req->params->{u} || 1;
+ my $p_page = $c->get_param('p') || 1;
+ my $u_page = $c->get_param('u') || 1;
- if (my $search = $c->req->param('search')) {
+ if (my $search = $c->get_param('search')) {
$c->stash->{searched} = $search;
my $site_restriction = $c->cobrand->site_restriction;
@@ -684,7 +684,7 @@ sub report_edit : Path('report_edit') : Args(1) {
);
}
- if ( $c->req->param('rotate_photo') ) {
+ if ( $c->get_param('rotate_photo') ) {
$c->forward('rotate_photo');
return 1;
}
@@ -701,7 +701,7 @@ sub report_edit : Path('report_edit') : Args(1) {
->search( { problem_id => $problem->id }, { order_by => 'created' } )
->all ];
- if ( $c->req->param('resend') ) {
+ if ( $c->get_param('resend') ) {
$c->forward('check_token');
$problem->whensent(undef);
@@ -711,24 +711,24 @@ sub report_edit : Path('report_edit') : Args(1) {
$c->forward( 'log_edit', [ $id, 'problem', 'resend' ] );
}
- elsif ( $c->req->param('flaguser') ) {
+ elsif ( $c->get_param('flaguser') ) {
$c->forward('flag_user');
$c->stash->{problem}->discard_changes;
}
- elsif ( $c->req->param('removeuserflag') ) {
+ elsif ( $c->get_param('removeuserflag') ) {
$c->forward('remove_user_flag');
$c->stash->{problem}->discard_changes;
}
- elsif ( $c->req->param('banuser') ) {
+ elsif ( $c->get_param('banuser') ) {
$c->forward('ban_user');
}
- elsif ( $c->req->param('submit') ) {
+ elsif ( $c->get_param('submit') ) {
$c->forward('check_token');
my $done = 0;
my $edited = 0;
- my $new_state = $c->req->param('state');
+ my $new_state = $c->get_param('state');
my $old_state = $problem->state;
if ( $new_state eq 'confirmed'
&& $problem->state eq 'unconfirmed'
@@ -741,35 +741,35 @@ sub report_edit : Path('report_edit') : Args(1) {
$done = 1;
}
- my $flagged = $c->req->param('flagged') ? 1 : 0;
- my $non_public = $c->req->param('non_public') ? 1 : 0;
+ my $flagged = $c->get_param('flagged') ? 1 : 0;
+ my $non_public = $c->get_param('non_public') ? 1 : 0;
# do this here so before we update the values in problem
- if ( $c->req->param('anonymous') ne $problem->anonymous
- || $c->req->param('name') ne $problem->name
- || $c->req->param('email') ne $problem->user->email
- || $c->req->param('title') ne $problem->title
- || $c->req->param('detail') ne $problem->detail
- || ($c->req->param('body') && $c->req->param('body') ne $problem->bodies_str)
+ if ( $c->get_param('anonymous') ne $problem->anonymous
+ || $c->get_param('name') ne $problem->name
+ || $c->get_param('email') ne $problem->user->email
+ || $c->get_param('title') ne $problem->title
+ || $c->get_param('detail') ne $problem->detail
+ || ($c->get_param('body') && $c->get_param('body') ne $problem->bodies_str)
|| $flagged != $problem->flagged
|| $non_public != $problem->non_public )
{
$edited = 1;
}
- $problem->anonymous( $c->req->param('anonymous') );
- $problem->title( $c->req->param('title') );
- $problem->detail( $c->req->param('detail') );
+ $problem->anonymous( $c->get_param('anonymous') );
+ $problem->title( $c->get_param('title') );
+ $problem->detail( $c->get_param('detail') );
$problem->state( $new_state );
- $problem->name( $c->req->param('name') );
- $problem->bodies_str( $c->req->param('body') ) if $c->req->param('body');
+ $problem->name( $c->get_param('name') );
+ $problem->bodies_str( $c->get_param('body') ) if $c->get_param('body');
$problem->flagged( $flagged );
$problem->non_public( $non_public );
- if ( $c->req->param('email') ne $problem->user->email ) {
+ if ( $c->get_param('email') ne $problem->user->email ) {
my $user = $c->model('DB::User')->find_or_create(
- { email => $c->req->param('email') }
+ { email => $c->get_param('email') }
);
$user->insert unless $user->in_storage;
@@ -777,11 +777,11 @@ sub report_edit : Path('report_edit') : Args(1) {
}
# Deal with photos
- if ( $c->req->param('remove_photo') ) {
+ if ( $c->get_param('remove_photo') ) {
$problem->photo(undef);
}
- if ( $c->req->param('remove_photo') || $new_state eq 'hidden' ) {
+ if ( $c->get_param('remove_photo') || $new_state eq 'hidden' ) {
unlink glob FixMyStreet->path_to( 'web', 'photo', $problem->id . '.*' );
}
@@ -818,7 +818,7 @@ sub report_edit : Path('report_edit') : Args(1) {
sub users: Path('users') : Args(0) {
my ( $self, $c ) = @_;
- if (my $search = $c->req->param('search')) {
+ if (my $search = $c->get_param('search')) {
$c->stash->{searched} = $search;
my $isearch = '%' . $search . '%';
@@ -890,52 +890,52 @@ sub update_edit : Path('update_edit') : Args(1) {
$c->forward('check_email_for_abuse', [ $update->user->email ] );
- if ( $c->req->param('banuser') ) {
+ if ( $c->get_param('banuser') ) {
$c->forward('ban_user');
}
- elsif ( $c->req->param('flaguser') ) {
+ elsif ( $c->get_param('flaguser') ) {
$c->forward('flag_user');
$c->stash->{update}->discard_changes;
}
- elsif ( $c->req->param('removeuserflag') ) {
+ elsif ( $c->get_param('removeuserflag') ) {
$c->forward('remove_user_flag');
$c->stash->{update}->discard_changes;
}
- elsif ( $c->req->param('submit') ) {
+ elsif ( $c->get_param('submit') ) {
$c->forward('check_token');
my $old_state = $update->state;
- my $new_state = $c->req->param('state');
+ my $new_state = $c->get_param('state');
my $edited = 0;
# $update->name can be null which makes ne unhappy
my $name = $update->name || '';
- if ( $c->req->param('name') ne $name
- || $c->req->param('email') ne $update->user->email
- || $c->req->param('anonymous') ne $update->anonymous
- || $c->req->param('text') ne $update->text ){
+ if ( $c->get_param('name') ne $name
+ || $c->get_param('email') ne $update->user->email
+ || $c->get_param('anonymous') ne $update->anonymous
+ || $c->get_param('text') ne $update->text ) {
$edited = 1;
}
- if ( $c->req->param('remove_photo') ) {
+ if ( $c->get_param('remove_photo') ) {
$update->photo(undef);
}
- if ( $c->req->param('remove_photo') || $new_state eq 'hidden' ) {
+ if ( $c->get_param('remove_photo') || $new_state eq 'hidden' ) {
unlink glob FixMyStreet->path_to( 'web', 'photo', 'c', $update->id . '.*' );
}
- $update->name( $c->req->param('name') || '' );
- $update->text( $c->req->param('text') );
- $update->anonymous( $c->req->param('anonymous') );
+ $update->name( $c->get_param('name') || '' );
+ $update->text( $c->get_param('text') );
+ $update->anonymous( $c->get_param('anonymous') );
$update->state( $new_state );
- if ( $c->req->param('email') ne $update->user->email ) {
+ if ( $c->get_param('email') ne $update->user->email ) {
my $user =
$c->model('DB::User')
- ->find_or_create( { email => $c->req->param('email') } );
+ ->find_or_create( { email => $c->get_param('email') } );
$user->insert unless $user->in_storage;
$update->user($user);
@@ -986,22 +986,22 @@ sub user_add : Path('user_edit') : Args(0) {
$c->forward('get_token');
$c->forward('fetch_all_bodies');
- return 1 unless $c->req->param('submit');
+ return 1 unless $c->get_param('submit');
$c->forward('check_token');
- if ( $c->cobrand->moniker eq 'zurich' and $c->req->param('email') eq '' ) {
+ if ( $c->cobrand->moniker eq 'zurich' and $c->get_param('email') eq '' ) {
$c->stash->{field_errors}->{email} = _('Please enter a valid email');
return 1;
}
- return unless $c->req->param('name') && $c->req->param('email');
+ return unless $c->get_param('name') && $c->get_param('email');
my $user = $c->model('DB::User')->find_or_create( {
- name => $c->req->param('name'),
- email => $c->req->param('email'),
- from_body => $c->req->param('body') || undef,
- flagged => $c->req->param('flagged') || 0,
+ name => $c->get_param('name'),
+ email => $c->get_param('email'),
+ from_body => $c->get_param('body') || undef,
+ flagged => $c->get_param('flagged') || 0,
}, {
key => 'users_email_key'
} );
@@ -1025,23 +1025,23 @@ sub user_edit : Path('user_edit') : Args(1) {
$c->forward('fetch_all_bodies');
- if ( $c->req->param('submit') ) {
+ if ( $c->get_param('submit') ) {
$c->forward('check_token');
my $edited = 0;
- if ( $user->email ne $c->req->param('email') ||
- $user->name ne $c->req->param('name' ) ||
- ($user->from_body && $user->from_body->id ne $c->req->param('body')) ||
- (!$user->from_body && $c->req->param('body'))
+ if ( $user->email ne $c->get_param('email') ||
+ $user->name ne $c->get_param('name') ||
+ ($user->from_body && $user->from_body->id ne $c->get_param('body')) ||
+ (!$user->from_body && $c->get_param('body'))
) {
$edited = 1;
}
- $user->name( $c->req->param('name') );
- $user->email( $c->req->param('email') );
- $user->from_body( $c->req->param('body') || undef );
- $user->flagged( $c->req->param('flagged') || 0 );
+ $user->name( $c->get_param('name') );
+ $user->email( $c->get_param('email') );
+ $user->from_body( $c->get_param('body') || undef );
+ $user->flagged( $c->get_param('flagged') || 0 );
if ( $c->cobrand->moniker eq 'zurich' and $user->email eq '' ) {
$c->stash->{field_errors}->{email} = _('Please enter a valid email');
@@ -1097,16 +1097,16 @@ sub stats : Path('stats') : Args(0) {
return $c->cobrand->admin_stats();
}
- if ( $c->req->param('getcounts') ) {
+ if ( $c->get_param('getcounts') ) {
my ( $start_date, $end_date, @errors );
my $parser = DateTime::Format::Strptime->new( pattern => '%d/%m/%Y' );
- $start_date = $parser-> parse_datetime ( $c->req->param('start_date') );
+ $start_date = $parser-> parse_datetime ( $c->get_param('start_date') );
push @errors, _('Invalid start date') unless defined $start_date;
- $end_date = $parser-> parse_datetime ( $c->req->param('end_date') ) ;
+ $end_date = $parser-> parse_datetime ( $c->get_param('end_date') ) ;
push @errors, _('Invalid end date') unless defined $end_date;
@@ -1114,21 +1114,21 @@ sub stats : Path('stats') : Args(0) {
$c->stash->{start_date} = $start_date;
$c->stash->{end_date} = $end_date;
- $c->stash->{unconfirmed} = $c->req->param('unconfirmed') eq 'on' ? 1 : 0;
+ $c->stash->{unconfirmed} = $c->get_param('unconfirmed') eq 'on' ? 1 : 0;
return 1 if @errors;
- my $bymonth = $c->req->param('bymonth');
+ my $bymonth = $c->get_param('bymonth');
$c->stash->{bymonth} = $bymonth;
my ( %body, %dates );
- $body{bodies_str} = { like => $c->req->param('body') }
- if $c->req->param('body');
+ $body{bodies_str} = { like => $c->get_param('body') }
+ if $c->get_param('body');
- $c->stash->{selected_body} = $c->req->param('body');
+ $c->stash->{selected_body} = $c->get_param('body');
my $field = 'confirmed';
- $field = 'created' if $c->req->param('unconfirmed');
+ $field = 'created' if $c->get_param('unconfirmed');
my $one_day = DateTime::Duration->new( days => 1 );
@@ -1140,7 +1140,7 @@ sub stats : Path('stats') : Args(0) {
order_by => [ 'state' ],
);
- if ( $c->req->param('bymonth') ) {
+ if ( $c->get_param('bymonth') ) {
%select = (
select => [
{ extract => \"year from $field", -as => 'c_year' },
@@ -1249,7 +1249,7 @@ not then display 404 page
sub check_token : Private {
my ( $self, $c ) = @_;
- if ( !$c->req->param('token') || $c->req->param('token' ) ne $c->stash->{token} ) {
+ if ( !$c->get_param('token') || $c->get_param('token') ne $c->stash->{token} ) {
$c->detach( '/page_error_404_not_found' );
}
@@ -1287,7 +1287,7 @@ accordingly
sub ban_user : Private {
my ( $self, $c ) = @_;
- my $email = $c->req->param('email');
+ my $email = $c->get_param('email');
return unless $email;
@@ -1314,7 +1314,7 @@ Sets the flag on a user with the given email
sub flag_user : Private {
my ( $self, $c ) = @_;
- my $email = $c->req->param('email');
+ my $email = $c->get_param('email');
return unless $email;
@@ -1342,7 +1342,7 @@ Remove the flag on a user with the given email
sub remove_user_flag : Private {
my ( $self, $c ) = @_;
- my $email = $c->req->param('email');
+ my $email = $c->get_param('email');
return unless $email;
@@ -1387,7 +1387,7 @@ Rotate a photo 90 degrees left or right
sub rotate_photo : Private {
my ( $self, $c ) =@_;
- my $direction = $c->req->param('rotate_photo');
+ my $direction = $c->get_param('rotate_photo');
return unless $direction eq _('Rotate Left') or $direction eq _('Rotate Right');
my $photo = $c->stash->{problem}->photo;
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;
}
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index 5bfe1ada2..723684793 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -41,7 +41,7 @@ sub around_index : Path : Args(0) {
my $ret = $c->forward('/location/determine_location_from_coords')
|| $c->forward('/location/determine_location_from_pc');
unless ($ret) {
- return $c->res->redirect('/') unless $c->req->param('pc') || $partial_report;
+ return $c->res->redirect('/') unless $c->get_param('pc') || $partial_report;
return;
}
@@ -78,13 +78,12 @@ Handle coord systems that are no longer in use.
sub redirect_en_or_xy_to_latlon : Private {
my ( $self, $c ) = @_;
- my $req = $c->req;
# check for x,y or e,n requests
- my $x = $req->param('x');
- my $y = $req->param('y');
- my $e = $req->param('e');
- my $n = $req->param('n');
+ my $x = $c->get_param('x');
+ my $y = $c->get_param('y');
+ my $e = $c->get_param('e');
+ my $n = $c->get_param('n');
# lat and lon - fill in below if we need to
my ( $lat, $lon );
@@ -118,7 +117,7 @@ token to stash and return report. Otherwise return false.
sub load_partial : Private {
my ( $self, $c ) = @_;
- my $partial = scalar $c->req->param('partial')
+ my $partial = $c->get_param('partial')
|| return;
# is it in the database
@@ -161,7 +160,7 @@ sub display_location : Private {
my $longitude = $c->stash->{longitude};
# Deal with pin hiding/age
- my $all_pins = $c->req->param('all_pins') ? 1 : undef;
+ my $all_pins = $c->get_param('all_pins') ? 1 : undef;
$c->stash->{all_pins} = $all_pins;
my $interval = $all_pins ? undef : $c->cobrand->on_map_default_max_pin_age;
@@ -182,7 +181,7 @@ sub display_location : Private {
# create a list of all the pins
my @pins;
- unless ($c->req->param('no_pins') || $c->cobrand->moniker eq 'emptyhomes') {
+ unless ($c->get_param('no_pins') || $c->cobrand->moniker eq 'emptyhomes') {
@pins = map {
# Here we might have a DB::Problem or a DB::Nearby, we always want the problem.
my $p = (ref $_ eq 'FixMyStreet::App::Model::DB::Nearby') ? $_->problem : $_;
@@ -258,7 +257,7 @@ sub check_and_stash_category : Private {
$c->stash->{filter_categories} = \@categories;
- my $category = $c->req->param('filter_category');
+ my $category = $c->get_param('filter_category');
my %categories_mapped = map { $_ => 1 } @categories;
if ( defined $category && $categories_mapped{$category} ) {
$c->stash->{filter_category} = $category;
@@ -278,7 +277,7 @@ sub ajax : Path('/ajax') {
$c->res->content_type('application/json; charset=utf-8');
- unless ( $c->req->param('bbox') ) {
+ unless ( $c->get_param('bbox') ) {
$c->res->status(404);
$c->res->body('');
return;
@@ -288,7 +287,7 @@ sub ajax : Path('/ajax') {
$c->res->header( 'Cache_Control' => 'max-age=0' );
# how far back should we go?
- my $all_pins = $c->req->param('all_pins') ? 1 : undef;
+ my $all_pins = $c->get_param('all_pins') ? 1 : undef;
my $interval = $all_pins ? undef : $c->cobrand->on_map_default_max_pin_age;
# Need to be the class that can handle it
@@ -320,7 +319,7 @@ sub ajax : Path('/ajax') {
sub location_autocomplete : Path('/ajax/geocode') {
my ( $self, $c ) = @_;
$c->res->content_type('application/json; charset=utf-8');
- unless ( $c->req->param('term') ) {
+ unless ( $c->get_param('term') ) {
$c->res->status(404);
$c->res->body('');
return;
@@ -328,26 +327,26 @@ sub location_autocomplete : Path('/ajax/geocode') {
# we want the match even if there's no ambiguity, so recommendation doesn't
# disappear when it's the last choice being offered in the autocomplete.
$c->stash->{allow_single_geocode_match_strings} = 1;
- return $self->_geocode( $c, $c->req->param('term') );
+ return $self->_geocode( $c, $c->get_param('term') );
}
sub location_lookup : Path('/ajax/lookup_location') {
my ( $self, $c ) = @_;
$c->res->content_type('application/json; charset=utf-8');
- unless ( $c->req->param('term') ) {
+ unless ( $c->get_param('term') ) {
$c->res->status(404);
$c->res->body('');
return;
}
- return $self->_geocode( $c, $c->req->param('term') );
+ return $self->_geocode( $c, $c->get_param('term') );
}
sub _geocode : Private {
my ( $self, $c, $term ) = @_;
my ( $lat, $long, $suggestions ) =
- FixMyStreet::Geocode::lookup( $c->req->param('term'), $c );
+ FixMyStreet::Geocode::lookup( $c->get_param('term'), $c );
my ($response, @addresses, @locations);
diff --git a/perllib/FixMyStreet/App/Controller/Auth.pm b/perllib/FixMyStreet/App/Controller/Auth.pm
index fad8941c5..66cf3979c 100644
--- a/perllib/FixMyStreet/App/Controller/Auth.pm
+++ b/perllib/FixMyStreet/App/Controller/Auth.pm
@@ -28,22 +28,21 @@ Present the user with a sign in / create account page.
sub general : Path : Args(0) {
my ( $self, $c ) = @_;
- my $req = $c->req;
- $c->detach( 'redirect_on_signin', [ $req->param('r') ] )
- if $c->user && $req->param('r');
+ $c->detach( 'redirect_on_signin', [ $c->get_param('r') ] )
+ if $c->user && $c->get_param('r');
# all done unless we have a form posted to us
- return unless $req->method eq 'POST';
+ return unless $c->req->method eq 'POST';
# decide which action to take
- my $has_password = $req->param('sign_in') || $req->param('password_sign_in');
- my $has_email = $req->param('email_sign_in') || $req->param('name') || $req->param('password_register');
+ my $has_password = $c->get_param('sign_in') || $c->get_param('password_sign_in');
+ my $has_email = $c->get_param('email_sign_in') || $c->get_param('name') || $c->get_param('password_register');
$c->detach('email_sign_in') if $has_email && !$has_password;
$c->forward( 'sign_in' )
- && $c->detach( 'redirect_on_signin', [ $req->param('r') ] );
+ && $c->detach( 'redirect_on_signin', [ $c->get_param('r') ] );
}
@@ -56,9 +55,9 @@ Allow the user to sign in with a username and a password.
sub sign_in : Private {
my ( $self, $c, $email ) = @_;
- $email ||= $c->req->param('email') || '';
- my $password = $c->req->param('password_sign_in') || '';
- my $remember_me = $c->req->param('remember_me') || 0;
+ $email ||= $c->get_param('email') || '';
+ my $password = $c->get_param('password_sign_in') || '';
+ my $remember_me = $c->get_param('remember_me') || 0;
# Sign out just in case
$c->logout();
@@ -95,7 +94,7 @@ sub email_sign_in : Private {
my ( $self, $c ) = @_;
# check that the email is valid - otherwise flag an error
- my $raw_email = lc( $c->req->param('email') || '' );
+ my $raw_email = lc( $c->get_param('email') || '' );
my $email_checker = Email::Valid->new(
-mxcheck => 1,
@@ -112,8 +111,8 @@ sub email_sign_in : Private {
}
my $user_params = {};
- $user_params->{password} = $c->req->param('password_register')
- if $c->req->param('password_register');
+ $user_params->{password} = $c->get_param('password_register')
+ if $c->get_param('password_register');
my $user = $c->model('DB::User')->new( $user_params );
my $token_obj = $c->model('DB::Token') #
@@ -122,8 +121,8 @@ sub email_sign_in : Private {
scope => 'email_sign_in',
data => {
email => $good_email,
- r => $c->req->param('r'),
- name => $c->req->param('name'),
+ r => $c->get_param('r'),
+ name => $c->get_param('name'),
password => $user->password,
}
}
@@ -221,8 +220,8 @@ sub change_password : Local {
return unless $c->req->method eq 'POST';
# get the passwords
- my $new = $c->req->param('new_password') // '';
- my $confirm = $c->req->param('confirm') // '';
+ my $new = $c->get_param('new_password') // '';
+ my $confirm = $c->get_param('confirm') // '';
# check for errors
my $password_error =
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/\@/&#64;/;
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;
}
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm
index c2b0a2ee2..c3aa35008 100644
--- a/perllib/FixMyStreet/App/Controller/Dashboard.pm
+++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm
@@ -32,9 +32,9 @@ sub example : Local : Args(0) {
#$c->forward( '/report/new/setup_categories_and_bodies' );
# See if we've had anything from the dropdowns - perhaps vary results if so
- $c->stash->{ward} = $c->req->param('ward');
- $c->stash->{category} = $c->req->param('category');
- $c->stash->{q_state} = $c->req->param('state');
+ $c->stash->{ward} = $c->get_param('ward');
+ $c->stash->{category} = $c->get_param('category');
+ $c->stash->{q_state} = $c->get_param('state');
eval {
my $data = File::Slurp::read_file(
@@ -108,8 +108,8 @@ sub index : Path : Args(0) {
# See if we've had anything from the dropdowns
- $c->stash->{ward} = $c->req->param('ward');
- $c->stash->{category} = $c->req->param('category');
+ $c->stash->{ward} = $c->get_param('ward');
+ $c->stash->{category} = $c->get_param('category');
my %where = (
bodies_str => $body->id, # XXX Does this break in a two tier council? Restriction needs looking at...
@@ -143,7 +143,7 @@ sub index : Path : Args(0) {
# List of reports underneath summary table
- $c->stash->{q_state} = $c->req->param('state') || '';
+ $c->stash->{q_state} = $c->get_param('state') || '';
if ( $c->stash->{q_state} eq 'fixed' ) {
$prob_where->{'me.state'} = [ FixMyStreet::DB::Result::Problem->fixed_states() ];
} elsif ( $c->stash->{q_state} ) {
@@ -170,7 +170,7 @@ sub index : Path : Args(0) {
}
$c->stash->{lists} = \%problems;
- if ( $c->req->params->{export} ) {
+ if ( $c->get_param('export') ) {
$self->export_as_csv($c, $problems_rs, $body);
}
}
diff --git a/perllib/FixMyStreet/App/Controller/JSON.pm b/perllib/FixMyStreet/App/Controller/JSON.pm
index 17507a84b..959ead245 100644
--- a/perllib/FixMyStreet/App/Controller/JSON.pm
+++ b/perllib/FixMyStreet/App/Controller/JSON.pm
@@ -38,9 +38,9 @@ sub problems : Local {
: '';
# gather the parameters
- my $start_date = $c->req->param('start_date') || '';
- my $end_date = $c->req->param('end_date') || '';
- my $category = $c->req->param('category') || '';
+ my $start_date = $c->get_param('start_date') || '';
+ my $end_date = $c->get_param('end_date') || '';
+ my $category = $c->get_param('category') || '';
my $yyyy_mm_dd = qr{^\d{4}-\d\d-\d\d$};
if ( $start_date !~ $yyyy_mm_dd
diff --git a/perllib/FixMyStreet/App/Controller/Location.pm b/perllib/FixMyStreet/App/Controller/Location.pm
index 5e5349a6c..ff90d3d60 100644
--- a/perllib/FixMyStreet/App/Controller/Location.pm
+++ b/perllib/FixMyStreet/App/Controller/Location.pm
@@ -29,15 +29,15 @@ Use latitude and longitude if provided in parameters.
sub determine_location_from_coords : Private {
my ( $self, $c ) = @_;
- my $latitude = $c->req->param('latitude') || $c->req->param('lat');
- my $longitude = $c->req->param('longitude') || $c->req->param('lon');
+ my $latitude = $c->get_param('latitude') || $c->get_param('lat');
+ my $longitude = $c->get_param('longitude') || $c->get_param('lon');
if ( defined $latitude && defined $longitude ) {
($c->stash->{latitude}, $c->stash->{longitude}) =
map { Utils::truncate_coordinate($_) } ($latitude, $longitude);
# Also save the pc if there is one
- if ( my $pc = $c->req->param('pc') ) {
+ if ( my $pc = $c->get_param('pc') ) {
$c->stash->{pc} = $pc;
}
@@ -65,7 +65,7 @@ sub determine_location_from_pc : Private {
my ( $self, $c, $pc ) = @_;
# check for something to search
- $pc ||= $c->req->param('pc') || return;
+ $pc ||= $c->get_param('pc') || return;
$c->stash->{pc} = $pc; # for template
if ( $pc =~ /^(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)$/ ) {
diff --git a/perllib/FixMyStreet/App/Controller/Moderate.pm b/perllib/FixMyStreet/App/Controller/Moderate.pm
index ad293fbd7..08c4280a1 100644
--- a/perllib/FixMyStreet/App/Controller/Moderate.pm
+++ b/perllib/FixMyStreet/App/Controller/Moderate.pm
@@ -65,7 +65,7 @@ sub report : Chained('moderate') : PathPart('report') : CaptureArgs(1) {
});
$c->stash->{problem} = $problem;
$c->stash->{problem_original} = $original;
- $c->stash->{moderation_reason} = $c->req->param('moderation_reason') // '';
+ $c->stash->{moderation_reason} = $c->get_param('moderation_reason') // '';
}
sub moderate_report : Chained('report') : PathPart('') : Args(0) {
@@ -127,7 +127,7 @@ sub report_moderate_hide : Private {
my $problem = $c->stash->{problem} or die;
- if ($c->req->param('problem_hide')) {
+ if ($c->get_param('problem_hide')) {
$problem->update({ state => 'hidden' });
@@ -145,9 +145,9 @@ sub report_moderate_title : Private {
my $old_title = $problem->title;
my $original_title = $original->title;
- my $title = $c->req->param('problem_revert_title') ?
+ my $title = $c->get_param('problem_revert_title') ?
$original_title
- : $self->diff($original_title, $c->req->param('problem_title'));
+ : $self->diff($original_title, $c->get_param('problem_title'));
if ($title ne $old_title) {
$original->insert unless $original->in_storage;
@@ -166,9 +166,9 @@ sub report_moderate_detail : Private {
my $old_detail = $problem->detail;
my $original_detail = $original->detail;
- my $detail = $c->req->param('problem_revert_detail') ?
+ my $detail = $c->get_param('problem_revert_detail') ?
$original_detail
- : $self->diff($original_detail, $c->req->param('problem_detail'));
+ : $self->diff($original_detail, $c->get_param('problem_detail'));
if ($detail ne $old_detail) {
$original->insert unless $original->in_storage;
@@ -184,7 +184,7 @@ sub report_moderate_anon : Private {
my $problem = $c->stash->{problem} or die;
my $original = $c->stash->{problem_original};
- my $show_user = $c->req->param('problem_show_name') ? 1 : 0;
+ my $show_user = $c->get_param('problem_show_name') ? 1 : 0;
my $anonymous = $show_user ? 0 : 1;
my $old_anonymous = $problem->anonymous ? 1 : 0;
@@ -205,7 +205,7 @@ sub report_moderate_photo : Private {
return unless $original->photo;
- my $show_photo = $c->req->param('problem_show_photo') ? 1 : 0;
+ my $show_photo = $c->get_param('problem_show_photo') ? 1 : 0;
my $old_show_photo = $problem->photo ? 1 : 0;
if ($show_photo != $old_show_photo) {
@@ -268,7 +268,7 @@ sub update_moderate_hide : Private {
my $problem = $c->stash->{problem} or die;
my $comment = $c->stash->{comment} or die;
- if ($c->req->param('update_hide')) {
+ if ($c->get_param('update_hide')) {
$comment->update({ state => 'hidden' });
$c->detach( 'update_moderate_audit', ['hide'] ); # break chain here.
}
@@ -284,9 +284,9 @@ sub update_moderate_detail : Private {
my $old_detail = $comment->text;
my $original_detail = $original->detail;
- my $detail = $c->req->param('update_revert_detail') ?
+ my $detail = $c->get_param('update_revert_detail') ?
$original_detail
- : $self->diff($original_detail, $c->req->param('update_detail'));
+ : $self->diff($original_detail, $c->get_param('update_detail'));
if ($detail ne $old_detail) {
$original->insert unless $original->in_storage;
@@ -303,7 +303,7 @@ sub update_moderate_anon : Private {
my $comment = $c->stash->{comment} or die;
my $original = $c->stash->{comment_original};
- my $show_user = $c->req->param('update_show_name') ? 1 : 0;
+ my $show_user = $c->get_param('update_show_name') ? 1 : 0;
my $anonymous = $show_user ? 0 : 1;
my $old_anonymous = $comment->anonymous ? 1 : 0;
@@ -324,7 +324,7 @@ sub update_moderate_photo : Private {
return unless $original->photo;
- my $show_photo = $c->req->param('update_show_photo') ? 1 : 0;
+ my $show_photo = $c->get_param('update_show_photo') ? 1 : 0;
my $old_show_photo = $comment->photo ? 1 : 0;
if ($show_photo != $old_show_photo) {
diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm
index b3d341a68..83d5f7adb 100644
--- a/perllib/FixMyStreet/App/Controller/My.pm
+++ b/perllib/FixMyStreet/App/Controller/My.pm
@@ -25,8 +25,8 @@ sub my : Path : Args(0) {
$c->detach( '/auth/redirect' ) unless $c->user;
- my $p_page = $c->req->params->{p} || 1;
- my $u_page = $c->req->params->{u} || 1;
+ my $p_page = $c->get_param('p') || 1;
+ my $u_page = $c->get_param('u') || 1;
$c->forward( '/reports/stash_report_filter_status' );
@@ -42,7 +42,7 @@ sub my : Path : Args(0) {
%$params
} if $c->cobrand->problems_clause;
- my $category = $c->req->param('filter_category');
+ my $category = $c->get_param('filter_category');
if ( $category ) {
$params->{category} = $category;
$c->stash->{filter_category} = $category;
diff --git a/perllib/FixMyStreet/App/Controller/Open311.pm b/perllib/FixMyStreet/App/Controller/Open311.pm
index 64b21db6b..96066ca93 100644
--- a/perllib/FixMyStreet/App/Controller/Open311.pm
+++ b/perllib/FixMyStreet/App/Controller/Open311.pm
@@ -155,9 +155,9 @@ sub get_discovery : Private {
sub get_services : Private {
my ( $self, $c ) = @_;
- my $jurisdiction_id = $c->req->param('jurisdiction_id') || '';
- my $lat = $c->req->param('lat') || '';
- my $lon = $c->req->param('long') || '';
+ my $jurisdiction_id = $c->get_param('jurisdiction_id') || '';
+ my $lat = $c->get_param('lat') || '';
+ my $lon = $c->get_param('long') || '';
# Look up categories for this council or councils
my $categories = $c->model('DB::Contact')->not_deleted;
@@ -309,7 +309,7 @@ sub get_requests : Private {
$c->forward( 'is_jurisdiction_id_ok' );
- my $max_requests = $c->req->param('max_requests') || 0;
+ my $max_requests = $c->get_param('max_requests') || 0;
# Only provide access to the published reports
my $states = FixMyStreet::DB::Result::Problem->visible_states();
@@ -327,7 +327,7 @@ sub get_requests : Private {
has_photo => [ '=', 'photo' ],
);
for my $param (keys %rules) {
- my $value = $c->req->param($param);
+ my $value = $c->get_param($param);
next unless $value;
my $op = $rules{$param}[0];
my $key = $rules{$param}[1];
@@ -366,12 +366,12 @@ sub get_requests : Private {
$criteria->{$key} = { $op, $value };
}
- if ( $c->req->param('start_date') and $c->req->param('end_date') ) {
- $criteria->{confirmed} = [ '-and' => { '>=', $c->req->param('start_date') }, { '<', $c->req->param('end_date') } ];
- } elsif ( $c->req->param('start_date') ) {
- $criteria->{confirmed} = { '>=', $c->req->param('start_date') };
- } elsif ( $c->req->param('end_date') ) {
- $criteria->{confirmed} = { '<', $c->req->param('end_date') };
+ if ( $c->get_param('start_date') and $c->get_param('end_date') ) {
+ $criteria->{confirmed} = [ '-and' => { '>=', $c->get_param('start_date') }, { '<', $c->get_param('end_date') } ];
+ } elsif ( $c->get_param('start_date') ) {
+ $criteria->{confirmed} = { '>=', $c->get_param('start_date') };
+ } elsif ( $c->get_param('end_date') ) {
+ $criteria->{confirmed} = { '<', $c->get_param('end_date') };
}
if ('rss' eq $c->stash->{format}) {
@@ -441,7 +441,7 @@ sub format_output : Private {
sub is_jurisdiction_id_ok : Private {
my ( $self, $c ) = @_;
- unless (my $jurisdiction_id = $c->req->param('jurisdiction_id')) {
+ unless (my $jurisdiction_id = $c->get_param('jurisdiction_id')) {
$c->detach( 'error', [ _('Missing jurisdiction_id') ] );
}
}
diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm
index d70be50e6..a2ec7d4c8 100644
--- a/perllib/FixMyStreet/App/Controller/Photo.pm
+++ b/perllib/FixMyStreet/App/Controller/Photo.pm
@@ -226,7 +226,7 @@ sub process_photo_cache : Private {
my ( $self, $c ) = @_;
# get the fileid and make sure it is just a hex number
- my $fileid = $c->req->param('upload_fileid') || '';
+ my $fileid = $c->get_param('upload_fileid') || '';
$fileid =~ s{[^0-9a-f]}{}gi;
return unless $fileid;
diff --git a/perllib/FixMyStreet/App/Controller/Questionnaire.pm b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
index f6cc33e74..f9a08e408 100755
--- a/perllib/FixMyStreet/App/Controller/Questionnaire.pm
+++ b/perllib/FixMyStreet/App/Controller/Questionnaire.pm
@@ -67,15 +67,15 @@ token), or the mini own-report one (when we'll have a problem ID).
sub submit : Path('submit') {
my ( $self, $c ) = @_;
- if (my $token = $c->req->params->{token}) {
+ if (my $token = $c->get_param('token')) {
if ($token eq '_test_') {
- $c->stash->{been_fixed} = $c->req->params->{been_fixed};
- $c->stash->{new_state} = $c->req->params->{new_state};
+ $c->stash->{been_fixed} = $c->get_param('been_fixed');
+ $c->stash->{new_state} = $c->get_param('new_state');
$c->stash->{template} = 'questionnaire/completed.html';
return;
}
$c->forward('submit_standard');
- } elsif (my $p = $c->req->params->{problem}) {
+ } elsif (my $p = $c->get_param('problem')) {
$c->detach('creator_fixed') if $p eq '_test_';
$c->forward('submit_creator_fixed');
} else {
@@ -103,8 +103,8 @@ sub submit_creator_fixed : Private {
my @errors;
- $c->stash->{reported} = $c->req->params->{reported};
- $c->stash->{problem_id} = $c->req->params->{problem};
+ $c->stash->{reported} = $c->get_param('reported');
+ $c->stash->{problem_id} = $c->get_param('problem');
# should only be able to get to here if we are logged and we have a
# problem
@@ -156,7 +156,7 @@ sub submit_creator_fixed : Private {
sub submit_standard : Private {
my ( $self, $c ) = @_;
- $c->forward( '/tokens/load_questionnaire', [ $c->req->params->{token} ] );
+ $c->forward( '/tokens/load_questionnaire', [ $c->get_param('token') ] );
$c->forward( 'check_questionnaire' );
$c->forward( 'process_questionnaire' );
@@ -232,7 +232,7 @@ sub submit_standard : Private {
sub process_questionnaire : Private {
my ( $self, $c ) = @_;
- map { $c->stash->{$_} = $c->req->params->{$_} || '' } qw(been_fixed reported another update);
+ map { $c->stash->{$_} = $c->get_param($_) || '' } qw(been_fixed reported another update);
# EHA questionnaires done for you
if ($c->cobrand->moniker eq 'emptyhomes') {
diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm
index 817e2a631..97250f859 100644
--- a/perllib/FixMyStreet/App/Controller/Report.pm
+++ b/perllib/FixMyStreet/App/Controller/Report.pm
@@ -24,7 +24,7 @@ Redirect to homepage unless C<id> parameter in query, in which case redirect to
sub index : Path('') : Args(0) {
my ( $self, $c ) = @_;
- my $id = $c->req->param('id');
+ my $id = $c->get_param('id');
my $uri =
$id
@@ -78,7 +78,7 @@ sub _display : Private {
sub support : Path('support') : Args(0) {
my ( $self, $c ) = @_;
- my $id = $c->req->param('id');
+ my $id = $c->get_param('id');
my $uri =
$id
@@ -163,7 +163,7 @@ sub format_problem_for_display : Private {
map { Utils::truncate_coordinate($_) }
( $problem->latitude, $problem->longitude );
- unless ( $c->req->param('submit_update') ) {
+ unless ( $c->get_param('submit_update') ) {
$c->stash->{add_alert} = 1;
}
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index b4daf0f55..69c94b911 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -221,12 +221,13 @@ sub category_extras_ajax : Path('category_extras') : Args(0) {
$c->forward('setup_categories_and_bodies');
my $category_extra = '';
- if ( $c->stash->{category_extras}->{ $c->req->param('category') } && @{ $c->stash->{category_extras}->{ $c->req->param('category') } } >= 1 ) {
+ my $category = $c->get_param('category');
+ if ( $c->stash->{category_extras}->{$category} && @{ $c->stash->{category_extras}->{$category} } >= 1 ) {
$c->stash->{report_meta} = {};
- $c->stash->{report} = { category => $c->req->param('category') };
- $c->stash->{category_extras} = { $c->req->param('category' ) => $c->stash->{category_extras}->{ $c->req->param('category') } };
+ $c->stash->{report} = { category => $category };
+ $c->stash->{category_extras} = { $category => $c->stash->{category_extras}->{$category} };
- $category_extra= $c->render_fragment( 'report/new/category_extras.html');
+ $category_extra = $c->render_fragment( 'report/new/category_extras.html');
}
my $body = JSON->new->utf8(1)->encode(
@@ -256,7 +257,7 @@ sub report_import : Path('/import') {
$c->res->content_type('text/plain; charset=utf-8');
my %input =
- map { $_ => $c->req->param($_) || '' } (
+ map { $_ => $c->get_param($_) || '' } (
'service', 'subject', 'detail', 'name', 'email', 'phone',
'easting', 'northing', 'lat', 'lon', 'id', 'phone_id',
);
@@ -407,7 +408,7 @@ sub initialize_report : Private {
# create a new one. Stick it on the stash.
my $report = undef;
- if ( my $partial = scalar $c->req->param('partial') ) {
+ if ( my $partial = $c->get_param('partial') ) {
for (1) { # use as pseudo flow control
@@ -461,15 +462,15 @@ sub initialize_report : Private {
}
- if ( $c->req->param('first_name') && $c->req->param('last_name') ) {
- $c->stash->{first_name} = $c->req->param('first_name');
- $c->stash->{last_name} = $c->req->param('last_name');
+ if ( $c->get_param('first_name') && $c->get_param('last_name') ) {
+ $c->stash->{first_name} = $c->get_param('first_name');
+ $c->stash->{last_name} = $c->get_param('last_name');
- $c->req->param( 'name', sprintf( '%s %s', $c->req->param('first_name'), $c->req->param('last_name') ) );
+ $c->set_param('name', sprintf( '%s %s', $c->get_param('first_name'), $c->get_param('last_name') ));
}
# Capture whether the map was used
- $report->used_map( $c->req->param('skipped') ? 0 : 1 );
+ $report->used_map( $c->get_param('skipped') ? 0 : 1 );
$c->stash->{report} = $report;
@@ -523,8 +524,8 @@ sub determine_location_from_tile_click : Private {
# Extract the data needed
my ( $pin_tile_x, $pin_tile_y ) = $x_key =~ m{$param_key_regex};
- my $pin_x = $c->req->param($x_key);
- my $pin_y = $c->req->param($y_key);
+ my $pin_x = $c->get_param($x_key);
+ my $pin_y = $c->get_param($y_key);
# return if they are both 0 - this happens when you submit the form by
# hitting enter and not using the button. It also happens if you click
@@ -694,7 +695,7 @@ on the presence of the C<submit_problem> parameter.
sub check_form_submitted : Private {
my ( $self, $c ) = @_;
return if $c->stash->{force_form_not_submitted};
- return $c->req->param('submit_problem') || '';
+ return $c->get_param('submit_problem') || '';
}
=head2 process_user
@@ -709,7 +710,7 @@ sub process_user : Private {
my $report = $c->stash->{report};
# 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($_) }
( 'email', 'name', 'phone', 'password_register', 'fms_extra_title' );
my $user_title = Utils::trim_text( $params{fms_extra_title} );
@@ -741,7 +742,7 @@ sub process_user : Private {
unless $report->user;
# The user is trying to sign in. We only care about email from the params.
- if ( $c->req->param('submit_sign_in') || $c->req->param('password_sign_in') ) {
+ if ( $c->get_param('submit_sign_in') || $c->get_param('password_sign_in') ) {
unless ( $c->forward( '/auth/sign_in' ) ) {
$c->stash->{field_errors}->{password} = _('There was a problem with your email/password combination. If you cannot remember your password, or do not have one, please fill in the &lsquo;sign in by email&rsquo; section of the form.');
return 1;
@@ -779,7 +780,7 @@ sub process_report : Private {
# Extract all the params to a hash to make them easier to work with
my %params = #
- map { $_ => scalar $c->req->param($_) } #
+ map { $_ => $c->get_param($_) }
(
'title', 'detail', 'pc', #
'detail_size', 'detail_depth',
@@ -877,14 +878,14 @@ sub process_report : Private {
foreach my $field ( @$metas ) {
if ( lc( $field->{required} ) eq 'true' ) {
- unless ( $c->request->param( $field->{code} ) ) {
+ unless ( $c->get_param($field->{code}) ) {
$c->stash->{field_errors}->{ $field->{code} } = _('This information is required');
}
}
push @extra, {
name => $field->{code},
description => $field->{description},
- value => $c->request->param( $field->{code} ) || '',
+ value => $c->get_param($field->{code}) || '',
};
}
@@ -947,7 +948,7 @@ sub check_for_errors : Private {
# We only want to validate the phone number web requests (where the
# service parameter is blank) because previous versions of the mobile
# apps don't validate the presence of a phone number.
- if ( ! $c->req->param('phone') and ! $c->req->param('service') ) {
+ if ( ! $c->get_param('phone') and ! $c->get_param('service') ) {
$field_errors{phone} = _("This information is required");
}
}
@@ -957,7 +958,7 @@ sub check_for_errors : Private {
# if they're got the login details wrong when signing in then
# we don't care about the name field even though it's validated
# by the user object
- if ( $c->req->param('submit_sign_in') and $field_errors{password} ) {
+ if ( $c->get_param('submit_sign_in') and $field_errors{password} ) {
delete $field_errors{name};
}
@@ -1043,9 +1044,9 @@ sub save_user_and_report : Private {
$report->bodies_str( undef ) if $report->bodies_str eq '-1';
# if there is a Message Manager message ID, pass it back to the client view
- if ($c->cobrand->moniker eq 'fixmybarangay' && $c->req->param('external_source_id')=~/^\d+$/) {
- $c->stash->{external_source_id} = $c->req->param('external_source_id');
- $report->external_source_id( $c->req->param('external_source_id') );
+ if ($c->cobrand->moniker eq 'fixmybarangay' && $c->get_param('external_source_id') =~ /^\d+$/) {
+ $c->stash->{external_source_id} = $c->get_param('external_source_id');
+ $report->external_source_id( $c->get_param('external_source_id') );
$report->external_source( $c->config->{MESSAGE_MANAGER_URL} ) ;
}
@@ -1095,7 +1096,7 @@ sub generate_map : Private {
sub check_for_category : Private {
my ( $self, $c ) = @_;
- $c->stash->{category} = $c->req->param('category');
+ $c->stash->{category} = $c->get_param('category');
return 1;
}
@@ -1165,7 +1166,7 @@ sub redirect_to_around : Private {
my ( $self, $c ) = @_;
my $params = {
- pc => ( $c->stash->{pc} || $c->req->param('pc') || '' ),
+ pc => ( $c->stash->{pc} || $c->get_param('pc') || '' ),
lat => $c->stash->{latitude},
lon => $c->stash->{longitude},
};
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index f1a1aa821..79fed0fd1 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -20,12 +20,12 @@ Creates an update to a report
sub report_update : Path : Args(0) {
my ( $self, $c ) = @_;
- $c->forward( '/report/load_problem_or_display_error', [ $c->req->param('id') ] );
+ $c->forward( '/report/load_problem_or_display_error', [ $c->get_param('id') ] );
$c->forward('process_update');
$c->forward('process_user');
$c->forward('/photo/process_photo');
$c->forward('check_for_errors')
- or $c->go( '/report/display', [ $c->req->param('id') ] );
+ or $c->go( '/report/display', [ $c->get_param('id') ] );
$c->forward('save_update');
$c->forward('redirect_or_confirm_creation');
@@ -76,7 +76,7 @@ sub update_problem : Private {
$problem->state('confirmed');
}
- if ( $c->cobrand->can_support_problems && $c->user && $c->user->from_body && $c->req->param('external_source_id') ) {
+ if ( $c->cobrand->can_support_problems && $c->user && $c->user->from_body && $c->get_param('external_source_id') ) {
$problem->interest_count( \'interest_count + 1' );
}
@@ -106,9 +106,9 @@ sub process_user : Private {
if ( $c->user_exists ) {
my $user = $c->user->obj;
- my $name = scalar $c->req->param('name');
+ my $name = $c->get_param('name');
$user->name( Utils::trim_text( $name ) ) if $name;
- my $title = scalar $c->req->param('fms_extra_title');
+ my $title = $c->get_param('fms_extra_title');
if ( $title ) {
$c->log->debug( 'user exists and title is ' . $title );
$user->title( Utils::trim_text( $title ) );
@@ -118,7 +118,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', 'name', 'password_register', 'fms_extra_title' );
# cleanup the email address
@@ -129,7 +129,7 @@ sub process_user : Private {
unless $update->user;
# The user is trying to sign in. We only care about email from the params.
- if ( $c->req->param('submit_sign_in') || $c->req->param('password_sign_in') ) {
+ if ( $c->get_param('submit_sign_in') || $c->get_param('password_sign_in') ) {
unless ( $c->forward( '/auth/sign_in', [ $email ] ) ) {
$c->stash->{field_errors}->{password} = _('There was a problem with your email/password combination. If you cannot remember your password, or do not have one, please fill in the &lsquo;sign in by email&rsquo; section of the form.');
return 1;
@@ -164,23 +164,23 @@ want to move adding these elsewhere
sub process_update : Private {
my ( $self, $c ) = @_;
- if ( $c->req->param('first_name' ) && $c->req->param('last_name' ) ) {
- my $first_name = $c->req->param('first_name');
- my $last_name = $c->req->param('last_name');
- $c->req->param('name', sprintf( '%s %s', $first_name, $last_name ) );
+ if ( $c->get_param('first_name') && $c->get_param('last_name') ) {
+ my $first_name = $c->get_param('first_name');
+ my $last_name = $c->get_param('last_name');
+ $c->set_param('name', sprintf( '%s %s', $first_name, $last_name ));
$c->stash->{first_name} = $first_name;
$c->stash->{last_name} = $last_name;
}
my %params =
- map { $_ => scalar $c->req->param($_) } ( 'update', 'name', 'fixed', 'state', 'reopen' );
+ map { $_ => $c->get_param($_) } ( 'update', 'name', 'fixed', 'state', 'reopen' );
$params{update} =
Utils::cleanup_text( $params{update}, { allow_multiline => 1 } );
my $name = Utils::trim_text( $params{name} );
- my $anonymous = $c->req->param('may_show_name') ? 0 : 1;
+ my $anonymous = $c->get_param('may_show_name') ? 0 : 1;
$params{reopen} = 0 unless $c->user && $c->user->id == $c->stash->{problem}->user->id;
@@ -225,10 +225,10 @@ sub process_update : Private {
# TODO Use extra here as it is used on reports.
$c->cobrand->process_extras( $c, $update->problem->bodies_str, \@extra );
- if ( $c->req->param('fms_extra_title') ) {
+ if ( $c->get_param('fms_extra_title') ) {
my %extras = ();
- $extras{title} = $c->req->param('fms_extra_title');
- $extras{email_alerts_requested} = $c->req->param('add_alert');
+ $extras{title} = $c->get_param('fms_extra_title');
+ $extras{email_alerts_requested} = $c->get_param('add_alert');
$update->extra( \%extras );
}
@@ -239,10 +239,10 @@ sub process_update : Private {
$update->extra( $extra );
}
- $c->log->debug( 'name is ' . $c->req->param('name') );
+ $c->log->debug( 'name is ' . $c->get_param('name') );
- $c->stash->{update} = $update;
- $c->stash->{add_alert} = $c->req->param('add_alert');
+ $c->stash->{update} = $update;
+ $c->stash->{add_alert} = $c->get_param('add_alert');
return 1;
}
@@ -259,11 +259,11 @@ sub check_for_errors : Private {
my ( $self, $c ) = @_;
# they have to be an authority user to update the state
- if ( $c->req->param('state') ) {
+ if ( $c->get_param('state') ) {
my $error = 0;
$error = 1 unless $c->user && $c->user->belongs_to_body( $c->stash->{update}->problem->bodies_str );
- my $state = $c->req->param('state');
+ my $state = $c->get_param('state');
$state = 'fixed - council' if $state eq 'fixed';
$error = 1 unless ( grep { $state eq $_ } ( FixMyStreet::DB::Result::Problem->council_states() ) );
@@ -388,7 +388,7 @@ sub redirect_or_confirm_creation : Private {
data => {
%$data,
id => $update->id,
- add_alert => ( $c->req->param('add_alert') ? 1 : 0 ),
+ add_alert => ( $c->get_param('add_alert') ? 1 : 0 ),
}
}
);
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index 5a044c9af..6b0d516a6 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -128,7 +128,7 @@ sub ward : Path : Args(2) {
} )->all;
@categories = map { $_->category } @categories;
$c->stash->{filter_categories} = \@categories;
- $c->stash->{filter_category} = $c->req->param('filter_category');
+ $c->stash->{filter_category} = $c->get_param('filter_category');
my $pins = $c->stash->{pins};
@@ -383,10 +383,10 @@ sub check_canonical_url : Private {
sub load_and_group_problems : Private {
my ( $self, $c ) = @_;
- my $page = $c->req->params->{p} || 1;
+ my $page = $c->get_param('p') || 1;
# NB: If 't' is specified, it will override 'status'.
- my $type = $c->req->params->{t} || 'all';
- my $category = $c->req->params->{c} || $c->req->params->{filter_category} || '';
+ my $type = $c->get_param('t') || 'all';
+ my $category = $c->get_param('c') || $c->get_param('filter_category') || '';
my $states = $c->stash->{filter_problem_states};
my $where = {
@@ -500,7 +500,7 @@ sub redirect_body : Private {
sub stash_report_filter_status : Private {
my ( $self, $c ) = @_;
- my $status = $c->req->param('status') || $c->cobrand->on_map_default_status;
+ my $status = $c->get_param('status') || $c->cobrand->on_map_default_status;
if ( $status eq 'all' ) {
$c->stash->{filter_status} = 'all';
$c->stash->{filter_problem_states} = FixMyStreet::DB::Result::Problem->visible_states();
diff --git a/perllib/FixMyStreet/App/Controller/Root.pm b/perllib/FixMyStreet/App/Controller/Root.pm
index 769a147bf..16f4aa491 100644
--- a/perllib/FixMyStreet/App/Controller/Root.pm
+++ b/perllib/FixMyStreet/App/Controller/Root.pm
@@ -47,7 +47,7 @@ sub index : Path : Args(0) {
my %old_params = ();
foreach my $key (@old_param_keys) {
- my $val = $c->req->param($key);
+ my $val = $c->get_param($key);
next unless $val;
$old_params{$key} = $val;
}
diff --git a/perllib/FixMyStreet/App/Controller/Rss.pm b/perllib/FixMyStreet/App/Controller/Rss.pm
index cbeddce85..7aafc99ff 100755
--- a/perllib/FixMyStreet/App/Controller/Rss.pm
+++ b/perllib/FixMyStreet/App/Controller/Rss.pm
@@ -350,7 +350,7 @@ sub get_query_parameters : Private {
$d = '' unless $d && $d =~ /^\d+$/;
$c->stash->{distance} = $d;
- my $state = $c->req->param('state') || 'all';
+ my $state = $c->get_param('state') || 'all';
$state = 'all' unless $state =~ /^(all|open|fixed)$/;
$c->stash->{state_qs} = "?state=$state" unless $state eq 'all';
diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm
index 4c0afdeda..96bcedd37 100644
--- a/perllib/FixMyStreet/App/Controller/Tokens.pm
+++ b/perllib/FixMyStreet/App/Controller/Tokens.pm
@@ -143,7 +143,7 @@ sub confirm_alert : Path('/A') {
my ( $self, $c, $token_code ) = @_;
if ($token_code eq '_test_') {
- $c->stash->{confirm_type} = $c->req->params->{confirm_type};
+ $c->stash->{confirm_type} = $c->get_param('confirm_type');
return;
}
diff --git a/perllib/FixMyStreet/Cobrand/EmptyHomes.pm b/perllib/FixMyStreet/Cobrand/EmptyHomes.pm
index 5052d91a7..0b02f90c4 100644
--- a/perllib/FixMyStreet/Cobrand/EmptyHomes.pm
+++ b/perllib/FixMyStreet/Cobrand/EmptyHomes.pm
@@ -138,7 +138,7 @@ sub process_extras {
my $body_id = shift;
my $extra = shift;
- my $value = $ctx->request->params->{address} || '';
+ my $value = $ctx->get_param('address') || '';
$ctx->stash->{field_errors}->{address} = _('This information is required')
unless $value;
$extra->{address} = $value;
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index 9001ca5f7..f21d38ff8 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -40,12 +40,12 @@ sub extra_contact_validation {
my %errors;
- $c->stash->{dest} = $c->req->param('dest');
+ $c->stash->{dest} = $c->get_param('dest');
$errors{dest} = "Please enter who your message is for"
- unless $c->req->param('dest');
+ unless $c->get_param('dest');
- if ( $c->req->param('dest') eq 'council' || $c->req->param('dest') eq 'update' ) {
+ if ( $c->get_param('dest') eq 'council' || $c->get_param('dest') eq 'update' ) {
$errors{not_for_us} = 1;
}
diff --git a/perllib/FixMyStreet/Cobrand/SeeSomething.pm b/perllib/FixMyStreet/Cobrand/SeeSomething.pm
index 775ba770b..75f1c32e8 100644
--- a/perllib/FixMyStreet/Cobrand/SeeSomething.pm
+++ b/perllib/FixMyStreet/Cobrand/SeeSomething.pm
@@ -99,22 +99,22 @@ sub admin_stats {
$c->detach( '/page_error_404_not_found' );
}
- if ( $c->req->param('category') ) {
- $filters{category} = $c->req->param('category');
- $c->stash->{category} = $c->req->param('category');
+ if ( $c->get_param('category') ) {
+ $filters{category} = $c->get_param('category');
+ $c->stash->{category} = $c->get_param('category');
}
- if ( $c->req->param('subcategory') ) {
- $filters{subcategory} = $c->req->param('subcategory');
- $c->stash->{subcategory} = $c->req->param('subcategory');
+ if ( $c->get_param('subcategory') ) {
+ $filters{subcategory} = $c->get_param('subcategory');
+ $c->stash->{subcategory} = $c->get_param('subcategory');
}
- if ( $c->req->param('service') ) {
- $filters{service} = { -ilike => $c->req->param('service') };
- $c->stash->{service} = $c->req->param('service');
+ if ( $c->get_param('service') ) {
+ $filters{service} = { -ilike => $c->get_param('service') };
+ $c->stash->{service} = $c->get_param('service');
}
- my $page = $c->req->params->{p} || 1;
+ my $page = $c->get_param('p') || 1;
my $p = $c->model('DB::Problem')->search(
{
diff --git a/perllib/FixMyStreet/Cobrand/UK.pm b/perllib/FixMyStreet/Cobrand/UK.pm
index cd64de9c6..b293c3568 100644
--- a/perllib/FixMyStreet/Cobrand/UK.pm
+++ b/perllib/FixMyStreet/Cobrand/UK.pm
@@ -37,7 +37,7 @@ sub process_extras {
if ( $body_id eq '2482' ) {
my @fields = ( 'fms_extra_title', @$fields );
for my $field ( @fields ) {
- my $value = $ctx->request->param( $field );
+ my $value = $ctx->get_param($field);
if ( !$value ) {
$ctx->stash->{field_errors}->{ $field } = _('This information is required');
@@ -49,8 +49,8 @@ sub process_extras {
};
}
- if ( $ctx->request->param('fms_extra_title') ) {
- $ctx->stash->{fms_extra_title} = $ctx->request->param('fms_extra_title');
+ if ( $ctx->get_param('fms_extra_title') ) {
+ $ctx->stash->{fms_extra_title} = $ctx->get_param('fms_extra_title');
$ctx->stash->{extra_name_info} = 1;
}
}
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index 65930a092..e653ae522 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -85,11 +85,11 @@ sub area_check {
} else {
$url .= 'around';
}
- $url .= '?pc=' . URI::Escape::uri_escape( $self->{c}->req->param('pc') )
- if $self->{c}->req->param('pc');
- $url .= '?latitude=' . URI::Escape::uri_escape( $self->{c}->req->param('latitude') )
- . '&amp;longitude=' . URI::Escape::uri_escape( $self->{c}->req->param('longitude') )
- if $self->{c}->req->param('latitude');
+ $url .= '?pc=' . URI::Escape::uri_escape( $self->{c}->get_param('pc') )
+ if $self->{c}->get_param('pc');
+ $url .= '?latitude=' . URI::Escape::uri_escape( $self->{c}->get_param('latitude') )
+ . '&amp;longitude=' . URI::Escape::uri_escape( $self->{c}->get_param('longitude') )
+ if $self->{c}->get_param('latitude');
my $error_msg = "That location is not covered by " . $self->council_name . ".
Please visit <a href=\"$url\">the main FixMyStreet site</a>.";
return ( 0, $error_msg );
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm
index 100349efb..c64fe1177 100644
--- a/perllib/FixMyStreet/Cobrand/Zurich.pm
+++ b/perllib/FixMyStreet/Cobrand/Zurich.pm
@@ -342,8 +342,8 @@ sub admin {
my @children = map { $_->id } $body->bodies->all;
my @all = (@children, $body->id);
- my $order = $c->req->params->{o} || 'created';
- my $dir = defined $c->req->params->{d} ? $c->req->params->{d} : 1;
+ my $order = $c->get_param('o') || 'created';
+ my $dir = defined $c->get_param('d') ? $c->get_param('d') : 1;
$c->stash->{order} = $order;
$c->stash->{dir} = $dir;
$order .= ' desc' if $dir;
@@ -362,7 +362,7 @@ sub admin {
order_by => $order,
});
- my $page = $c->req->params->{p} || 1;
+ my $page = $c->get_param('p') || 1;
$c->stash->{other} = $c->cobrand->problems->search({
state => { -not_in => [ 'unconfirmed', 'confirmed', 'planned' ] },
bodies_str => \@all,
@@ -376,8 +376,8 @@ sub admin {
my $body = $c->stash->{body};
- my $order = $c->req->params->{o} || 'created';
- my $dir = defined $c->req->params->{d} ? $c->req->params->{d} : 1;
+ my $order = $c->get_param('o') || 'created';
+ my $dir = defined $c->get_param('d') ? $c->get_param('d') : 1;
$c->stash->{order} = $order;
$c->stash->{dir} = $dir;
$order .= ' desc' if $dir;
@@ -396,7 +396,7 @@ sub admin {
order_by => $order
} );
- my $page = $c->req->params->{p} || 1;
+ my $page = $c->get_param('p') || 1;
$c->stash->{reports_published} = $c->cobrand->problems->search( {
state => 'fixed - council',
bodies_str => $body->parent->id,
@@ -449,14 +449,14 @@ sub admin_report_edit {
}
# If super or sdm check that the token is correct before proceeding
- if ( ($type eq 'super' || $type eq 'dm') && $c->req->param('submit') ) {
+ if ( ($type eq 'super' || $type eq 'dm') && $c->get_param('submit') ) {
$c->forward('check_token');
}
# All types of users can add internal notes
- if ( ($type eq 'super' || $type eq 'dm' || $type eq 'sdm') && $c->req->param('submit') ) {
+ if ( ($type eq 'super' || $type eq 'dm' || $type eq 'sdm') && $c->get_param('submit') ) {
# If there is a new note add it as a comment to the problem (with is_internal_note set true in extra).
- if ( my $new_internal_note = $c->req->params->{new_internal_note} ) {
+ if ( my $new_internal_note = $c->get_param('new_internal_note') ) {
$problem->add_to_comments( {
text => $new_internal_note,
user => $c->user->obj,
@@ -469,12 +469,12 @@ sub admin_report_edit {
}
# Problem updates upon submission
- if ( ($type eq 'super' || $type eq 'dm') && $c->req->param('submit') ) {
- $problem->set_extra_metadata('publish_photo' => $c->req->params->{publish_photo} || 0 );
- $problem->set_extra_metadata('third_personal' => $c->req->params->{third_personal} || 0 );
+ if ( ($type eq 'super' || $type eq 'dm') && $c->get_param('submit') ) {
+ $problem->set_extra_metadata('publish_photo' => $c->get_param('publish_photo') || 0 );
+ $problem->set_extra_metadata('third_personal' => $c->get_param('third_personal') || 0 );
# Make sure we have a copy of the original detail field
- if (my $new_detail = $c->req->params->{detail}) {
+ if (my $new_detail = $c->get_param('detail')) {
my $old_detail = $problem->detail;
if (! $problem->get_extra_metadata('original_detail')
&& ($old_detail ne $new_detail))
@@ -489,9 +489,9 @@ sub admin_report_edit {
# Workflow things
my $redirect = 0;
- my $new_cat = $c->req->params->{category};
+ my $new_cat = $c->get_param('category');
if ( $new_cat && $new_cat ne $problem->category ) {
- my $cat = $c->model('DB::Contact')->search( { category => $c->req->params->{category} } )->first;
+ my $cat = $c->model('DB::Contact')->search( { category => $c->get_param('category') } )->first;
my $old_cat = $problem->category;
$problem->category( $new_cat );
$problem->external_body( undef );
@@ -500,14 +500,14 @@ sub admin_report_edit {
$problem->set_extra_metadata(changed_category => 1);
$internal_note_text = "Weitergeleitet von $old_cat an $new_cat";
$redirect = 1 if $cat->body_id ne $body->id;
- } elsif ( my $subdiv = $c->req->params->{body_subdivision} ) {
+ } elsif ( my $subdiv = $c->get_param('body_subdivision') ) {
$problem->set_extra_metadata_if_undefined( moderated_overdue => $self->overdue( $problem ) );
$self->set_problem_state($c, $problem, 'in progress');
$problem->external_body( undef );
$problem->bodies_str( $subdiv );
$problem->whensent( undef );
$redirect = 1;
- } elsif ( my $external = $c->req->params->{body_external} ) {
+ } elsif ( my $external = $c->get_param('body_external') ) {
$problem->set_extra_metadata_if_undefined( moderated_overdue => $self->overdue( $problem ) );
$self->set_problem_state($c, $problem, 'closed');
$problem->set_extra_metadata_if_undefined( closed_overdue => $self->overdue( $problem ) );
@@ -516,7 +516,7 @@ sub admin_report_edit {
_admin_send_email( $c, 'problem-external.txt', $problem );
$redirect = 1;
} else {
- if (my $state = $c->req->params->{state}) {
+ if (my $state = $c->get_param('state')) {
if ($problem->state eq 'unconfirmed' and $state ne 'unconfirmed') {
# only set this for the first state change
@@ -528,21 +528,21 @@ sub admin_report_edit {
if ($self->problem_is_closed($problem)) {
$problem->set_extra_metadata_if_undefined( closed_overdue => $self->overdue( $problem ) );
}
- if ( $state eq 'hidden' && $c->req->params->{send_rejected_email} ) {
+ if ( $state eq 'hidden' && $c->get_param('send_rejected_email') ) {
_admin_send_email( $c, 'problem-rejected.txt', $problem );
}
}
}
- $problem->title( $c->req->param('title') );
- $problem->detail( $c->req->param('detail') );
- $problem->latitude( $c->req->param('latitude') );
- $problem->longitude( $c->req->param('longitude') );
+ $problem->title( $c->get_param('title') ) if $c->get_param('title');
+ $problem->detail( $c->get_param('detail') ) if $c->get_param('detail');
+ $problem->latitude( $c->get_param('latitude') );
+ $problem->longitude( $c->get_param('longitude') );
# Final, public, Update from DM
- if (my $update = $c->req->param('status_update')) {
+ if (my $update = $c->get_param('status_update')) {
$problem->set_extra_metadata(public_response => $update);
- if ($c->req->params->{publish_response}) {
+ if ($c->get_param('publish_response')) {
$self->set_problem_state($c, $problem, 'fixed - council');
$problem->set_extra_metadata( closed_overdue => $self->overdue( $problem ) );
_admin_send_email( $c, 'problem-closed.txt', $problem );
@@ -588,7 +588,7 @@ sub admin_report_edit {
# Has cut-down edit template for adding update and sending back up only
$c->stash->{template} = 'admin/report_edit-sdm.html';
- if ($c->req->param('send_back')) {
+ if ($c->get_param('send_back')) {
$c->forward('check_token');
$problem->bodies_str( $body->parent->id );
@@ -597,20 +597,20 @@ sub admin_report_edit {
# log here
$c->res->redirect( '/admin/summary' );
- } elsif ($c->req->param('submit')) {
+ } elsif ($c->get_param('submit')) {
$c->forward('check_token');
my $db_update = 0;
- if ( $c->req->param('latitude') != $problem->latitude || $c->req->param('longitude') != $problem->longitude ) {
- $problem->latitude( $c->req->param('latitude') );
- $problem->longitude( $c->req->param('longitude') );
+ if ( $c->get_param('latitude') != $problem->latitude || $c->get_param('longitude') != $problem->longitude ) {
+ $problem->latitude( $c->get_param('latitude') );
+ $problem->longitude( $c->get_param('longitude') );
$db_update = 1;
}
$problem->update if $db_update;
# Add new update from status_update
- if (my $update = $c->req->param('status_update')) {
+ if (my $update = $c->get_param('status_update')) {
FixMyStreet::App->model('DB::Comment')->create( {
text => $update,
user => $c->user->obj,
@@ -625,7 +625,7 @@ sub admin_report_edit {
$c->stash->{status_message} = '<p><em>' . _('Updated!') . '</em></p>';
# If they clicked the no more updates button, we're done.
- if ($c->req->param('no_more_updates')) {
+ if ($c->get_param('no_more_updates')) {
$problem->set_extra_metadata( subdiv_overdue => $self->overdue( $problem ) );
$problem->bodies_str( $body->parent->id );
$problem->whensent( undef );
@@ -712,7 +712,7 @@ sub admin_stats {
my $c = $self->{c};
my %date_params;
- my $ym = $c->req->params->{ym};
+ my $ym = $c->get_param('ym');
my ($m, $y) = $ym ? ($ym =~ /^(\d+)\.(\d+)$/) : ();
$c->stash->{ym} = $ym;
if ($y && $m) {
@@ -726,7 +726,7 @@ sub admin_stats {
state => [ FixMyStreet::DB::Result::Problem->visible_states() ],
);
- if ( $c->req->params->{export} ) {
+ if ( $c->get_param('export') ) {
my $problems = $c->model('DB::Problem')->search(
{%date_params},
{
diff --git a/perllib/FixMyStreet/Map.pm b/perllib/FixMyStreet/Map.pm
index 0fa23d081..b050592ba 100644
--- a/perllib/FixMyStreet/Map.pm
+++ b/perllib/FixMyStreet/Map.pm
@@ -115,9 +115,9 @@ sub _map_features {
sub map_pins {
my ($c, $interval) = @_;
- my $bbox = $c->req->param('bbox');
+ my $bbox = $c->get_param('bbox');
my ( $min_lon, $min_lat, $max_lon, $max_lat ) = split /,/, $bbox;
- my $category = $c->req->param('filter_category');
+ my $category = $c->get_param('filter_category');
$c->forward( '/reports/stash_report_filter_status' );
my $states = $c->stash->{filter_problem_states};
diff --git a/perllib/FixMyStreet/Map/Google.pm b/perllib/FixMyStreet/Map/Google.pm
index 172d2d60e..46823f358 100644
--- a/perllib/FixMyStreet/Map/Google.pm
+++ b/perllib/FixMyStreet/Map/Google.pm
@@ -35,12 +35,12 @@ sub display_map {
$default_zoom = $numZoomLevels - 3 if $dist < 10;
# Map centre may be overridden in the query string
- $params{latitude} = Utils::truncate_coordinate($c->req->params->{lat} + 0)
- if defined $c->req->params->{lat};
- $params{longitude} = Utils::truncate_coordinate($c->req->params->{lon} + 0)
- if defined $c->req->params->{lon};
+ $params{latitude} = Utils::truncate_coordinate($c->get_param('lat') + 0)
+ if defined $c->get_param('lat');
+ $params{longitude} = Utils::truncate_coordinate($c->get_param('lon') + 0)
+ if defined $c->get_param('lon');
- my $zoom = defined $c->req->params->{zoom} ? $c->req->params->{zoom} + 0 : $default_zoom;
+ my $zoom = defined $c->get_param('zoom') ? $c->get_param('zoom') + 0 : $default_zoom;
$zoom = $numZoomLevels - 1 if $zoom >= $numZoomLevels;
$zoom = 0 if $zoom < 0;
$params{zoom_act} = $zoomOffset + $zoom;
diff --git a/perllib/FixMyStreet/Map/OSM.pm b/perllib/FixMyStreet/Map/OSM.pm
index df4b292a8..7d91a9ee7 100644
--- a/perllib/FixMyStreet/Map/OSM.pm
+++ b/perllib/FixMyStreet/Map/OSM.pm
@@ -64,12 +64,12 @@ sub display_map {
$default_zoom = $numZoomLevels - 3 if $dist < 10;
# Map centre may be overridden in the query string
- $params{latitude} = Utils::truncate_coordinate($c->req->params->{lat} + 0)
- if defined $c->req->params->{lat};
- $params{longitude} = Utils::truncate_coordinate($c->req->params->{lon} + 0)
- if defined $c->req->params->{lon};
+ $params{latitude} = Utils::truncate_coordinate($c->get_param('lat') + 0)
+ if defined $c->get_param('lat');
+ $params{longitude} = Utils::truncate_coordinate($c->get_param('lon') + 0)
+ if defined $c->get_param('lon');
- my $zoom = defined $c->req->params->{zoom} ? $c->req->params->{zoom} + 0 : $default_zoom;
+ my $zoom = defined $c->get_param('zoom') ? $c->get_param('zoom') + 0 : $default_zoom;
$zoom = $numZoomLevels - 1 if $zoom >= $numZoomLevels;
$zoom = 0 if $zoom < 0;
$params{zoom_act} = $zoomOffset + $zoom;
@@ -168,7 +168,7 @@ sub click_to_wgs84 {
my ($self, $c, $pin_tile_x, $pin_x, $pin_tile_y, $pin_y) = @_;
my $tile_x = click_to_tile($pin_tile_x, $pin_x);
my $tile_y = click_to_tile($pin_tile_y, $pin_y);
- my $zoom = MIN_ZOOM_LEVEL + (defined $c->req->params->{zoom} ? $c->req->params->{zoom} : 3);
+ my $zoom = MIN_ZOOM_LEVEL + (defined $c->get_param('zoom') ? $c->get_param('zoom') : 3);
my ($lat, $lon) = tile_to_latlon($tile_x, $tile_y, $zoom);
return ( $lat, $lon );
}
diff --git a/perllib/FixMyStreet/Map/Zurich.pm b/perllib/FixMyStreet/Map/Zurich.pm
index d667a4701..9b01f2978 100644
--- a/perllib/FixMyStreet/Map/Zurich.pm
+++ b/perllib/FixMyStreet/Map/Zurich.pm
@@ -45,13 +45,13 @@ sub display_map {
my ($self, $c, %params) = @_;
# Map centre may be overridden in the query string
- $params{latitude} = Utils::truncate_coordinate($c->req->params->{lat} + 0)
- if defined $c->req->params->{lat};
- $params{longitude} = Utils::truncate_coordinate($c->req->params->{lon} + 0)
- if defined $c->req->params->{lon};
+ $params{latitude} = Utils::truncate_coordinate($c->get_param('lat') + 0)
+ if defined $c->get_param('lat');
+ $params{longitude} = Utils::truncate_coordinate($c->get_param('lon') + 0)
+ if defined $c->get_param('lon');
- my $zoom = defined $c->req->params->{zoom}
- ? $c->req->params->{zoom} + 0
+ my $zoom = defined $c->get_param('zoom')
+ ? $c->get_param('zoom') + 0
: $c->stash->{page} eq 'report'
? DEFAULT_ZOOM+1
: DEFAULT_ZOOM;
@@ -159,7 +159,7 @@ sub click_to_wgs84 {
my ($self, $c, $pin_tile_x, $pin_x, $pin_tile_y, $pin_y) = @_;
my $tile_x = click_to_tile($pin_tile_x, $pin_x);
my $tile_y = click_to_tile($pin_tile_y, $pin_y);
- my $zoom = (defined $c->req->params->{zoom} ? $c->req->params->{zoom} : DEFAULT_ZOOM);
+ my $zoom = (defined $c->get_param('zoom') ? $c->get_param('zoom') : DEFAULT_ZOOM);
my ($lat, $lon) = tile_to_latlon($tile_x, $tile_y, $zoom);
return ( $lat, $lon );
}