From 404aa7549c42763f3f7640fdefbf206b137318a1 Mon Sep 17 00:00:00 2001 From: Julian Prieber <60265788+JulianPrieber@users.noreply.github.com> Date: Fri, 17 Nov 2023 17:05:50 +0100 Subject: [PATCH] Added page to report user profiles Sends notification with report to admin email set in env with SMTP server. --- app/Http/Controllers/UserController.php | 16 ++ app/Mail/ReportSubmissionMail.php | 28 +++ resources/lang/en/messages.php | 47 +++++ resources/views/layouts/send-report.blade.php | 76 ++++++++ resources/views/report.blade.php | 180 ++++++++++++++++++ routes/web.php | 3 + 6 files changed, 350 insertions(+) create mode 100644 app/Mail/ReportSubmissionMail.php create mode 100644 resources/views/layouts/send-report.blade.php create mode 100644 resources/views/report.blade.php diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index b3351a3..ab51919 100755 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -11,6 +11,8 @@ use Illuminate\Support\Facades\Response; use JeroenDesloovere\VCard\VCard; use Illuminate\Validation\Rule; use Illuminate\Support\Facades\Validator; +use Illuminate\Support\Facades\Mail; +use App\Mail\ReportSubmissionMail; use Auth; use DB; @@ -1160,6 +1162,20 @@ class UserController extends Controller } + // Hanle reports + function report(Request $request) + { + $formData = $request->all(); + + try { + Mail::to(env('ADMIN_EMAIL'))->send(new ReportSubmissionMail($formData)); + + return redirect('report')->with('success', __('messages.report_success')); + } catch (\Exception $e) { + return redirect()->back()->with('error', __('messages.report_error')); + } + } + //Edit/save page icons public function editIcons(request $request) { diff --git a/app/Mail/ReportSubmissionMail.php b/app/Mail/ReportSubmissionMail.php new file mode 100644 index 0000000..d2c67e3 --- /dev/null +++ b/app/Mail/ReportSubmissionMail.php @@ -0,0 +1,28 @@ +formData = $formData; + } + + public function build() + { + return $this->view('layouts.send-report') + ->subject(__('messages.report_mail_admin_subject')); + } +} \ No newline at end of file diff --git a/resources/lang/en/messages.php b/resources/lang/en/messages.php index 1b40b89..3da9fd8 100644 --- a/resources/lang/en/messages.php +++ b/resources/lang/en/messages.php @@ -1039,6 +1039,53 @@ return [ 'footer.Contact' => 'Contact', + /* + |-------------------------------------------------------------------------- + | Report Page + |-------------------------------------------------------------------------- + | + */ + + 'report_violation' => 'Report a Violation', + 'url_label' => 'URL of the site you are reporting', + 'report_type_label' => 'Type of report', + 'hate_speech' => 'Hate Speech or Harassment', + 'violence_threats' => 'Violence or Threats', + 'illegal_activities' => 'Illegal Activities', + 'copyright_infringement' => 'Copyright Infringement', + 'misinformation_fake_news' => 'Misinformation or Fake News', + 'identity_theft' => 'Identity Theft', + 'drug_related_content' => 'Drug-related Content', + 'weapons_harmful_objects' => 'Weapons or Harmful Objects', + 'child_exploitation' => 'Child Exploitation', + 'fraud_scams' => 'Fraud or Scams', + 'privacy_violation' => 'Privacy Violation', + 'impersonation' => 'Impersonation', + 'other_specify' => 'Other (Specify)', + 'additional_comments_label' => 'Additional comments', + 'submit_button' => 'Submit', + + + 'report_mail_admin_subject' => 'Profile Report', + 'report_mail_admin_report' => 'A Profile has been reported', + + 'report_mail_reported_profile' => 'Reported Profile', + 'report_mail_reported_url' => 'Reported URL', + 'report_mail_type' => 'Type', + 'report_mail_message' => 'Message', + + 'report_mail_report_submitted_by' => 'Report submitted by', + 'report_mail_reported_by' => 'Reported by', + 'report_mail_profile' => 'Profile', + + 'report_mail_button_profile' => 'View on Users Page', + 'report_mail_button_delete' => 'Delete Reported User', + + + 'report_error' => 'Profile could not be reported', + 'report_success' => 'Profile has been reported successfully', + + #=============================================================================# # Laravel internal translations # #=============================================================================# diff --git a/resources/views/layouts/send-report.blade.php b/resources/views/layouts/send-report.blade.php new file mode 100644 index 0000000..a8428e0 --- /dev/null +++ b/resources/views/layouts/send-report.blade.php @@ -0,0 +1,76 @@ + + +
+ + + + + + +