diff options
Diffstat (limited to 'perllib/FixMyStreet/Cobrand/Default.pm')
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 87 |
1 files changed, 23 insertions, 64 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index c6ca5c56b..816c5e315 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -5,6 +5,7 @@ use strict; use warnings; use FixMyStreet; use FixMyStreet::DB; +use FixMyStreet::Geocode::Address; use FixMyStreet::Geocode::Bing; use DateTime; use List::MoreUtils 'none'; @@ -514,34 +515,32 @@ sub geocoded_string_check { return 1; } =item find_closest Used by send-reports and similar to attach nearest things to the bottom of the -report. +report. This can be called with either a hash of lat/lon or a Problem. =cut sub find_closest { - my ( $self, $problem, $as_data ) = @_; + my ($self, $data) = @_; + $data = { problem => $data } if ref $data ne 'HASH'; + + my $problem = $data->{problem}; + my $lat = $problem ? $problem->latitude : $data->{latitude}; + my $lon = $problem ? $problem->longitude : $data->{longitude}; + my $j = $problem->geocode if $problem; - my $j = $problem->geocode; if (!$j) { - $j = FixMyStreet::Geocode::Bing::reverse( $problem->latitude, $problem->longitude, + $j = FixMyStreet::Geocode::Bing::reverse( $lat, $lon, disambiguate_location()->{bing_culture} ); - # cache the bing results for use in alerts - $problem->geocode( $j ); - $problem->update; - } - - my $data = $as_data ? {} : ''; - if ($j && $j->{resourceSets}[0]{resources}[0]{name}) { - my $str = $j->{resourceSets}[0]{resources}[0]{name}; - if ($as_data) { - $data->{road} = $str; - } else { - $data .= sprintf(_("Nearest road to the pin placed on the map (automatically generated by Bing Maps): %s"), - $str) . "\n\n"; + if ($problem) { + # cache the bing results for use in alerts + $problem->geocode( $j ); + $problem->update; } } - return $data; + return FixMyStreet::Geocode::Address->new($j->{resourceSets}[0]{resources}[0]) + if $j && $j->{resourceSets}[0]{resources}[0]{name}; + return {}; } =item find_closest_address_for_rss @@ -645,6 +644,7 @@ sub admin_pages { $pages->{flagged} = [ _('Flagged'), 7 ]; $pages->{states} = [ _('States'), 8 ]; $pages->{config} = [ _('Configuration'), 9]; + $pages->{user_import} = [ undef, undef ]; }; # And some that need special permissions if ( $user->has_body_permission_to('category_edit') ) { @@ -667,6 +667,7 @@ sub admin_pages { $pages->{responsepriority_edit} = [ undef, undef ]; }; if ( $user->has_body_permission_to('user_edit') ) { + $pages->{reports} = [ _('Reports'), 2 ]; $pages->{users} = [ _('Users'), 6 ]; $pages->{user_edit} = [ undef, undef ]; } @@ -727,7 +728,7 @@ sub available_permissions { # trusted => _("Trusted to make reports that don't need to be inspected"), }, _("Users") => { - user_edit => _("Edit other users' details"), + user_edit => _("Edit users' details/search for their reports"), user_manage_permissions => _("Edit other users' permissions"), user_assign_body => _("Grant access to the admin"), user_assign_areas => _("Assign users to areas"), # future use @@ -1067,6 +1068,8 @@ sub show_unconfirmed_reports { 0; } +sub default_problem_state { 'unconfirmed' } + sub state_groups_admin { my $rs = FixMyStreet::DB->resultset("State"); my @fixed = FixMyStreet::DB::Result::Problem->fixed_states; @@ -1159,50 +1162,6 @@ sub jurisdiction_id_example { return $self->moniker; } -=item body_details_data - -Returns a list of bodies to create with ensure_body. These -are mostly just passed to ->find_or_create, but there is some -pre-processing so that you can enter: - - area_id => 123, - parent => 'Big Town', - -instead of - - body_areas => [ { area_id => 123 } ], - parent => { name => 'Big Town' }, - -For example: - - return ( - { - name => 'Big Town', - }, - { - name => 'Small town', - parent => 'Big Town', - area_id => 1234, - }, - - -=cut - -sub body_details_data { - return (); -} - -=item contact_details_data - -Returns a list of contact_data to create with setup_contacts. -See Zurich for an example. - -=cut - -sub contact_details_data { - return () -} - =item lookup_by_ref_regex Returns a regex to match postcode form input against to determine if a lookup @@ -1221,7 +1180,7 @@ Return true if an Open311 service attribute should be a hidden field. sub category_extra_hidden { my ($self, $meta) = @_; - return 0; + return 0; } =item reputation_increment_states/reputation_decrement_states |