From 86f825e388fae55cc71e270bd845a4949b32b2fe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 4 May 2026 16:56:38 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20rewrite=20workshop=5Fadmin=20UI=20?= =?UTF-8?q?=E2=80=93=20remove=20adapter=20terminology,=20make=20configurat?= =?UTF-8?q?ions=20primary?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/3fc88263-c1c0-46f6-95f1-7070fc6f9d02 Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com> --- .../controllers/WorkshopProfileController.php | 11 +++- modules/steam_workshop/lang/en_US.php | 61 ++++++++++--------- modules/steam_workshop/steam_workshop.css | 21 +++++++ .../views/admin/profile_form.php | 38 +++++++----- .../steam_workshop/views/admin/profiles.php | 27 +++----- modules/steam_workshop/workshop_admin.php | 20 +----- 6 files changed, 98 insertions(+), 80 deletions(-) diff --git a/modules/steam_workshop/controllers/WorkshopProfileController.php b/modules/steam_workshop/controllers/WorkshopProfileController.php index 01623cff..0f263904 100644 --- a/modules/steam_workshop/controllers/WorkshopProfileController.php +++ b/modules/steam_workshop/controllers/WorkshopProfileController.php @@ -31,9 +31,17 @@ class WorkshopProfileController public function handle(): void { + global $db; + + $userId = (int)($_SESSION['user_id'] ?? 0); + if (!$db->isAdmin($userId)) { + print_failure($this->lang['error_admin_only'] ?? 'Administrator access required.'); + return; + } + echo ''; - $action = $_GET['sw_action'] ?? 'profiles'; + $action = $_GET['sw_action'] ?? 'list'; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $postAction = $_POST['sw_action'] ?? ''; @@ -48,6 +56,7 @@ class WorkshopProfileController } switch ($action) { + case 'config_form': case 'profile_form': $this->handleForm((int)($_GET['profile_id'] ?? 0)); break; diff --git a/modules/steam_workshop/lang/en_US.php b/modules/steam_workshop/lang/en_US.php index db527900..2df15b15 100644 --- a/modules/steam_workshop/lang/en_US.php +++ b/modules/steam_workshop/lang/en_US.php @@ -105,54 +105,59 @@ return [ 'error_missing_query' => 'Enter a search term before querying the Workshop.', // ------------------------------------------------------- - // Workshop profile admin (WorkshopProfileController) + // Workshop game configuration admin (WorkshopProfileController) // ------------------------------------------------------- - 'nav_workshop_profiles' => 'Workshop Profiles (DB)', - 'profile_heading_list' => 'Workshop Game Profiles', - 'profile_intro' => 'One profile per supported game. Each profile drives mod install and caching behaviour.', - 'profile_btn_create' => 'Create Profile', - 'profile_list_empty' => 'No Workshop profiles defined yet.', + 'config_heading_list' => 'Workshop Game Configurations', + 'config_intro' => 'One configuration per supported game. Each configuration controls how SteamCMD downloads and installs Workshop mods for servers of that game type.', + 'config_btn_create' => 'Add Game Configuration', + 'config_list_empty' => 'No Workshop configurations defined yet. Add one for each game that supports Steam Workshop mods.', + 'config_confirm_delete' => 'Delete this Workshop configuration? Servers using it will no longer have Workshop mod support.', + 'config_back_list' => 'Back to configurations', + 'config_heading_edit' => 'Edit Workshop Configuration: %s', + 'config_heading_create' => 'Add Workshop Game Configuration', + 'config_steamcmd_heading' => 'How mods are downloaded', + 'config_steamcmd_note' => 'Workshop mods are downloaded using SteamCMD with the command: +workshop_download_item {app_id} {mod_id}. The cache path below is where SteamCMD stores downloaded mod files on the agent machine. The install path below is where those files are copied into the game server directory.', + 'config_label_app_id' => 'Steam App ID', + 'config_hint_app_id' => 'The Steam App ID used with +workshop_download_item, e.g. 107410 for Arma 3', + 'config_hint_game_key' => 'Short identifier matching the game XML key, e.g. arma3_linux', + 'config_section_copy' => 'Copy / sync method', + 'config_hint_launch_tpl' => 'Extra launch parameters added when this game has Workshop mods enabled. E.g. -mod=@{mod_id}', + 'config_label_enabled' => 'Configuration enabled (allows servers to use Workshop mods for this game)', 'profile_col_game' => 'Game', 'profile_col_key' => 'Game Key', - 'profile_col_method' => 'Copy Method', + 'profile_col_method' => 'Install Method', 'profile_col_restart' => 'Restart?', 'profile_col_status' => 'Status', - 'profile_confirm_delete' => 'Delete this Workshop profile? This will not affect already-installed server mods.', - 'profile_back_adapters' => 'Back to adapter management', - 'profile_back_list' => 'Back to profiles', - 'profile_heading_edit' => 'Edit Workshop Profile: %s', - 'profile_heading_create' => 'Create Workshop Profile', - 'profile_saved' => 'Workshop profile saved.', - 'profile_save_error' => 'Failed to save Workshop profile.', - 'profile_deleted' => 'Workshop profile deleted.', - 'profile_delete_error' => 'Failed to delete Workshop profile.', - 'profile_not_found' => 'Profile not found.', 'profile_section_basic' => 'Basic info', 'profile_section_paths' => 'Paths & templates', - 'profile_section_copy' => 'Copy / sync method', 'profile_section_config' => 'Config & launch parameters', 'profile_section_flags' => 'Flags', 'profile_label_game_name' => 'Game name', 'profile_label_os' => 'Supported OS', - 'profile_label_cache_path' => 'Cache path template', + 'profile_label_cache_path' => 'SteamCMD cache path template', 'profile_hint_cache_path' => 'Where SteamCMD downloads mods on the agent. E.g. {steamcmd_path}/steamapps/workshop/content/{workshop_app_id}/{mod_id}', - 'profile_label_install_path' => 'Install path template', - 'profile_hint_install_path' => 'Server-side mod directory. E.g. {server_path}/mods/{mod_folder}', + 'profile_label_install_path' => 'Server install path template', + 'profile_hint_install_path' => 'Where mod files are placed inside the game server directory. E.g. {server_path}/mods/{mod_folder}', 'profile_label_folder_name' => 'Mod folder name template', - 'profile_hint_folder_name' => 'Folder name for each mod. Default: @{mod_id}', - 'profile_label_copy_method' => 'Copy method', - 'profile_label_install_script'=> 'Custom install script (admin-defined only, optional)', + 'profile_hint_folder_name' => 'Folder name for each mod inside the install path. Default: @{mod_id}', + 'profile_label_copy_method' => 'Method used to copy mod files from SteamCMD cache to the server', + 'profile_label_install_script'=> 'Custom install script (optional, admin-defined)', 'profile_hint_install_script' => 'Only used when copy method is custom_script. Template variables are replaced before execution.', 'profile_label_config_tpl' => 'Config file template (optional)', 'profile_label_launch_tpl' => 'Launch parameter template (optional)', - 'profile_label_requires_restart' => 'Restart required after mod install/update', - 'profile_label_enabled' => 'Profile enabled', + 'profile_label_requires_restart' => 'Server restart required after mod install or update', 'profile_template_vars' => 'Available: {home_id} {agent_id} {workshop_app_id} {mod_id} {mod_title} {mod_folder} {steamcmd_path} {server_path} {install_path} {cache_path}', + 'profile_saved' => 'Workshop configuration saved.', + 'profile_save_error' => 'Failed to save Workshop configuration.', + 'profile_deleted' => 'Workshop configuration deleted.', + 'profile_delete_error' => 'Failed to delete Workshop configuration.', + 'profile_not_found' => 'Configuration not found.', + 'button_delete' => 'Delete', 'error_game_key_invalid' => 'Game key may only contain letters, digits, underscores, dots, and hyphens.', 'error_game_name_required' => 'Game name is required.', 'error_app_id_required' => 'Workshop App ID is required (numeric).', - 'error_cache_path_required' => 'Cache path template is required.', - 'error_install_path_required' => 'Install path template is required.', + 'error_cache_path_required' => 'SteamCMD cache path template is required.', + 'error_install_path_required' => 'Server install path template is required.', // ------------------------------------------------------- // User mod management (WorkshopModController) diff --git a/modules/steam_workshop/steam_workshop.css b/modules/steam_workshop/steam_workshop.css index 70433164..8fd15c67 100644 --- a/modules/steam_workshop/steam_workshop.css +++ b/modules/steam_workshop/steam_workshop.css @@ -584,3 +584,24 @@ color: #777; font-size: 0.9rem; } + + +/* Info box used on the configuration form to explain SteamCMD usage */ +.sw-info-box { + background: #e8f4fd; + border: 1px solid #b3d7f5; + border-radius: 4px; + padding: 0.75rem 1rem; + margin-bottom: 1.25rem; + font-size: 0.9rem; +} + +.sw-info-box strong { + display: block; + margin-bottom: 0.25rem; +} + +.sw-info-box p { + margin: 0; + color: #2c5f8a; +} diff --git a/modules/steam_workshop/views/admin/profile_form.php b/modules/steam_workshop/views/admin/profile_form.php index f05244d0..5784e5a8 100644 --- a/modules/steam_workshop/views/admin/profile_form.php +++ b/modules/steam_workshop/views/admin/profile_form.php @@ -6,8 +6,8 @@ declare(strict_types=1); $isEdit = $profileId > 0 && $profile !== null; $heading = $isEdit - ? sprintf($lang['profile_heading_edit'] ?? 'Edit Workshop Profile: %s', htmlspecialchars($profile['game_name'] ?? '')) - : ($lang['profile_heading_create'] ?? 'Create Workshop Profile'); + ? sprintf($lang['config_heading_edit'] ?? 'Edit Workshop Configuration: %s', htmlspecialchars($profile['game_name'] ?? '')) + : ($lang['config_heading_create'] ?? 'Add Workshop Game Configuration'); $v = static function (string $key, array $profile, string $default = ''): string { return htmlspecialchars((string)($profile[$key] ?? $default), ENT_QUOTES); @@ -15,14 +15,19 @@ $v = static function (string $key, array $profile, string $default = ''): string $osList = ['linux' => 'Linux', 'windows' => 'Windows']; $currentOs = array_filter(explode(',', (string)($profile['supported_os'] ?? 'linux'))); -$methodList = ['rsync' => 'rsync (Linux)', 'robocopy' => 'robocopy (Windows)', 'custom_script' => 'custom_script']; +$methodList = ['rsync' => 'rsync (Linux)', 'robocopy' => 'robocopy (Windows)', 'custom_script' => 'Custom script']; $curMethod = (string)($profile['copy_method'] ?? 'rsync'); $tplVarNote = $lang['profile_template_vars'] ?? 'Available: {home_id} {agent_id} {workshop_app_id} {mod_id} {mod_title} {mod_folder} {steamcmd_path} {server_path} {install_path} {cache_path}'; ?>