feat: add Workshop behavior settings UI + fix billing period_start migration

Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/ee35e671-8ff2-43fb-a365-f7a4f9263ca7

Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-05-07 00:22:45 +00:00 committed by GitHub
parent 3a2ed00778
commit bf44b618e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 358 additions and 4 deletions

View file

@ -124,6 +124,17 @@ function sw_admin_save_profile($db)
'notes' => trim($_POST['notes'] ?? ''),
);
// Per-profile default behavior fields
$valid_update_modes = array('manual', 'on_restart', 'before_start', 'scheduled');
$valid_restart_behaviors = array('none', 'if_empty', 'immediate', 'next_restart');
$valid_hot_load = array('disabled', 'attempt');
$posted_um = $_POST['default_update_mode'] ?? 'manual';
$posted_rb = $_POST['default_restart_behavior'] ?? 'none';
$posted_hl = $_POST['default_hot_load'] ?? 'disabled';
$fields['default_update_mode'] = in_array($posted_um, $valid_update_modes, true) ? $posted_um : 'manual';
$fields['default_restart_behavior'] = in_array($posted_rb, $valid_restart_behaviors, true) ? $posted_rb : 'none';
$fields['default_hot_load'] = in_array($posted_hl, $valid_hot_load, true) ? $posted_hl : 'disabled';
$setParts = array();
foreach ($fields as $col => $val) {
$setParts[] = "`$col` = '" . $db->realEscapeSingle($val) . "'";
@ -291,6 +302,42 @@ function sw_admin_edit_form(array $profile, array $detected = array(), $showDete
<label><textarea name="notes" rows="4"><?= sw_h($profile['notes']) ?></textarea></label>
</div>
<div class="sw-section">
<h4>Default Workshop Behavior for New Servers</h4>
<p class="sw-muted">
These defaults are applied when a user enables Workshop on a server that has no saved behavior settings yet.
Users can always override them on their own server pages.
All defaults are intentionally set to the safest option (manual / no auto-restart / hot-load off).
</p>
<div class="sw-grid">
<label>
<span>Default Install / Update Mode</span>
<select name="default_update_mode">
<option value="manual" <?= (($profile['default_update_mode'] ?? 'manual') === 'manual') ? 'selected' : '' ?>>Manual only (safe default)</option>
<option value="on_restart" <?= (($profile['default_update_mode'] ?? 'manual') === 'on_restart') ? 'selected' : '' ?>>On next server restart</option>
<option value="before_start" <?= (($profile['default_update_mode'] ?? 'manual') === 'before_start') ? 'selected' : '' ?>>Before every server start</option>
<option value="scheduled" <?= (($profile['default_update_mode'] ?? 'manual') === 'scheduled') ? 'selected' : '' ?>>Scheduled update check</option>
</select>
</label>
<label>
<span>Default Restart Behavior</span>
<select name="default_restart_behavior">
<option value="none" <?= (($profile['default_restart_behavior'] ?? 'none') === 'none') ? 'selected' : '' ?>>Do not restart automatically (safe default)</option>
<option value="if_empty" <?= (($profile['default_restart_behavior'] ?? 'none') === 'if_empty') ? 'selected' : '' ?>>Restart only if server is empty</option>
<option value="immediate" <?= (($profile['default_restart_behavior'] ?? 'none') === 'immediate') ? 'selected' : '' ?>>Restart immediately after warning</option>
<option value="next_restart" <?= (($profile['default_restart_behavior'] ?? 'none') === 'next_restart') ? 'selected' : '' ?>>Install on next manual restart only</option>
</select>
</label>
<label>
<span>Default Hot-Load</span>
<select name="default_hot_load">
<option value="disabled" <?= (($profile['default_hot_load'] ?? 'disabled') === 'disabled') ? 'selected' : '' ?>>Disabled (safe default)</option>
<option value="attempt" <?= (($profile['default_hot_load'] ?? 'disabled') === 'attempt') ? 'selected' : '' ?>>Attempt hot-load if game supports it</option>
</select>
</label>
</div>
</div>
<p>
<button type="submit" name="save_profile" value="1" class="button">Save Profile</button>
<a href="home.php?m=steam_workshop&p=admin" class="button">Cancel</a>