Panel/Panel/modules/addonsmanager/user_addons.php
copilot-swe-agent[bot] 6dd5088613
feat: redesign SCM workshop handling – remove workshop_item_id requirement, add user ID entry, deprecate steam_workshop menu
- server_content_helpers.php: remove workshop_item_id from required fields/validation; support newline-separated IDs; add scm_validate_workshop_user_ids(); update help text; add new template policy columns to ensure_phase2_schema; add content_id guard to ensure_workshop_schema
- addons_manager.php: rename admin workshop_item_id row to "Default Workshop IDs (Optional)" with updated label
- user_addons.php: route workshop_item type to workshop_content page instead of addons installer
- workshop_content.php: accept addon_id param; show template info; use textarea for multi-ID entry; update heading/help text
- workshop_action.php: accept addon_id param; resolve workshop_app_id from addon template; pass extra_manifest to manifest-and-run; store content_id on insert; use newline/comma-separated IDs
- addons_installer.php: redirect workshop_item addon_type to workshop_content page
- module.php: db_version 6 with allow_user_workshop_ids, max_workshop_ids, required_workshop_ids, blocked_workshop_ids on addons; content_id on server_content_workshop
- server_content_categories.php: rename "Steam Workshop Item" → "Steam Workshop Mods"
- steam_workshop/module.php: empty $module_menus, mark deprecated, bump version to 3.3
- addonsmanager.js: remove #scm-row-workshop-id from steam_workshop admin rows

Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/6a328ac8-2f82-4943-93a9-7660bf42a2fd

Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
2026-05-20 16:47:47 +00:00

116 lines
4.2 KiB
PHP

<?php
/*
*
* GSP - Game Server Panel (a heavily customized fork of OGP maintained by WDS)
*
* User page: Server Content (module: addonsmanager, page: user_addons)
* ─────────────────────────────────────────────────────────────────────────────
* Shows the available Server Content categories for a specific game server
* home. Each category that has at least one content item configured for the
* server's game type is displayed as a clickable link that takes the user to
* the installer (addons_installer.php).
*
* Group filtering: non-admin users only see content items assigned to one of
* their groups, or to the "All groups" (group_id=0 / NULL) bucket.
*
*/
// Central category map — load so we can iterate all types dynamically.
require_once(dirname(__FILE__) . '/server_content_categories.php');
require_once(dirname(__FILE__) . '/server_content_helpers.php');
function exec_ogp_module() {
global $db;
$home_id = $_GET['home_id'];
$mod_id = $_GET['mod_id'];
$ip = $_GET['ip'];
$port = $_GET['port'];
$user_id = $_SESSION['user_id'];
// Check if user has some games.
$isAdmin = $db->isAdmin( $user_id );
$query_groups = "";
if($isAdmin)
$home_info = $db->getGameHome($home_id);
else
{
$home_info = $db->getUserGameHome($user_id,$home_id);
$groups = $db->getUsersGroups($_SESSION['user_id']);
if (!is_array($groups)) {
$groups = [];
}
$query_groups .= " AND (";
foreach ((array)$groups as $group)
$query_groups .= "group_id=".$group['group_id']." OR ";
$query_groups .= "group_id=0 OR group_id IS NULL)";
}
if ($home_info)
{
scm_ensure_workshop_schema($db);
$home_cfg_id = $home_info['home_cfg_id'];
echo "<h2>Server Content: ".htmlentities($home_info['home_name'])."</h2>\n".
"<table class='center' >\n".
"<tr>\n";
// Iterate all registered content types. Each type that has at least
// one item for this game generates a link to the installer page.
// New types added to server_content_categories.php automatically
// appear here without any further code changes.
$categories = get_server_content_categories(); // key => label
$printed_any_cell = false;
foreach ((array)$categories as $type_key => $type_label)
{
$items = $db->resultQuery(
"SELECT DISTINCT addon_id, name, game_name " .
"FROM OGP_DB_PREFIXaddons " .
"NATURAL JOIN OGP_DB_PREFIXconfig_homes " .
"WHERE addon_type='" . $db->realEscapeSingle($type_key) . "' " .
"AND home_cfg_id=" . (int)$home_cfg_id . $query_groups
);
$items_qty = is_array($items) ? count((array)$items) : 0;
if ($items && $items_qty >= 1)
{
if ($printed_any_cell)
echo "</td><td>\n";
else
echo "<td>\n";
$printed_any_cell = true;
// Workshop items route to the workshop_content page where users
// enter their own Workshop IDs. All other types use the installer.
if ($type_key === 'workshop_item') {
$first_addon_id = isset($items[0]['addon_id']) ? (int)$items[0]['addon_id'] : 0;
echo "<a href='?m=addonsmanager&amp;p=workshop_content" .
"&amp;home_id=" . (int)$home_id .
"&amp;mod_id=" . (int)$mod_id .
($first_addon_id > 0 ? "&amp;addon_id=" . $first_addon_id : '') .
"&amp;ip=" . htmlspecialchars($ip) .
"&amp;port=" . htmlspecialchars($port) . "'>" .
htmlspecialchars($type_label) . " (" . $items_qty . ")" .
"</a>\n";
} else {
echo "<a href='?m=addonsmanager&amp;p=addons" .
"&amp;home_id=" . (int)$home_id .
"&amp;mod_id=" . (int)$mod_id .
"&amp;addon_type=" . urlencode($type_key) .
"&amp;ip=" . htmlspecialchars($ip) .
"&amp;port=" . htmlspecialchars($port) . "'>" .
htmlspecialchars($type_label) . " (" . $items_qty . ")" .
"</a>\n";
}
}
}
if ($printed_any_cell)
echo "</td>\n";
echo "</tr>\n".
"</table>\n".
"<form action='?m=gamemanager&amp;p=game_monitor&amp;home_id-mod_id-ip-port=$home_id-$mod_id-$ip-$port' method='POST'>\n".
"<input type='submit' value='".get_lang('back')."' />\n".
"</form>\n".
"<br>\n";
}
else
print_failure(get_lang('no_games_servers_available'));
}
?>