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}'; ?>

-

+

+ +
+ +

. The cache path below is where SteamCMD stores downloaded content on the agent. The install path is where the mod files are copied into the game server directory.'); ?>

+
@@ -34,6 +39,7 @@ $tplVarNote = $lang['profile_template_vars'] ?? 'Available: {home_id} {agent_id
diff --git a/modules/steam_workshop/views/admin/profiles.php b/modules/steam_workshop/views/admin/profiles.php index 90b09f16..9a38595a 100644 --- a/modules/steam_workshop/views/admin/profiles.php +++ b/modules/steam_workshop/views/admin/profiles.php @@ -5,15 +5,15 @@ declare(strict_types=1); ?>
-

+

@@ -22,7 +22,7 @@ declare(strict_types=1); - + @@ -36,7 +36,7 @@ declare(strict_types=1); - + @@ -63,11 +63,4 @@ declare(strict_types=1);
App ID OS @@ -46,15 +46,15 @@ declare(strict_types=1); + href="?m=steam_workshop&p=workshop_admin&sw_action=config_form&profile_id=">
- -
-

- ← - - -

diff --git a/modules/steam_workshop/workshop_admin.php b/modules/steam_workshop/workshop_admin.php index 5380cde3..df2436b9 100644 --- a/modules/steam_workshop/workshop_admin.php +++ b/modules/steam_workshop/workshop_admin.php @@ -1,7 +1,6 @@ ' . get_lang('steam_workshop') . ''; - // Route to the DB-driven profile manager when requested - $swAction = $_GET['sw_action'] ?? ''; - $profileActions = ['profiles', 'profile_form']; - $postAction = $_POST['sw_action'] ?? ''; - $profilePostActions = ['profile_save', 'profile_delete']; - - if (in_array($swAction, $profileActions, true) || in_array($postAction, $profilePostActions, true)) { - $controller = new WorkshopProfileController($db); - $controller->handle(); - return; - } - - // Default: legacy XML adapter manager + tab link to profiles - echo '

' - . (function_exists('get_lang') ? get_lang('nav_workshop_profiles') : 'Workshop Profiles') - . '

'; - - $controller = new AdminWorkshopController($db); + $controller = new WorkshopProfileController($db); $controller->handle(); }