Update AdminUserController modtools

This commit is contained in:
Daniel Supernault 2020-02-19 21:15:49 -07:00
parent a4cf21eaad
commit a7adfb9457
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
3 changed files with 112 additions and 110 deletions

View file

@ -168,25 +168,44 @@ trait AdminUserController
$action = $request->input('action'); $action = $request->input('action');
$profile = Profile::findOrFail($pid); $profile = Profile::findOrFail($pid);
if($profile->user->is_admin == true) {
$mid = $request->user()->id;
abort_if($profile->user_id < $mid, 403);
}
switch ($action) { switch ($action) {
case 'cw': case 'cw':
$profile->cw = true; $profile->cw = !$profile->cw;
$msg = "Successfully added Content Warnings to {$profile->username}'s future posts!"; $msg = "Success!";
break; break;
case 'no_autolink': case 'no_autolink':
$profile->no_autolink = true; $profile->no_autolink = !$profile->no_autolink;
$msg = "Successfully applied No Autolinking to {$profile->username}'s future posts!"; $msg = "Success!";
break; break;
case 'unlisted': case 'unlisted':
$profile->unlisted = true; $profile->unlisted = !$profile->unlisted;
$msg = "Successfully applied Unlisted scope to {$profile->username}'s future posts!"; $msg = "Success!";
break; break;
} }
$profile->save(); $profile->save();
ModLogService::boot()
->objectUid($profile->user_id)
->objectId($profile->user_id)
->objectType('App\User::class')
->user($request->user())
->action('admin.user.moderate')
->metadata([
'action' => $action,
'message' => $msg
])
->accessLevel('admin')
->save();
$request->session()->flash('status', $msg); $request->session()->flash('status', $msg);
return redirect('/i/admin/users/show/' . $profile->user_id); return redirect('/i/admin/users/modtools/' . $profile->user_id);
} }
} }

View file

@ -54,53 +54,36 @@
<div class="col-12 col-md-6"> <div class="col-12 col-md-6">
<form method="post" action="/i/admin/users/moderation/update" class="pb-3"> <form method="post" action="/i/admin/users/moderation/update" class="pb-3">
@csrf @csrf
<input type="hidden" name="action" value="cw">
<input type="hidden" name="profile_id" value="{{$profile->id}}"> <input type="hidden" name="profile_id" value="{{$profile->id}}">
<button class="btn btn-outline-primary py-0 font-weight-bold">Enforce CW</button> <button class="btn btn-outline-{{$profile->cw ? 'secondary' : 'primary'}} py-0 font-weight-bold">
{{$profile->cw ? 'Remove CW Enforcement' : 'Enforce CW'}}
</button>
<p class="help-text text-muted font-weight-bold small">Adds a CW to every post made by this account.</p> <p class="help-text text-muted font-weight-bold small">Adds a CW to every post made by this account.</p>
</form> </form>
</div> </div>
<div class="col-12 col-md-6"> <div class="col-12 col-md-6">
<form method="post" action="/i/admin/users/moderation/update" class="pb-3"> <form method="post" action="/i/admin/users/moderation/update" class="pb-3">
@csrf @csrf
<input type="hidden" name="action" value="unlisted">
<input type="hidden" name="profile_id" value="{{$profile->id}}"> <input type="hidden" name="profile_id" value="{{$profile->id}}">
<button class="btn btn-outline-primary py-0 font-weight-bold">Unlisted Posts</button> <button class="btn btn-outline-{{$profile->unlisted ? 'secondary' : 'primary'}} py-0 font-weight-bold">
{{$profile->unlisted ? 'Remove Unlisting' : 'Unlisted Posts'}}
</button>
<p class="help-text text-muted font-weight-bold small">Removes account from public/network timelines.</p> <p class="help-text text-muted font-weight-bold small">Removes account from public/network timelines.</p>
</form> </form>
</div> </div>
<div class="col-12 col-md-6"> <div class="col-12 col-md-6">
<form method="post" action="/i/admin/users/moderation/update" class="pb-3"> <form method="post" action="/i/admin/users/moderation/update" class="pb-3">
@csrf @csrf
<input type="hidden" name="action" value="no_autolink">
<input type="hidden" name="profile_id" value="{{$profile->id}}"> <input type="hidden" name="profile_id" value="{{$profile->id}}">
<button class="btn btn-outline-primary py-0 font-weight-bold">No Autolinking</button> <button class="btn btn-outline-{{$profile->no_autolink ? 'secondary' : 'primary'}} py-0 font-weight-bold">
{{$profile->no_autolink ? 'Remove No Autolinking' : 'No Autolinking'}}
</button>
<p class="help-text text-muted font-weight-bold small">Do not transform mentions, hashtags or urls into HTML.</p> <p class="help-text text-muted font-weight-bold small">Do not transform mentions, hashtags or urls into HTML.</p>
</form> </form>
</div> </div>
<div class="col-12 col-md-6">
<form method="post" action="/i/admin/users/moderation/update" class="pb-3">
@csrf
<input type="hidden" name="profile_id" value="{{$profile->id}}">
<button class="btn btn-outline-primary py-0 font-weight-bold">Disable Account</button>
<p class="help-text text-muted font-weight-bold small">Temporarily disable account until next time user log in.</p>
</form>
</div>
<div class="col-12 col-md-6">
<form method="post" action="/i/admin/users/moderation/update" class="pb-3">
@csrf
<input type="hidden" name="profile_id" value="{{$profile->id}}">
<button class="btn btn-outline-primary py-0 font-weight-bold">Suspend Account</button>
<p class="help-text text-muted font-weight-bold small">This prevents any new interactions, without deleting existing data.</p>
</form>
</div>
<div class="col-12 col-md-6">
<form method="post" action="/i/admin/users/moderation/update" class="pb-3">
@csrf
<input type="hidden" name="profile_id" value="{{$profile->id}}">
<button class="btn btn-outline-danger py-0 font-weight-bold">Lock down Account</button>
<p class="help-text text-muted font-weight-bold small">This disables the account and changes the password, forcing account to reset password via verified email.</p>
</form>
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -42,9 +42,9 @@
</a> </a>
</div> </div>
</div> </div>
</span>
</div> </div>
<hr> <hr>
<div class="row mb-3"> <div class="row mb-3">
<div class="col-12 col-md-4"> <div class="col-12 col-md-4">
<div class="card shadow-none border"> <div class="card shadow-none border">