pulsanti e sistemazione create client
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user