diff options
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Admin.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index e2547019b..4973b7c4e 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -130,6 +130,8 @@ sub index : Path : Args(0) { $c->stash->{categories} = $c->cobrand->problems->categories_summary(); + $c->stash->{total_bodies} = $c->model('DB::Body')->count(); + return 1; } @@ -234,6 +236,7 @@ sub bodies : Path('bodies') : Args(0) { my $posted = $c->req->param('posted') || ''; if ( $posted eq 'body' ) { + $c->forward('check_for_super_user'); $c->forward('check_token'); my $params = $c->forward('body_params'); @@ -296,6 +299,7 @@ sub body : Path('body') : Args(1) { $c->stash->{body_id} = $body_id; + $c->forward( 'check_for_super_user' ); $c->forward( 'get_token' ); $c->forward( 'lookup_body' ); $c->forward( 'fetch_all_bodies' ); @@ -311,6 +315,13 @@ sub body : Path('body') : Args(1) { return 1; } +sub check_for_super_user : Private { + my ( $self, $c ) = @_; + if ( $c->cobrand->moniker eq 'zurich' && $c->stash->{admin_type} ne 'super' ) { + $c->detach('/page_error_404_not_found', []); + } +} + sub update_contacts : Private { my ( $self, $c ) = @_; @@ -377,6 +388,7 @@ sub update_contacts : Private { $c->stash->{updated} = _('Values updated'); } elsif ( $posted eq 'body' ) { + $c->forward('check_for_super_user'); $c->forward('check_token'); my $params = $c->forward( 'body_params' ); @@ -401,7 +413,7 @@ sub update_contacts : Private { sub body_params : Private { my ( $self, $c ) = @_; - my @fields = qw/name endpoint jurisdiction api_key send_method send_comments suppress_alerts send_extended_statuses comment_user_id can_be_devolved parent/; + my @fields = qw/name endpoint jurisdiction api_key send_method send_comments suppress_alerts send_extended_statuses comment_user_id can_be_devolved parent deleted/; my %defaults = map { $_ => '' } @fields; %defaults = ( %defaults, send_comments => 0, @@ -410,6 +422,7 @@ sub body_params : Private { send_extended_statuses => 0, can_be_devolved => 0, parent => undef, + deleted => 0, ); my %params = map { $_ => $c->req->param($_) || $defaults{$_} } @fields; return \%params; @@ -420,6 +433,7 @@ sub display_contacts : Private { my $contacts = $c->stash->{body}->contacts->search(undef, { order_by => [ 'category' ] } ); $c->stash->{contacts} = $contacts; + $c->stash->{live_contacts} = $contacts->search({ deleted => 0 }); if ( $c->req->param('text') && $c->req->param('text') == 1 ) { $c->stash->{template} = 'admin/council_contacts.txt'; @@ -1014,8 +1028,20 @@ sub flagged : Path('flagged') : Args(0) { $c->stash->{problems} = [ $problems->all ]; my $users = $c->model('DB::User')->search( { flagged => 1 } ); + my @users = $users->all; + my %email2user = map { $_->email => $_ } @users; + $c->stash->{users} = [ @users ]; - $c->stash->{users} = $users; + my @abuser_emails = $c->model('DB::Abuse')->all(); + + foreach my $email (@abuser_emails) { + # Slight abuse of the boolean flagged value + if ($email2user{$email->email}) { + $email2user{$email->email}->flagged( 2 ); + } else { + push @{$c->stash->{users}}, { email => $email->email, flagged => 2 }; + } + } return 1; } |