From a4cf21eaad29cce20a9f78d7ff83f4711d217b59 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Wed, 19 Feb 2020 20:45:11 -0700 Subject: [PATCH] Update AdminUserController, add moderation method --- .../Controllers/Admin/AdminUserController.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/app/Http/Controllers/Admin/AdminUserController.php b/app/Http/Controllers/Admin/AdminUserController.php index bde92e319..8cefa79ee 100644 --- a/app/Http/Controllers/Admin/AdminUserController.php +++ b/app/Http/Controllers/Admin/AdminUserController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin; use Cache, DB; use Illuminate\Http\Request; use App\ModLog; +use App\Profile; use App\User; use App\Mail\AdminMessage; use Illuminate\Support\Facades\Mail; @@ -155,4 +156,37 @@ trait AdminUserController $profile = $user->profile; return view('admin.users.delete', compact('user', 'profile')); } + + public function userModerate(Request $request) + { + $this->validate($request, [ + 'profile_id' => 'required|exists:profiles,id', + 'action' => 'required|in:cw,no_autolink,unlisted' + ]); + + $pid = $request->input('profile_id'); + $action = $request->input('action'); + $profile = Profile::findOrFail($pid); + + switch ($action) { + case 'cw': + $profile->cw = true; + $msg = "Successfully added Content Warnings to {$profile->username}'s future posts!"; + break; + + case 'no_autolink': + $profile->no_autolink = true; + $msg = "Successfully applied No Autolinking to {$profile->username}'s future posts!"; + break; + + case 'unlisted': + $profile->unlisted = true; + $msg = "Successfully applied Unlisted scope to {$profile->username}'s future posts!"; + break; + } + + $profile->save(); + $request->session()->flash('status', $msg); + return redirect('/i/admin/users/show/' . $profile->user_id); + } } \ No newline at end of file