package FixMyStreet::Cobrand::TfL; use parent 'FixMyStreet::Cobrand::Whitelabel'; use strict; use warnings; use POSIX qw(strcoll); use FixMyStreet::MapIt; sub council_area_id { return [ 2511, 2489, 2494, 2488, 2482, 2505, 2512, 2481, 2484, 2495, 2493, 2508, 2502, 2509, 2487, 2485, 2486, 2483, 2507, 2503, 2480, 2490, 2492, 2500, 2510, 2497, 2499, 2491, 2498, 2506, 2496, 2501, 2504 ]; } sub council_area { return 'TfL'; } sub council_name { return 'TfL'; } sub council_url { return 'tfl'; } sub area_types { [ 'LBO' ] } sub is_council { 0 } sub send_questionnaires { 0 } sub area_check { my ( $self, $params, $context ) = @_; my $councils = $params->{all_areas}; my $council_match = grep { $councils->{$_} } @{ $self->council_area_id }; return 1 if $council_match; return ( 0, $self->area_check_error_message($params, $context) ); } sub enter_postcode_text { my ($self) = @_; return 'Enter a London postcode, or street name and area'; } sub privacy_policy_url { 'https://tfl.gov.uk/corporate/privacy-and-cookies/reporting-street-problems' } sub about_hook { my $self = shift; my $c = $self->{c}; if ($c->stash->{template} eq 'about/privacy.html') { $c->res->redirect($self->privacy_policy_url); $c->detach; } } sub body { # Overridden because UKCouncils::body excludes TfL FixMyStreet::DB->resultset('Body')->search({ name => 'TfL' })->first; } # These need to be overridden so the method in UKCouncils doesn't create # a fixmystreet.com link (because of the false-returning owns_problem call) sub relative_url_for_report { "" } sub base_url_for_report { my $self = shift; return $self->base_url; } sub categories_restriction { my ($self, $rs) = @_; return $rs->search( { 'body.name' => 'TfL' } ); } sub lookup_by_ref_regex { return qr/^\s*((?:FMS\s*)?\d+)\s*$/i; } sub lookup_by_ref { my ($self, $ref) = @_; if ( $ref =~ s/^\s*FMS\s*//i ) { return { 'id' => $ref }; } return 0; } sub report_sent_confirmation_email { 'id' } sub report_age { '6 weeks' } sub password_expiry { return if FixMyStreet->test_mode; # uncoverable statement 86400 * 365 } sub pin_colour { my ( $self, $p, $context ) = @_; return 'green' if $p->is_closed; return 'green' if $p->is_fixed; return 'red' if $p->state eq 'confirmed'; return 'orange'; # all the other `open_states` like "in progress" } sub admin_allow_user { my ( $self, $user ) = @_; return 1 if $user->is_superuser; return undef unless defined $user->from_body; return $user->from_body->name eq 'TfL'; } sub fetch_area_children { my $self = shift; my $areas = FixMyStreet::MapIt::call('areas', $self->area_types); foreach (keys %$areas) { $areas->{$_}->{name} =~ s/\s*(Borough|City|District|County) Council$//; } return $areas; } 1;