diff options
author | Zarino Zappia <mail@zarino.co.uk> | 2019-08-20 11:16:53 +0100 |
---|---|---|
committer | Zarino Zappia <mail@zarino.co.uk> | 2019-08-23 10:38:29 +0100 |
commit | 3c4d48f5fd5f499736f07ac2a5d17c1d4bab6c14 (patch) | |
tree | 59df44c764e803c679c01f17296a01fdb7813619 /perllib/FixMyStreet/App/Controller/Contact.pm | |
parent | 169c8960d9c32e35f5a2603c611857757d8b1044 (diff) |
Include user admin links in contact form emails
If a message is sent via the contact form, with a stated email address
matching a user in the database, the resulting email will now include
quick links to:
- Admin page for editing the user
- Admin page for viewing the user’s reports
And if the user has made at least one report, also:
- Admin page for the user’s most recent report
This should speed up admin email triage considerably.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Contact.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Contact.pm | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Contact.pm b/perllib/FixMyStreet/App/Controller/Contact.pm index e2b76ca60..90ea18ca2 100644 --- a/perllib/FixMyStreet/App/Controller/Contact.pm +++ b/perllib/FixMyStreet/App/Controller/Contact.pm @@ -197,6 +197,21 @@ sub prepare_params_for_email : Private { my $base_url = $c->cobrand->base_url(); my $admin_url = $c->cobrand->admin_base_url; + my $user = $c->cobrand->users->find( { email => $c->stash->{em} } ); + if ( $user ) { + $c->stash->{user_admin_url} = $admin_url . '/users/' . $user->id; + $c->stash->{user_reports_admin_url} = $admin_url . '/reports?search=' . $user->email; + + my $user_latest_problem = $user->problems->search({ + state => [ FixMyStreet::DB::Result::Problem->visible_states() ] + }, { + order_by => { -desc => 'id' } + })->single; + if ( $user_latest_problem) { + $c->stash->{user_latest_report_admin_url} = $admin_url . '/report_edit/' . $user_latest_problem->id; + } + } + if ( $c->stash->{update} ) { $c->stash->{problem_url} = $base_url . $c->stash->{update}->url; |