2026-05-20 09:20:27 +02:00
|
|
|
<?php
|
|
|
|
|
|
2026-05-21 10:54:04 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-05-20 09:20:27 +02:00
|
|
|
use GlpiPlugin\Urbackup\Config;
|
|
|
|
|
|
2026-08-07 14:27:33 +02:00
|
|
|
if (!defined('GLPI_ROOT')) {
|
|
|
|
|
define('GLPI_ROOT', dirname(__DIR__, 4));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
include_once GLPI_ROOT . '/inc/includes.php';
|
2026-05-20 09:20:27 +02:00
|
|
|
|
|
|
|
|
// Check user has right to manage plugin configuration
|
|
|
|
|
if (!Session::haveRight('config', UPDATE)) {
|
|
|
|
|
Html::displayRightError();
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-07 14:27:33 +02:00
|
|
|
if (($_SERVER['REQUEST_METHOD'] ?? 'GET') === 'POST') {
|
|
|
|
|
// CSRF token is validated by the global CheckCsrfListener on every POST.
|
|
|
|
|
if (isset($_POST['update'])) {
|
|
|
|
|
global $DB;
|
|
|
|
|
|
|
|
|
|
$enable_computer = (string) ($_POST['enable_computer'] ?? '0') === '1' ? '1' : '0';
|
|
|
|
|
|
|
|
|
|
$table = Config::getTable();
|
|
|
|
|
$iterator = $DB->request([
|
|
|
|
|
'FROM' => $table,
|
|
|
|
|
'WHERE' => ['name' => 'enable_computer'],
|
|
|
|
|
'LIMIT' => 1,
|
|
|
|
|
]);
|
|
|
|
|
$row = $iterator->current();
|
|
|
|
|
|
|
|
|
|
$values = [
|
|
|
|
|
'value' => $enable_computer,
|
|
|
|
|
'date_mod' => $_SESSION['glpi_currenttime'] ?? date('Y-m-d H:i:s'),
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if ($row === false) {
|
|
|
|
|
$values['name'] = 'enable_computer';
|
|
|
|
|
$values['date_creation'] = $_SESSION['glpi_currenttime'] ?? date('Y-m-d H:i:s');
|
|
|
|
|
$DB->insert($table, $values);
|
|
|
|
|
} else {
|
|
|
|
|
$DB->update($table, $values, ['name' => 'enable_computer']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Session::addMessageAfterRedirect(
|
|
|
|
|
__('Configuration saved.', 'urbackup'),
|
|
|
|
|
false,
|
|
|
|
|
INFO
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Html::redirect(Config::getFormURL());
|
|
|
|
|
}
|
2026-05-20 09:20:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Display GLPI header
|
|
|
|
|
Html::header(
|
|
|
|
|
__('UrBackup configuration', 'urbackup'),
|
|
|
|
|
'',
|
|
|
|
|
'Config',
|
|
|
|
|
'PluginUrbackupConfig'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Show configuration form
|
|
|
|
|
$config = new Config();
|
|
|
|
|
$config->showForm(1);
|
|
|
|
|
|
|
|
|
|
// Display GLPI footer
|
2026-08-07 14:27:33 +02:00
|
|
|
Html::footer();
|