aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Admin.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-07-20 11:29:58 +0100
committerMatthew Somerville <matthew@mysociety.org>2011-08-09 18:32:04 +0100
commite767b9fc4beb8fa3cb33e40a2dfe779e9ccef1d4 (patch)
treee50d5b7d31bcf3355b39c5b1e7bbac4f5f834a23 /perllib/FixMyStreet/App/Controller/Admin.pm
parent06d5c56d4ae1882e973b14199cf5d3063980823a (diff)
add remove user flag button to report and update edit pages
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Admin.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm38
1 files changed, 37 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index ed7fc7ce8..fcdc351ce 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -520,6 +520,11 @@ sub report_edit : Path('report_edit') : Args(1) {
}
elsif ( $c->req->param('flaguser') ) {
$c->forward('flag_user');
+ $c->stash->{problem}->discard_changes;
+ }
+ elsif ( $c->req->param('removeuserflag') ) {
+ $c->forward('remove_user_flag');
+ $c->stash->{problem}->discard_changes;
}
elsif ( $c->req->param('banuser') ) {
$c->forward('ban_user');
@@ -637,6 +642,11 @@ sub update_edit : Path('update_edit') : Args(1) {
}
elsif ( $c->req->param('flaguser') ) {
$c->forward('flag_user');
+ $c->stash->{update}->discard_changes;
+ }
+ elsif ( $c->req->param('removeuserflag') ) {
+ $c->forward('remove_user_flag');
+ $c->stash->{update}->discard_changes;
}
elsif ( $c->req->param('submit') ) {
$c->forward('check_token');
@@ -871,7 +881,7 @@ sub ban_user : Private {
=head2 flag_user
-Sets the flag on a user with the give email
+Sets the flag on a user with the given email
=cut
@@ -897,6 +907,32 @@ sub flag_user : Private {
return 1;
}
+=head2 remove_user_flag
+
+Remove the flag on a user with the given email
+
+=cut
+
+sub remove_user_flag : Private {
+ my ( $self, $c ) = @_;
+
+ my $email = $c->req->param('email');
+
+ return unless $email;
+
+ my $user = $c->model('DB::User')->find({ email => $email });
+
+ if ( !$user ) {
+ $c->stash->{status_message} = _('Could not find user');
+ } else {
+ $user->flagged(0);
+ $user->update;
+ $c->stash->{status_message} = _('User flag removed');
+ }
+
+ return 1;
+}
+
=head2 check_email_for_abuse