diff --git a/app/Http/Livewire/UserWarnings.php b/app/Http/Livewire/UserWarnings.php
new file mode 100644
index 0000000000..a583937349
--- /dev/null
+++ b/app/Http/Livewire/UserWarnings.php
@@ -0,0 +1,254 @@
+
+ * @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
+ */
+
+namespace App\Http\Livewire;
+
+use App\Models\PrivateMessage;
+use App\Models\User;
+use App\Models\Warning;
+use Illuminate\Support\Carbon;
+use Livewire\Component;
+use Livewire\WithPagination;
+
+/**
+ * @property \Illuminate\Contracts\Pagination\LengthAwarePaginator $warnings
+ * @property int $automatedWarningsCount
+ * @property int $manualWarningsCount
+ * @property int $deletedWarningsCount
+ */
+class UserWarnings extends Component
+{
+ use WithPagination;
+
+ public User $user;
+
+ public string $warningTab = 'automated';
+
+ public string $message = '';
+
+ public int $perPage = 10;
+
+ public string $sortField = 'created_at';
+
+ public string $sortDirection = 'desc';
+
+ protected $queryString = [
+ 'warningTab' => ['except' => 'automated'],
+ ];
+
+ protected $rules = [
+ 'message' => [
+ 'required',
+ 'filled',
+ 'max:255',
+ ],
+ ];
+
+ final public function getWarningsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator
+ {
+ return $this->user
+ ->userwarning()
+ ->when(
+ auth()->user()->group->is_modo,
+ fn ($query) => $query->with('warneduser', 'staffuser', 'torrenttitle'),
+ fn ($query) => $query->with('warneduser', 'torrenttitle'),
+ )
+ ->when($this->warningTab === 'automated', fn ($query) => $query->whereNotNull('torrent'))
+ ->when($this->warningTab === 'manual', fn ($query) => $query->whereNull('torrent'))
+ ->when($this->warningTab === 'deleted', fn ($query) => $query->onlyTrashed())
+ ->paginate($this->perPage);
+ }
+
+ final public function getAutomatedWarningsCountProperty(): int
+ {
+ return $this->user->userwarning()->whereNotNull('torrent')->count();
+ }
+
+ final public function getManualWarningsCountProperty(): int
+ {
+ return $this->user->userwarning()->whereNull('torrent')->count();
+ }
+
+ final public function getDeletedWarningsCountProperty(): int
+ {
+ return $this->user->userwarning()->onlyTrashed()->count();
+ }
+
+ /**
+ * Manually warn a user.
+ */
+ final public function store(): void
+ {
+ abort_unless(auth()->user()->group->is_modo, 403);
+
+ $this->validate();
+
+ Warning::create([
+ 'user_id' => $this->user->id,
+ 'warned_by' => auth()->user()->id,
+ 'torrent' => null,
+ 'reason' => $this->message,
+ 'expires_on' => Carbon::now()->addDays(config('hitrun.expire')),
+ 'active' => '1',
+ ]);
+
+ $this->message = '';
+
+ PrivateMessage::create([
+ 'sender_id' => User::SYSTEM_USER_ID,
+ 'receiver_id' => $this->user->id,
+ 'subject' => 'Received warning',
+ 'message' => 'You have received a [b]warning[/b]. Reason: '.$this->message,
+ ]);
+
+ $this->dispatchBrowserEvent('success', ['type' => 'success', 'message' => 'Warning issued successfully!']);
+ }
+
+ /**
+ * Deactivate A Warning.
+ */
+ final public function deactivate(Warning $warning): void
+ {
+ abort_unless(auth()->user()->group->is_modo, 403);
+
+ $staff = auth()->user();
+
+ $warning->update([
+ 'expires_on' => now(),
+ 'active' => false,
+ ]);
+
+ PrivateMessage::create([
+ 'sender_id' => $staff->id,
+ 'receiver_id' => $this->user->id,
+ 'subject' => 'Hit and Run Warning Deleted',
+ 'message' => $staff->username.' has decided to deactivate your warning for torrent '.$warning->torrent.' You lucked out! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]',
+ ]);
+
+ $this->dispatchBrowserEvent('success', ['type' => 'success', 'message' => 'Warning Was Successfully Deactivated']);
+ }
+
+ /**
+ * Reactivate A Warning.
+ */
+ final public function reactivate(Warning $warning): void
+ {
+ abort_unless(auth()->user()->group->is_modo, 403);
+
+ $warning->update([
+ 'expires_on' => $warning->created_at->addDays(config('hitrun.expire')),
+ 'active' => true,
+ ]);
+
+ $this->dispatchBrowserEvent('success', ['type' => 'success', 'message' => 'Warning Was Successfully Reactivated']);
+ }
+
+ /**
+ * Deactivate All Warnings.
+ */
+ final public function massDeactivate(): void
+ {
+ abort_unless(auth()->user()->group->is_modo, 403);
+
+ $staff = auth()->user();
+
+ $this->user
+ ->warnings()
+ ->where('active', '=', 1)
+ ->update([
+ 'expires_on' => now(),
+ 'active' => false,
+ ]);
+
+ PrivateMessage::create([
+ 'sender_id' => $staff->id,
+ 'receiver_id' => $this->user->id,
+ 'subject' => 'All Hit and Run Warnings Deleted',
+ 'message' => $staff->username.' has decided to deactivate all of your warnings. You lucked out! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]',
+ ]);
+
+ $this->dispatchBrowserEvent('success', ['type' => 'success', 'message' => 'All Warnings Were Successfully Deactivated']);
+ }
+
+ /**
+ * Delete A Warning.
+ */
+ final public function destroy(Warning $warning): void
+ {
+ abort_unless(auth()->user()->group->is_modo, 403);
+
+ $staff = auth()->user();
+
+ $warning->update([
+ 'deleted_by' => $staff->id,
+ ]);
+
+ $warning->delete();
+
+ PrivateMessage::create([
+ 'sender_id' => $staff->id,
+ 'receiver_id' => $this->user->id,
+ 'subject' => 'Hit and Run Warning Deleted',
+ 'message' => $staff->username.' has decided to delete your warning for torrent '.$warning->torrent.' You lucked out! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]',
+ ]);
+
+ $this->dispatchBrowserEvent('success', ['type' => 'success', 'message' => 'Warning Was Successfully Deleted']);
+ }
+
+ /**
+ * Delete All Warnings.
+ */
+ final public function massDestroy(): void
+ {
+ abort_unless(auth()->user()->group->is_modo, 403);
+
+ $staff = auth()->user();
+
+ $this->user->warnings()->update([
+ 'deleted_by' => $staff->id,
+ ]);
+
+ $this->user->warnings()->delete();
+
+ PrivateMessage::create([
+ 'sender_id' => $staff->id,
+ 'receiver_id' => $this->user->id,
+ 'subject' => 'All Hit and Run Warnings Deleted',
+ 'message' => $staff->username.' has decided to delete all of your warnings. You lucked out! [color=red][b]THIS IS AN AUTOMATED SYSTEM MESSAGE, PLEASE DO NOT REPLY![/b][/color]',
+ ]);
+
+ $this->dispatchBrowserEvent('success', ['type' => 'success', 'message' => 'All Warnings Were Successfully Deleted']);
+ }
+
+ /**
+ * Restore A Soft Deleted Warning.
+ */
+ final public function restore(int $id): void
+ {
+ abort_unless(auth()->user()->group->is_modo, 403);
+
+ Warning::withTrashed()->findOrFail($id)->restore();
+
+ $this->dispatchBrowserEvent('success', ['type' => 'success', 'message' => 'Warning Was Successfully Restored']);
+ }
+
+ final public function render(): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application
+ {
+ return view('livewire.user-warnings', [
+ 'warnings' => $this->warnings,
+ 'automatedWarningsCount' => $this->automatedWarningsCount,
+ 'manualWarningsCount' => $this->manualWarningsCount,
+ 'deletedWarningsCount' => $this->deletedWarningsCount,
+ ]);
+ }
+}
diff --git a/lang/en/user.php b/lang/en/user.php
index fe1d3d1d6b..679686f64e 100644
--- a/lang/en/user.php
+++ b/lang/en/user.php
@@ -266,6 +266,7 @@
'profile-privacy-help' => 'Control which statistics and pieces of information appear on your profile.
These settings are overridden if you do not allow any groups to access your profile or if you Go Private',
'public-info' => 'Public Info',
+ 'reactivate' => 'Reactivate',
'reason-ban' => 'Ban Reason',
'reason-unban' => 'Unban Reason',
'recent-achievements' => 'Recent Achievements',
diff --git a/resources/views/livewire/user-warnings.blade.php b/resources/views/livewire/user-warnings.blade.php
new file mode 100644
index 0000000000..fd7eac9bcb
--- /dev/null
+++ b/resources/views/livewire/user-warnings.blade.php
@@ -0,0 +1,271 @@
+
+
+
+
+
+
+
+ {{ __('user.warned-by') }} |
+ @if ($warningTab !== 'manual')
+ {{ __('torrent.torrent') }} |
+ @endif
+ {{ __('common.reason') }} |
+ {{ __('user.created-on') }} |
+ {{ __('user.expires-on') }} |
+ {{ __('user.active') }} |
+ {{ __('common.actions') }} |
+
+
+
+ @forelse ($warnings as $warning)
+
+
+
+ |
+ @if ($warningTab !== 'manual')
+
+ @isset($warning->torrenttitle)
+
+ {{ $warning->torrenttitle->name }}
+
+ @else
+ n/a
+ @endif
+ |
+ @endif
+ {{ $warning->reason }} |
+
+
+ |
+
+
+ |
+
+ @if ($warning->active)
+
+ @else
+
+ @endif
+ |
+ @if(auth()->user()->group->is_modo)
+
+
+ |
+ @endif
+
+ @empty
+
+ {{ __('user.no-warning') }} |
+
+ @endforelse
+
+
+ {{ $warnings->links('partials.pagination') }}
+
+
diff --git a/resources/views/user/profile/partials/warnings.blade.php b/resources/views/user/profile/partials/warnings.blade.php
deleted file mode 100644
index 468ff65623..0000000000
--- a/resources/views/user/profile/partials/warnings.blade.php
+++ /dev/null
@@ -1,330 +0,0 @@
-
-
-
-
-
-
-
- {{ __('user.warned-by') }} |
- {{ __('torrent.torrent') }} |
- {{ __('common.reason') }} |
- {{ __('user.created-on') }} |
- {{ __('user.expires-on') }} |
- {{ __('user.active') }} |
- {{ __('common.actions') }} |
-
-
-
- @forelse ($autoWarnings as $warning)
-
-
-
- |
-
- @isset($warning->torrenttitle)
-
- {{ $warning->torrenttitle->name }}
-
- @else
- n/a
- @endif
- |
- {{ $warning->reason }} |
-
-
- |
-
-
- |
-
- @if ($warning->active)
-
- @else
-
- @endif
- |
-
-
- |
-
- @empty
-
- {{ __('user.no-warning') }} |
-
- @endforelse
-
-
- {{ $autoWarnings->links('partials.pagination') }}
-
-
-
-
-
- {{ __('user.warned-by') }} |
- {{ __('common.reason') }} |
- {{ __('user.created-on') }} |
- {{ __('user.expires-on') }} |
- {{ __('user.active') }} |
- {{ __('common.actions') }} |
-
-
-
- @forelse ($manualWarnings as $warning)
-
-
-
- |
- {{ $warning->reason }} |
-
-
- |
-
-
- |
-
- @if ($warning->active)
-
- @else
-
- @endif
- |
-
-
- |
-
- @empty
-
- {{ __('user.no-warning') }} |
-
- @endforelse
-
-
- {{ $manualWarnings->links('partials.pagination') }}
-
-
-
-
-
- {{ __('user.warned-by') }} |
- {{ __('torrent.torrent') }} |
- {{ __('common.reason') }} |
- {{ __('user.created-on') }} |
- {{ __('user.deleted-on') }} |
- {{ __('user.deleted-by') }} |
- {{ __('common.actions') }} |
-
-
-
- @forelse ($softDeletedWarnings as $warning)
-
-
-
- |
-
- @isset($warning->torrenttitle)
-
- {{ $warning->torrenttitle->name }}
-
- @else
- n/a
- @endif
- |
- {{ $warning->reason }} |
- {{ $warning->created_at }} |
- {{ $warning->deleted_at }} |
-
-
- |
-
-
- |
-
- @empty
-
- {{ __('user.no-soft-warning') }} |
-
- @endforelse
-
-
- {{ $softDeletedWarnings->links('partials.pagination') }}
-
-
diff --git a/resources/views/user/profile/show.blade.php b/resources/views/user/profile/show.blade.php
index 944c555b01..290a87ce8e 100644
--- a/resources/views/user/profile/show.blade.php
+++ b/resources/views/user/profile/show.blade.php
@@ -111,7 +111,7 @@ class="form__textarea"
-
+
@if ($user->isOnline())
@@ -324,7 +324,9 @@ class="user-search__avatar"
@endif
@if (auth()->user()->group->is_modo)
@include('user.profile.partials.bans', ['bans' => $user->userban])
- @include('user.profile.partials.warnings')
+ @endif
+
+ @if (auth()->user()->group->is_modo)