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');
$profile = Profile::findOrFail($pid);
if($profile->user->is_admin == true) {
$mid = $request->user()->id;
abort_if($profile->user_id < $mid, 403);
}
switch ($action) {
case 'cw':
$profile->cw = true;
$msg = "Successfully added Content Warnings to {$profile->username}'s future posts!";
$profile->cw = !$profile->cw;
$msg = "Success!";
break;
case 'no_autolink':
$profile->no_autolink = true;
$msg = "Successfully applied No Autolinking to {$profile->username}'s future posts!";
$profile->no_autolink = !$profile->no_autolink;
$msg = "Success!";
break;
case 'unlisted':
$profile->unlisted = true;
$msg = "Successfully applied Unlisted scope to {$profile->username}'s future posts!";
$profile->unlisted = !$profile->unlisted;
$msg = "Success!";
break;
}
$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);
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">
<form method="post" action="/i/admin/users/moderation/update" class="pb-3">
@csrf
<input type="hidden" name="action" value="cw">
<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>
</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="action" value="unlisted">
<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>
</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="action" value="no_autolink">
<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>
</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">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>

View file

@ -42,80 +42,80 @@
</a>
</div>
</div>
</div>
<hr>
<div class="row mb-3">
<div class="col-12 col-md-4">
<div class="card shadow-none border">
<div class="card-body text-center">
<img src="{{$profile->avatarUrl()}}" class="box-shadow rounded-circle" width="128px" height="128px">
<p class="mt-3 mb-0 lead">
<span class="font-weight-bold">{{$profile->name}}</span>
</p>
@if($user->is_admin == true)
<p class="mb-0">
<span class="badge badge-danger badge-sm">ADMIN</span>
</p>
@endif
<p class="mb-0 text-center text-muted">
Joined {{$profile->created_at->diffForHumans()}}
</p>
</div>
<table class="table mb-0">
<tbody>
<tr>
<th scope="row" class="font-weight-bold text-muted text-uppercase pl-3 small" style="line-height: 2;">bookmarks</th>
<td class="text-right font-weight-bold">{{$profile->bookmarks()->count()}}</td>
</tr>
<tr>
<th scope="row" class="font-weight-bold text-muted text-uppercase pl-3 small" style="line-height: 2;">collections</th>
<td class="text-right font-weight-bold">{{$profile->collections()->count()}}</td>
</tr>
<tr>
<th scope="row" class="font-weight-bold text-muted text-uppercase pl-3 small" style="line-height: 2;">likes</th>
<td class="text-right font-weight-bold">{{$profile->likes()->count()}}</td>
</tr>
<tr>
<th scope="row" class="font-weight-bold text-muted text-uppercase pl-3 small" style="line-height: 2;">reports</th>
<td class="text-right font-weight-bold">{{$profile->reports()->count()}}</td>
</tr>
<tr>
<th scope="row" class="font-weight-bold text-muted text-uppercase pl-3 small" style="line-height: 2;">reported</th>
<td class="text-right font-weight-bold">{{$profile->reported()->count()}}</td>
</tr>
<tr>
<th scope="row" class="font-weight-bold text-muted text-uppercase pl-3 small" style="line-height: 2;">Active stories</th>
<td class="text-right font-weight-bold">{{$profile->stories()->count()}}</td>
</tr>
<tr>
<th scope="row" class="font-weight-bold text-muted text-uppercase pl-3 small" style="line-height: 2;">storage used</th>
<td class="text-right font-weight-bold">{{PrettyNumber::size($profile->media()->sum('size'))}}<span class="text-muted"> / {{PrettyNumber::size(config('pixelfed.max_account_size') * 1000)}}</span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-12 col-md-8">
<p class="title h4 font-weight-bold mt-2 py-2">Recent Posts</p>
<hr>
<div class="row">
@foreach($profile->statuses()->whereHas('media')->latest()->take(9)->get() as $item)
<div class="col-12 col-md-4 col-sm-6 px-0" style="margin-bottom: 1px;">
<a href="{{$item->url()}}">
<img src="{{$item->thumb(true)}}" width="200px" height="200px">
</a>
</div>
@endforeach
@if($profile->statuses()->whereHas('media')->count() == 0)
<div class="col-12">
<div class="card card-body border shadow-none bg-transparent">
<p class="text-center mb-0 text-muted">No statuses found</p>
</div>
</div>
</span>
</div>
<hr>
<div class="row mb-3">
<div class="col-12 col-md-4">
<div class="card shadow-none border">
<div class="card-body text-center">
<img src="{{$profile->avatarUrl()}}" class="box-shadow rounded-circle" width="128px" height="128px">
<p class="mt-3 mb-0 lead">
<span class="font-weight-bold">{{$profile->name}}</span>
</p>
@if($user->is_admin == true)
<p class="mb-0">
<span class="badge badge-danger badge-sm">ADMIN</span>
</p>
@endif
<p class="mb-0 text-center text-muted">
Joined {{$profile->created_at->diffForHumans()}}
</p>
</div>
<table class="table mb-0">
<tbody>
<tr>
<th scope="row" class="font-weight-bold text-muted text-uppercase pl-3 small" style="line-height: 2;">bookmarks</th>
<td class="text-right font-weight-bold">{{$profile->bookmarks()->count()}}</td>
</tr>
<tr>
<th scope="row" class="font-weight-bold text-muted text-uppercase pl-3 small" style="line-height: 2;">collections</th>
<td class="text-right font-weight-bold">{{$profile->collections()->count()}}</td>
</tr>
<tr>
<th scope="row" class="font-weight-bold text-muted text-uppercase pl-3 small" style="line-height: 2;">likes</th>
<td class="text-right font-weight-bold">{{$profile->likes()->count()}}</td>
</tr>
<tr>
<th scope="row" class="font-weight-bold text-muted text-uppercase pl-3 small" style="line-height: 2;">reports</th>
<td class="text-right font-weight-bold">{{$profile->reports()->count()}}</td>
</tr>
<tr>
<th scope="row" class="font-weight-bold text-muted text-uppercase pl-3 small" style="line-height: 2;">reported</th>
<td class="text-right font-weight-bold">{{$profile->reported()->count()}}</td>
</tr>
<tr>
<th scope="row" class="font-weight-bold text-muted text-uppercase pl-3 small" style="line-height: 2;">Active stories</th>
<td class="text-right font-weight-bold">{{$profile->stories()->count()}}</td>
</tr>
<tr>
<th scope="row" class="font-weight-bold text-muted text-uppercase pl-3 small" style="line-height: 2;">storage used</th>
<td class="text-right font-weight-bold">{{PrettyNumber::size($profile->media()->sum('size'))}}<span class="text-muted"> / {{PrettyNumber::size(config('pixelfed.max_account_size') * 1000)}}</span></td>
</tr>
</tbody>
</table>
</div>
</div>
@endsection
<div class="col-12 col-md-8">
<p class="title h4 font-weight-bold mt-2 py-2">Recent Posts</p>
<hr>
<div class="row">
@foreach($profile->statuses()->whereHas('media')->latest()->take(9)->get() as $item)
<div class="col-12 col-md-4 col-sm-6 px-0" style="margin-bottom: 1px;">
<a href="{{$item->url()}}">
<img src="{{$item->thumb(true)}}" width="200px" height="200px">
</a>
</div>
@endforeach
@if($profile->statuses()->whereHas('media')->count() == 0)
<div class="col-12">
<div class="card card-body border shadow-none bg-transparent">
<p class="text-center mb-0 text-muted">No statuses found</p>
</div>
</div>
@endif
</div>
</div>
</div>
@endsection