47 lines
1.0 KiB
PHP
47 lines
1.0 KiB
PHP
<?php
|
|
/**
|
|
* app/modules/connections/swap.php
|
|
*
|
|
* Vertauscht Endpunkt A und Endpunkt B einer Verbindung.
|
|
*/
|
|
|
|
$connectionId = (int)($_GET['id'] ?? 0);
|
|
|
|
if ($connectionId <= 0) {
|
|
$_SESSION['error'] = 'Ungueltige Verbindungs-ID';
|
|
header('Location: ?module=connections&action=list');
|
|
exit;
|
|
}
|
|
|
|
$connection = $sql->single(
|
|
"SELECT id, port_a_type, port_a_id, port_b_type, port_b_id
|
|
FROM connections
|
|
WHERE id = ?",
|
|
"i",
|
|
[$connectionId]
|
|
);
|
|
|
|
if (!$connection) {
|
|
$_SESSION['error'] = 'Verbindung nicht gefunden';
|
|
header('Location: ?module=connections&action=list');
|
|
exit;
|
|
}
|
|
|
|
$sql->set(
|
|
"UPDATE connections
|
|
SET port_a_type = ?, port_a_id = ?, port_b_type = ?, port_b_id = ?
|
|
WHERE id = ?",
|
|
"sisii",
|
|
[
|
|
(string)$connection['port_b_type'],
|
|
(int)$connection['port_b_id'],
|
|
(string)$connection['port_a_type'],
|
|
(int)$connection['port_a_id'],
|
|
$connectionId
|
|
]
|
|
);
|
|
|
|
$_SESSION['success'] = 'Endpunkte wurden vertauscht';
|
|
header('Location: ?module=connections&action=list');
|
|
exit;
|