aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Admin.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-06-10 13:27:17 +0100
committerMatthew Somerville <matthew@mysociety.org>2011-08-09 18:32:03 +0100
commitc7efa9f49a3aa1744fd12d00ba409734ec217b1a (patch)
tree561cc02bb4cf7f87eaa2c4943b11ea132aaaea15 /perllib/FixMyStreet/App/Controller/Admin.pm
parent4cdf8b0c15052fd06d811137dda52e3bac65028e (diff)
add a ban email address button
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Admin.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm46
1 files changed, 41 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index 3854e27aa..dc85b909a 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -499,6 +499,7 @@ sub report_edit : Path('report_edit') : Args(1) {
$c->forward('get_token');
$c->forward('check_page_allowed');
+ $c->forward('check_email_for_abuse', [ $problem->user->email ] );
$c->stash->{updates} =
[ $c->model('DB::Comment')
@@ -515,6 +516,9 @@ sub report_edit : Path('report_edit') : Args(1) {
$c->forward( 'log_edit', [ $id, 'problem', 'resend' ] );
}
+ elsif ( $c->req->param('banuser') ) {
+ $c->forward('ban_user');
+ }
elsif ( $c->req->param('submit') ) {
$c->forward('check_token');
@@ -688,6 +692,25 @@ sub log_edit : Private {
)->insert();
}
+sub ban_user : Private {
+ my ( $self, $c ) = @_;
+
+ my $email = $c->req->param('email');
+
+ my $abuse = $c->model('DB::Abuse')->find_or_new({ email => $email });
+
+ if ( $abuse->in_storage ) {
+ $c->stash->{status_message} = _('Email already in abuse list');
+ } else {
+ $abuse->insert;
+ $c->stash->{status_message} = _('Email added to abuse list');
+ }
+
+ $c->stash->{email_in_abuse} = 1;
+
+ return 1;
+}
+
sub update_edit : Path('update_edit') : Args(1) {
my ( $self, $c, $id ) = @_;
@@ -709,8 +732,12 @@ sub update_edit : Path('update_edit') : Args(1) {
$c->stash->{update} = $update;
- my $status_message = '';
- if ( $c->req->param('submit') ) {
+ $c->forward('check_email_for_abuse', [ $update->user->email ] );
+
+ if ( $c->req->param('banuser') ) {
+ $c->forward('ban_user');
+ }
+ elsif ( $c->req->param('submit') ) {
$c->forward('check_token');
my $old_state = $update->state;
@@ -752,7 +779,7 @@ sub update_edit : Path('update_edit') : Args(1) {
$update->update;
- $status_message = '<p><em>' . _('Updated!') . '</em></p>';
+ $c->stash->{status_message} = '<p><em>' . _('Updated!') . '</em></p>';
# If we're hiding an update, see if it marked as fixed and unfix if so
if ( $new_state eq 'hidden' && $update->mark_fixed ) {
@@ -761,7 +788,7 @@ sub update_edit : Path('update_edit') : Args(1) {
$update->problem->update;
}
- $status_message .=
+ $c->stash->{status_message} .=
'<p><em>' . _('Problem marked as open.') . '</em></p>';
}
@@ -775,7 +802,16 @@ sub update_edit : Path('update_edit') : Args(1) {
}
}
- $c->stash->{status_message} = $status_message;
+
+ return 1;
+}
+
+sub check_email_for_abuse : Private {
+ my ( $self, $c, $email ) =@_;
+
+ my $is_abuse = $c->model('DB::Abuse')->find({ email => $email });
+
+ $c->stash->{email_in_abuse} = 1 if $is_abuse;
return 1;
}