aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/App/Controller')
-rw-r--r--perllib/FixMyStreet/App/Controller/Location.pm25
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm7
2 files changed, 32 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Location.pm b/perllib/FixMyStreet/App/Controller/Location.pm
index 416fb942a..3869ef8d3 100644
--- a/perllib/FixMyStreet/App/Controller/Location.pm
+++ b/perllib/FixMyStreet/App/Controller/Location.pm
@@ -6,6 +6,7 @@ BEGIN {extends 'Catalyst::Controller'; }
use Encode;
use FixMyStreet::Geocode;
+use Geo::OLC;
use Try::Tiny;
use Utils;
@@ -74,6 +75,30 @@ sub determine_location_from_pc : Private {
map { Utils::truncate_coordinate($_) } ($1, $2);
return $c->forward( 'check_location' );
}
+
+ if (Geo::OLC::is_full($pc)) {
+ my $ref = Geo::OLC::decode($pc);
+ ($c->stash->{latitude}, $c->stash->{longitude}) =
+ map { Utils::truncate_coordinate($_) } @{$ref->{center}};
+ return $c->forward( 'check_location' );
+ }
+
+ if ($pc =~ /^\s*([2-9CFGHJMPQRVWX]{4,6}\+[2-9CFGHJMPQRVWX]{2,3})\s+(.*)$/i) {
+ my ($code, $rest) = ($1, $2);
+ my ($lat, $lon, $error) = FixMyStreet::Geocode::lookup($rest, $c);
+ if (ref($error) eq 'ARRAY') { # Just take the first result
+ $lat = $error->[0]{latitude};
+ $lon = $error->[0]{longitude};
+ }
+ if (defined $lat && defined $lon) {
+ $code = Geo::OLC::recover_nearest($code, $lat, $lon);
+ my $ref = Geo::OLC::decode($code);
+ ($c->stash->{latitude}, $c->stash->{longitude}) =
+ map { Utils::truncate_coordinate($_) } @{$ref->{center}};
+ return $c->forward( 'check_location' );
+ }
+ }
+
if ( $c->cobrand->country eq 'GB' && $pc =~ /^([A-Z])([A-Z])([\d\s]{4,})$/i) {
if (my $convert = gridref_to_latlon( $1, $2, $3 )) {
($c->stash->{latitude}, $c->stash->{longitude}) =
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index c5d20a5da..8ffba3dcf 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -484,6 +484,13 @@ sub save_update : Private {
$update->confirm();
} elsif ($c->stash->{contributing_as_anonymous_user}) {
$update->set_extra_metadata( contributed_as => 'anonymous_user' );
+ if ( $c->user_exists && $c->user->from_body ) {
+ # If a staff user has clicked the 'report anonymously' button then
+ # there would be no record of who that staff member was as we've
+ # used the cobrand's anonymous_account for the report. In this case
+ # record the staff user ID in the report metadata.
+ $update->set_extra_metadata( contributed_by => $c->user->id );
+ }
$update->confirm();
} elsif ( !$update->user->in_storage ) {
# User does not exist.