pulsanti e create client

This commit is contained in:
mariano
2026-05-20 11:46:28 +02:00
parent 7143d721fb
commit a1c3a5a07e
5 changed files with 112 additions and 21 deletions
+32
View File
@@ -152,6 +152,38 @@ if (isset($_POST['execute'])) {
}
}
break;
case 'create_client':
if (Profile::canCurrentUser(CREATE)) {
$link = ServerAsset::getLinkForAsset($itemtype, $items_id, false);
if ($link !== null) {
$server = new \GlpiPlugin\Urbackup\Server();
$server->getFromDB((int) $link['plugin_urbackup_servers_id']);
$client_name = ServerAsset::getAssetName($itemtype, $items_id);
try {
$api = new \GlpiPlugin\Urbackup\UrbackupApiClient($server);
$api->addClient($client_name);
} catch (\Throwable $e) {
// ignore
}
}
}
break;
case 'delete_client':
if (Profile::canCurrentUser(PURGE)) {
$link = ServerAsset::getLinkForAsset($itemtype, $items_id, false);
if ($link !== null) {
$server = new \GlpiPlugin\Urbackup\Server();
$server->getFromDB((int) $link['plugin_urbackup_servers_id']);
$client_name = ServerAsset::getAssetName($itemtype, $items_id);
try {
$api = new \GlpiPlugin\Urbackup\UrbackupApiClient($server);
$api->removeClient($client_name);
} catch (\Throwable $e) {
// ignore
}
}
}
break;
case 'set_internet_mode':
if (Profile::canCurrentUser(UPDATE)) {
$enabled = (int) ($_POST['internet_mode'] ?? 0) === 1;