Panel/Panel/modules/addonsmanager/user_addons.php
copilot-swe-agent[bot] d562d849b7
feat(addonsmanager): Phase 1 — Server Content Manager conversion
- Rename UI labels from "Addons Manager" to "Server Content Manager"
- Add server_content_categories.php: central category map with 8 types
- Bump module db_version 1→2 with safe VARCHAR(32) migration for addon_type
- addons_manager.php: use category map for type list + comments
- addons_installer.php: use category map + full TODO blocks for Phase 2+
- user_addons.php: dynamic category iteration via category map
- monitor_buttons.php: updated header comment
- English lang: updated all user-visible strings, added new type labels
- global.php + gamemanager.php: updated LANG_addons_manager, LANG_user_addons, LANG_addons
- Created SERVER_CONTENT_ROADMAP.md with full review and migration plan

Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/1e8f1b08-96d6-4c47-8f27-efe972d7cf17

Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
2026-05-18 21:27:35 +00:00

102 lines
3.6 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');
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)
{
$home_cfg_id = $home_info['home_cfg_id'];
echo "<h2>".get_lang('user_addons').": ".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;
// Display label comes from the category map; the internal
// addon_type key is passed in the URL for backward compatibility.
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'));
}
?>