Skip to content
Open
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- Add type renaming

## [3.0.2 End-of-Life Updater] - 2025-11-20

- Secured, fixed, and enhanced the uninstall process
Expand Down
25 changes: 21 additions & 4 deletions front/migration_status.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,30 @@
// Check if user has admin rights
Session::checkRight('config', UPDATE);

/** @var array $CFG_GLPI */
/** @var DBmysql $DB */
global $DB;
global $CFG_GLPI, $DB;

// Handle get_system_name AJAX action
if ($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_GET['action']) && $_GET['action'] === 'get_system_name') {
header('Content-Type: application/json');
echo json_encode(['system_name' => PluginGenericobjectType::getSystemName((string) ($_GET['name'] ?? ''))]);
exit;
}

// Handle rename POST action
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['type_id'], $_POST['new_name'])) {
$type_id = (int) $_POST['type_id'];
$new_name = (string) $_POST['new_name'];
PluginGenericobjectType::renameType($type_id, $new_name);
Html::redirect($CFG_GLPI['root_doc'] . '/plugins/genericobject/front/migration_status.php');
}

// Get all GenericObject types
$genericobject_types = [];
if ($DB->tableExists(PluginGenericobjectType::getTable())) {
$query = [
'SELECT' => ['itemtype', 'name'],
'SELECT' => ['id', 'name'],
'FROM' => PluginGenericobjectType::getTable(),
];
$request = $DB->request($query);
Expand Down Expand Up @@ -70,8 +86,9 @@

// Render the template content
TemplateRenderer::getInstance()->display('@genericobject/migration_status.html.twig', [
'genericobject_types' => $genericobject_types,
'customassets' => $customassets,
'genericobject_types' => $genericobject_types,
'customassets' => $customassets,
'reserved_names' => array_map('strtolower', PluginGenericobjectType::getReservedNames()),
]);

// Display GLPI footer
Expand Down
Loading