diff --git a/app/Filament/Resources/System/AgentAllowResource.php b/app/Filament/Resources/System/AgentAllowResource.php index 9f093ff0..90203991 100644 --- a/app/Filament/Resources/System/AgentAllowResource.php +++ b/app/Filament/Resources/System/AgentAllowResource.php @@ -74,6 +74,11 @@ class AgentAllowResource extends Resource ]) ->actions([ Tables\Actions\EditAction::make(), + Tables\Actions\DeleteAction::make()->using(function ($record) { + $record->delete(); + clear_agent_allow_deny_cache(); + return redirect(self::getUrl()); + }) ]) ->bulkActions([ Tables\Actions\DeleteBulkAction::make(), diff --git a/app/Filament/Resources/System/AgentAllowResource/Pages/EditAgentAllow.php b/app/Filament/Resources/System/AgentAllowResource/Pages/EditAgentAllow.php index a5afccce..82a73217 100644 --- a/app/Filament/Resources/System/AgentAllowResource/Pages/EditAgentAllow.php +++ b/app/Filament/Resources/System/AgentAllowResource/Pages/EditAgentAllow.php @@ -3,6 +3,7 @@ namespace App\Filament\Resources\System\AgentAllowResource\Pages; use App\Filament\Resources\System\AgentAllowResource; +use App\Models\NexusModel; use Filament\Pages\Actions; use Filament\Resources\Pages\EditRecord; @@ -13,7 +14,11 @@ class EditAgentAllow extends EditRecord protected function getActions(): array { return [ - Actions\DeleteAction::make(), + Actions\DeleteAction::make()->using(function ($record) { + $record->delete(); + clear_agent_allow_deny_cache(); + return redirect(AgentAllowResource::getUrl()); + }) ]; } diff --git a/app/Filament/Resources/System/AgentDenyResource.php b/app/Filament/Resources/System/AgentDenyResource.php index 714d0eb7..ba80e9ff 100644 --- a/app/Filament/Resources/System/AgentDenyResource.php +++ b/app/Filament/Resources/System/AgentDenyResource.php @@ -62,6 +62,11 @@ class AgentDenyResource extends Resource ]) ->actions([ Tables\Actions\EditAction::make(), + Tables\Actions\DeleteAction::make()->using(function ($record) { + $record->delete(); + clear_agent_allow_deny_cache(); + return redirect(self::getUrl()); + }) ]) ->bulkActions([ Tables\Actions\DeleteBulkAction::make(), diff --git a/app/Filament/Resources/System/AgentDenyResource/Pages/EditAgentDeny.php b/app/Filament/Resources/System/AgentDenyResource/Pages/EditAgentDeny.php index 96e72fd4..45506c35 100644 --- a/app/Filament/Resources/System/AgentDenyResource/Pages/EditAgentDeny.php +++ b/app/Filament/Resources/System/AgentDenyResource/Pages/EditAgentDeny.php @@ -13,7 +13,11 @@ class EditAgentDeny extends EditRecord protected function getActions(): array { return [ - Actions\DeleteAction::make(), + Actions\DeleteAction::make()->using(function ($record) { + $record->delete(); + clear_agent_allow_deny_cache(); + return redirect(AgentDenyResource::getUrl()); + }) ]; } diff --git a/include/cleanup.php b/include/cleanup.php index 6dfef0a7..2bc11291 100644 --- a/include/cleanup.php +++ b/include/cleanup.php @@ -729,7 +729,7 @@ function docleanup($forceAll = 0, $printProgress = false) { } //remove VIP status if time's up - $res = sql_query("SELECT id, modcomment FROM users WHERE vip_added='yes' AND vip_until < NOW()") or sqlerr(__FILE__, __LINE__); + $res = sql_query("SELECT id, modcomment, class FROM users WHERE vip_added='yes' AND vip_until < NOW()") or sqlerr(__FILE__, __LINE__); if (mysql_num_rows($res) > 0) { while ($arr = mysql_fetch_assoc($res)) @@ -742,8 +742,16 @@ function docleanup($forceAll = 0, $printProgress = false) { $modcomment = date("Y-m-d") . " - VIP status removed by - AutoSystem.\n". $modcomment; $modcom = sqlesc($modcomment); ///---end - sql_query("UPDATE users SET class = '1', vip_added = 'no', vip_until = null, modcomment = $modcom WHERE id = {$arr['id']}") or sqlerr(__FILE__, __LINE__); - sql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, {$arr['id']}, $dt, $msg, $subject)") or sqlerr(__FILE__, __LINE__); + if ($arr['class'] > \App\Models\User::CLASS_VIP) { + /** + * @since 1.8 + * never demotion VIP above + */ + sql_query("UPDATE users SET vip_added = 'no', vip_until = null, modcomment = $modcom WHERE id = {$arr['id']}") or sqlerr(__FILE__, __LINE__); + } else { + sql_query("UPDATE users SET class = '1', vip_added = 'no', vip_until = null, modcomment = $modcom WHERE id = {$arr['id']}") or sqlerr(__FILE__, __LINE__); + sql_query("INSERT INTO messages (sender, receiver, added, msg, subject) VALUES(0, {$arr['id']}, $dt, $msg, $subject)") or sqlerr(__FILE__, __LINE__); + } } } $log = "remove VIP status if time's up"; diff --git a/include/constants.php b/include/constants.php index af281f01..e1eb4828 100644 --- a/include/constants.php +++ b/include/constants.php @@ -1,6 +1,6 @@