77 lines
2.0 KiB
PHP
77 lines
2.0 KiB
PHP
<?php
|
|
|
|
use GlpiPlugin\Urbackup\Profile;
|
|
use GlpiPlugin\Urbackup\Server;
|
|
use GlpiPlugin\Urbackup\ServerAsset;
|
|
use Html;
|
|
|
|
if (!defined('GLPI_ROOT')) {
|
|
define('GLPI_ROOT', dirname(__DIR__, 4));
|
|
}
|
|
|
|
include_once GLPI_ROOT . "/inc/includes.php";
|
|
|
|
if (!Profile::canCurrentUser(UPDATE)) {
|
|
Html::displayRightError();
|
|
}
|
|
|
|
$server = new Server();
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
if (isset($_POST['link_asset'])) {
|
|
$itemtype = (string) ($_POST['itemtype'] ?? '');
|
|
$items_id = (int) ($_POST['items_id'] ?? 0);
|
|
$server_id = (int) ($_POST['id'] ?? 0);
|
|
|
|
if ($itemtype !== '' && $items_id > 0 && $server_id > 0) {
|
|
ServerAsset::connectAssetToServer($itemtype, $items_id, $server_id);
|
|
}
|
|
|
|
Html::redirect(PLUGIN_URBACKUP_WEB_DIR . '/front/server.php?id=' . $server_id);
|
|
}
|
|
|
|
$id = $_POST['id'] ?? 0;
|
|
|
|
if ($id > 0) {
|
|
$server->check($id, UPDATE);
|
|
$server->update($_POST);
|
|
} else {
|
|
$server->check(-1, CREATE);
|
|
$server->add($_POST);
|
|
}
|
|
|
|
Html::redirect(PLUGIN_URBACKUP_WEB_DIR . "/front/server.php");
|
|
}
|
|
|
|
$ID = $_GET['id'] ?? null;
|
|
|
|
Html::header(
|
|
$ID ? __('Edit UrBackup server', 'urbackup') : __('Add UrBackup server', 'urbackup'),
|
|
'',
|
|
'Assets',
|
|
'GlpiPlugin\Urbackup\Server'
|
|
);
|
|
|
|
$server->showForm($ID);
|
|
|
|
if ($ID > 0 && $server->getFromDB($ID)) {
|
|
echo '<div class="card mt-4">';
|
|
echo '<div class="card-header">';
|
|
echo '<h5 class="mb-0">' . htmlspecialchars(__('Linked clients', 'urbackup')) . '</h5>';
|
|
echo '</div>';
|
|
echo '<div class="card-body">';
|
|
Server::showLinkedClientsTab($server);
|
|
echo '</div>';
|
|
echo '</div>';
|
|
|
|
echo '<div class="card mt-4">';
|
|
echo '<div class="card-header">';
|
|
echo '<h5 class="mb-0">' . htmlspecialchars(__('Unlinked clients', 'urbackup')) . '</h5>';
|
|
echo '</div>';
|
|
echo '<div class="card-body">';
|
|
Server::showUnlinkedClientsTab($server);
|
|
echo '</div>';
|
|
echo '</div>';
|
|
}
|
|
|
|
Html::footer(); |