Pārlūkot izejas kodu

Update AdminUserController, add moderation method

Daniel Supernault 5 gadi atpakaļ
vecāks
revīzija
a4cf21eaad
1 mainītis faili ar 34 papildinājumiem un 0 dzēšanām
  1. 34 0
      app/Http/Controllers/Admin/AdminUserController.php

+ 34 - 0
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);
+	}
 }