From b7f3ae25e8799a215822859e5ca7769dbe7b4fdf Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Tue, 5 Jul 2022 15:36:11 +0800 Subject: [PATCH] show approval only when not review visible is no --- app/Filament/Resources/Torrent/TorrentResource.php | 5 +++++ public/details.php | 2 +- public/torrents.php | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Filament/Resources/Torrent/TorrentResource.php b/app/Filament/Resources/Torrent/TorrentResource.php index ad00bf95..7c299e8d 100644 --- a/app/Filament/Resources/Torrent/TorrentResource.php +++ b/app/Filament/Resources/Torrent/TorrentResource.php @@ -4,6 +4,7 @@ namespace App\Filament\Resources\Torrent; use App\Filament\Resources\Torrent\TorrentResource\Pages; use App\Filament\Resources\Torrent\TorrentResource\RelationManagers; +use App\Models\Setting; use App\Models\Tag; use App\Models\Torrent; use App\Models\TorrentTag; @@ -52,6 +53,7 @@ class TorrentResource extends Resource public static function table(Table $table): Table { + $showApproval = Setting::get('torrent.approval_status_none_visible') == 'no'; return $table ->columns([ Tables\Columns\TextColumn::make('id')->sortable(), @@ -72,6 +74,7 @@ class TorrentResource extends Resource Tables\Columns\TextColumn::make('leechers')->label(__('label.torrent.leechers')), // Tables\Columns\TextColumn::make('times_completed')->label(__('label.torrent.times_completed')), Tables\Columns\BadgeColumn::make('approval_status') + ->visible($showApproval) ->label(__('label.torrent.approval_status')) ->colors(array_flip(Torrent::listApprovalStatus(true, 'badge_color'))) ->formatStateUsing(fn ($record) => $record->approvalStatusText), @@ -100,6 +103,7 @@ class TorrentResource extends Resource // Tables\Actions\EditAction::make(), Tables\Actions\Action::make('approval') ->label(__('admin.resources.torrent.action_approval')) + ->visible($showApproval) ->form([ Forms\Components\Radio::make('approval_status') ->label(__('label.torrent.approval_status')) @@ -176,6 +180,7 @@ class TorrentResource extends Resource }) ->deselectRecordsAfterCompletion(), ]); + } public static function getEloquentQuery(): Builder diff --git a/public/details.php b/public/details.php index 9280ecc2..335114ee 100644 --- a/public/details.php +++ b/public/details.php @@ -156,7 +156,7 @@ if (!$row) { if (get_user_class() >= $askreseed_class && $row['seeders'] == 0) { $actions[] = "\"reseed\" ".$lang_details['text_ask_for_reseed'] .""; } - if (get_user_class() >= $torrentmanage_class) { + if (get_user_class() >= $torrentmanage_class && get_setting('torrent.approval_status_none_visible') == 'no') { $approvalIcon = ''; $actions[] = sprintf( '%s %s', diff --git a/public/torrents.php b/public/torrents.php index cd20e0ae..304f8064 100644 --- a/public/torrents.php +++ b/public/torrents.php @@ -811,8 +811,8 @@ $approvalStatusNoneVisible = get_setting('torrent.approval_status_none_visible') $approvalStatusIconEnabled = get_setting('torrent.approval_status_icon_enabled'); $approvalStatus = null; $showApprovalStatusFilter = false; -//when enable approval status icon, all user can use this filter, otherwise only staff member can use -if ($approvalStatusIconEnabled == 'yes' || get_user_class() >= $staffmem_class) { +//when enable approval status icon, all user can use this filter, otherwise only staff member and approval none visible is 'no' can use +if ($approvalStatusIconEnabled == 'yes' || (get_user_class() >= $staffmem_class && $approvalStatusNoneVisible == 'no')) { $showApprovalStatusFilter = true; } //when user can use approval status filter, and pass `approval_status` parameter, will affect