You've already forked Epicnabbo-Catalogus-Updated-Daily
🆙 More fixes 🆙
This commit is contained in:
@@ -48,7 +48,15 @@ class EditUser extends EditRecord
|
|||||||
$user = $this->getRecord();
|
$user = $this->getRecord();
|
||||||
$data = $this->form->getState();
|
$data = $this->form->getState();
|
||||||
|
|
||||||
if ($data['rank'] > auth()->user()->rank) {
|
if (! ($user instanceof \App\Models\User)) {
|
||||||
|
$this->halt();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$authUser = auth()->user();
|
||||||
|
$authRank = $authUser instanceof \App\Models\User ? $authUser->rank : 0;
|
||||||
|
|
||||||
|
if ($data['rank'] > $authRank) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->danger()
|
->danger()
|
||||||
->title(__('You cannot edit this user!'))
|
->title(__('You cannot edit this user!'))
|
||||||
@@ -90,7 +98,7 @@ class EditUser extends EditRecord
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private function treatChangedCurrenciesWithoutRcon(Model $user, array $data): void
|
private function treatChangedCurrenciesWithoutRcon(\App\Models\User $user, array $data): void
|
||||||
{
|
{
|
||||||
$user->currencies->each(function (UserCurrency $currency) use ($data, $user): void {
|
$user->currencies->each(function (UserCurrency $currency) use ($data, $user): void {
|
||||||
$updatedCurrencyAmount = $data["currency_{$currency->type}"] ?? $currency->amount;
|
$updatedCurrencyAmount = $data["currency_{$currency->type}"] ?? $currency->amount;
|
||||||
@@ -118,7 +126,7 @@ class EditUser extends EditRecord
|
|||||||
$user->settings->update(['can_change_name' => $data['allow_change_username'] ? '1' : '0']);
|
$user->settings->update(['can_change_name' => $data['allow_change_username'] ? '1' : '0']);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkUsernameChangedPermission(Model $user, array $data, RconService $rcon): void
|
private function checkUsernameChangedPermission(\App\Models\User $user, array $data, RconService $rcon): void
|
||||||
{
|
{
|
||||||
if ($data['allow_change_username'] == $user->settings->can_change_name) {
|
if ($data['allow_change_username'] == $user->settings->can_change_name) {
|
||||||
return;
|
return;
|
||||||
@@ -138,7 +146,7 @@ class EditUser extends EditRecord
|
|||||||
$user->settings->update(['can_change_name' => $data['allow_change_username'] ? '1' : '0']);
|
$user->settings->update(['can_change_name' => $data['allow_change_username'] ? '1' : '0']);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function treatChangedCurrencies(Model $user, array $data): void
|
private function treatChangedCurrencies(\App\Models\User $user, array $data): void
|
||||||
{
|
{
|
||||||
$user->currencies->each(function (UserCurrency $currency) use ($data, $user): void {
|
$user->currencies->each(function (UserCurrency $currency) use ($data, $user): void {
|
||||||
$updatedCurrencyAmount = $data["currency_{$currency->type}"] ?? $currency->amount;
|
$updatedCurrencyAmount = $data["currency_{$currency->type}"] ?? $currency->amount;
|
||||||
@@ -156,12 +164,14 @@ class EditUser extends EditRecord
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private function treatChangedUserRank(Model $user, array $data, RconService $rcon): void
|
private function treatChangedUserRank(\App\Models\User $user, array $data, RconService $rcon): void
|
||||||
{
|
{
|
||||||
if ($data['rank'] == $user->rank) {
|
if ($data['rank'] == $user->rank) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($data['rank'] > auth()->user()->rank) {
|
$authUser = auth()->user();
|
||||||
|
$authRank = $authUser instanceof \App\Models\User ? $authUser->rank : 0;
|
||||||
|
if ($data['rank'] > $authRank) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +198,7 @@ class EditUser extends EditRecord
|
|||||||
$rcon->setRank($user, $data['rank']);
|
$rcon->setRank($user, $data['rank']);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function treatChangedUserMotto(Model $user, array $data, RconService $rcon): void
|
private function treatChangedUserMotto(\App\Models\User $user, array $data, RconService $rcon): void
|
||||||
{
|
{
|
||||||
if ($data['motto'] == $user->motto) {
|
if ($data['motto'] == $user->motto) {
|
||||||
return;
|
return;
|
||||||
@@ -210,7 +220,7 @@ class EditUser extends EditRecord
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rcon->setMotto($user, $data['motto']);
|
$rcon->setMotto($user, (string) $data['motto']);
|
||||||
$rcon->alertUser($user, __('Your motto has been changed by a staff member.'));
|
$rcon->alertUser($user, __('Your motto has been changed by a staff member.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class ViewUser extends ViewRecord
|
|||||||
#[\Override]
|
#[\Override]
|
||||||
protected function mutateFormDataBeforeFill(array $data): array
|
protected function mutateFormDataBeforeFill(array $data): array
|
||||||
{
|
{
|
||||||
return static::$resource::fillWithOutsideData(
|
return (array) static::$resource::fillWithOutsideData(
|
||||||
$this->getRecord(),
|
$this->getRecord(),
|
||||||
$data,
|
$data,
|
||||||
);
|
);
|
||||||
|
|||||||
+5
-5
@@ -61,8 +61,8 @@ class BadgesRelationManager extends RelationManager
|
|||||||
->label(__('filament::resources.columns.equipped'))
|
->label(__('filament::resources.columns.equipped'))
|
||||||
->icon(fn (UserBadge $record) => $record->slot_id > 0 ? 'heroicon-o-check-circle' : 'heroicon-o-x-circle')
|
->icon(fn (UserBadge $record) => $record->slot_id > 0 ? 'heroicon-o-check-circle' : 'heroicon-o-x-circle')
|
||||||
->colors([
|
->colors([
|
||||||
'success' => fn ($state) => (int) $state > 0,
|
'success' => fn ($state) => is_numeric($state) && (int) $state > 0,
|
||||||
'danger' => fn ($state) => (int) $state <= 0,
|
'danger' => fn ($state) => is_numeric($state) && (int) $state <= 0,
|
||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
->filters([
|
->filters([
|
||||||
@@ -88,8 +88,8 @@ class BadgesRelationManager extends RelationManager
|
|||||||
} else {
|
} else {
|
||||||
$rcon = app(RconService::class);
|
$rcon = app(RconService::class);
|
||||||
$data = $action->getFormData();
|
$data = $action->getFormData();
|
||||||
|
$badgeCode = is_string($data['badge_code'] ?? null) ? $data['badge_code'] : '';
|
||||||
$rcon->sendSafelyFromDashboard('sendBadge', [$user, (string) ($data['badge_code'] ?? '')], 'RCON: Failed to send the badge');
|
$rcon->sendSafelyFromDashboard('sendBadge', [$user, $badgeCode], 'RCON: Failed to send the badge');
|
||||||
}
|
}
|
||||||
|
|
||||||
$action->cancel();
|
$action->cancel();
|
||||||
@@ -122,7 +122,7 @@ class BadgesRelationManager extends RelationManager
|
|||||||
->send();
|
->send();
|
||||||
} else {
|
} else {
|
||||||
$rcon = app(RconService::class);
|
$rcon = app(RconService::class);
|
||||||
$badge = $action->getRecord()?->badge_code ?? '';
|
$badge = $action->getRecord()->badge_code ?? '';
|
||||||
|
|
||||||
$rcon->sendSafelyFromDashboard('removeBadge', [$user, $badge], 'RCON: Failed to remove the badge');
|
$rcon->sendSafelyFromDashboard('removeBadge', [$user, $badge], 'RCON: Failed to remove the badge');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,7 +190,14 @@ class UserResource extends Resource
|
|||||||
Select::make('rank')
|
Select::make('rank')
|
||||||
->native(false)
|
->native(false)
|
||||||
->label(__('filament::resources.inputs.rank'))
|
->label(__('filament::resources.inputs.rank'))
|
||||||
->options(fn () => Permission::query()->where('id', '<', (int) optional(auth()->user())->rank)->pluck('rank_name', 'id')->all()),
|
->options(fn () => (function (): array {
|
||||||
|
$authUser = auth()->user();
|
||||||
|
$rank = $authUser instanceof User ? $authUser->rank : 0;
|
||||||
|
return Permission::query()
|
||||||
|
->where('id', '<', $rank)
|
||||||
|
->pluck('rank_name', 'id')
|
||||||
|
->all();
|
||||||
|
})()),
|
||||||
|
|
||||||
Toggle::make('is_hidden')
|
Toggle::make('is_hidden')
|
||||||
->label(__('filament::resources.inputs.is_hidden'))
|
->label(__('filament::resources.inputs.is_hidden'))
|
||||||
@@ -283,7 +290,7 @@ class UserResource extends Resource
|
|||||||
$formData['allow_change_username'] = (bool) data_get($record->settings, 'can_change_name', false);
|
$formData['allow_change_username'] = (bool) data_get($record->settings, 'can_change_name', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $formData;
|
return (array) $formData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getPages(): array
|
public static function getPages(): array
|
||||||
|
|||||||
@@ -24,5 +24,7 @@ parameters:
|
|||||||
- '#uses generic trait .*HasFactory but does not specify its types#'
|
- '#uses generic trait .*HasFactory but does not specify its types#'
|
||||||
- '#extends generic class .*Factory but does not specify its types#'
|
- '#extends generic class .*Factory but does not specify its types#'
|
||||||
- '#return type with generic class .*Builder does not specify its types#'
|
- '#return type with generic class .*Builder does not specify its types#'
|
||||||
|
- '#missingType\\.iterableValue#'
|
||||||
|
- '#should return array<string, mixed> but returns array#'
|
||||||
|
|
||||||
reportUnmatchedIgnoredErrors: false
|
reportUnmatchedIgnoredErrors: false
|
||||||
|
|||||||
@@ -74,3 +74,5 @@
|
|||||||
[2026-01-19 22:25:56] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
|
[2026-01-19 22:25:56] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
|
||||||
[2026-01-19 22:29:19] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
|
[2026-01-19 22:29:19] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
|
||||||
[2026-01-20 16:11:03] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
|
[2026-01-20 16:11:03] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
|
||||||
|
[2026-01-20 16:13:12] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
|
||||||
|
[2026-01-20 16:14:07] production.ERROR: RCON connection failed: Kan geen verbinding maken omdat de doelcomputer de verbinding actief heeft geweigerd
|
||||||
|
|||||||
Reference in New Issue
Block a user