aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet')
-rw-r--r--perllib/FixMyStreet/DB/Result/Comment.pm20
-rw-r--r--perllib/FixMyStreet/Map/Bing.pm10
-rw-r--r--perllib/FixMyStreet/Map/OSM.pm4
3 files changed, 24 insertions, 10 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm
index c876f3459..2ef8925e6 100644
--- a/perllib/FixMyStreet/DB/Result/Comment.pm
+++ b/perllib/FixMyStreet/DB/Result/Comment.pm
@@ -145,6 +145,26 @@ sub FOREIGNBUILDARGS {
return $opts;
};
+=head2 around user
+
+Also make sure we catch the setting of a user on an object at a time other than
+object creation, to set the extra field needed.
+
+=cut
+
+around user => sub {
+ my ( $orig, $self ) = ( shift, shift );
+ my $res = $self->$orig(@_);
+ if (@_) {
+ if ($_[0]->is_superuser) {
+ $self->set_extra_metadata( is_superuser => 1 );
+ } elsif (my $body = $_[0]->from_body) {
+ $self->set_extra_metadata( is_body_user => $body->id );
+ }
+ }
+ return $res;
+};
+
=head2 get_cobrand_logged
Get a cobrand object for the cobrand the update was made on.
diff --git a/perllib/FixMyStreet/Map/Bing.pm b/perllib/FixMyStreet/Map/Bing.pm
index 723dcd6dc..17bdc3a53 100644
--- a/perllib/FixMyStreet/Map/Bing.pm
+++ b/perllib/FixMyStreet/Map/Bing.pm
@@ -8,8 +8,6 @@ use strict;
sub map_type { '' }
-sub map_template { 'bing' }
-
sub map_javascript { [
'/vendor/OpenLayers/OpenLayers.fixmystreet.js',
'/js/map-OpenLayers.js',
@@ -31,14 +29,6 @@ sub get_quadkey {
return $key;
}
-sub display_map {
- my ($self, $c, %params) = @_;
-
- $params{aerial} = $c->get_param("aerial") ? 1 : 0;
-
- $self->SUPER::display_map($c, %params);
-}
-
my $road_base = '//%s.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/%s?mkt=en-US&it=G,L&src=t&shading=hill&og=969&n=z';
my $aerial_base = '//%s.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/%s?mkt=en-US&it=A,G,L&src=t&og=969&n=z';
diff --git a/perllib/FixMyStreet/Map/OSM.pm b/perllib/FixMyStreet/Map/OSM.pm
index 417fdca0b..47c1c8535 100644
--- a/perllib/FixMyStreet/Map/OSM.pm
+++ b/perllib/FixMyStreet/Map/OSM.pm
@@ -21,11 +21,13 @@ sub map_template { 'osm' }
sub map_javascript { [
'/vendor/OpenLayers/OpenLayers.wfs.js',
'/js/map-OpenLayers.js',
+ FixMyStreet->config('BING_MAPS_API_KEY') ? ('/js/map-bing-ol.js') : (),
'/js/map-OpenStreetMap.js',
] }
sub map_tiles {
my ( $self, %params ) = @_;
+ return FixMyStreet::Map::Bing->map_tiles(%params) if $params{aerial};
my ( $x, $y, $z ) = ( $params{x_tile}, $params{y_tile}, $params{zoom_act} );
my $tile_url = $self->base_tile_url();
return [
@@ -59,6 +61,8 @@ sub display_map {
if defined $c->get_param('lon');
$params{zoomToBounds} = $params{any_zoom} && !defined $c->get_param('zoom');
+ $params{aerial} = $c->get_param("aerial") && FixMyStreet->config('BING_MAPS_API_KEY') ? 1 : 0;
+
my %data;
$data{cobrand} = $c->cobrand;
$data{distance} = $c->stash->{distance};