1
0
Fork 0
Manager/pages/groups.php

40 lines
2.0 KiB
PHP
Raw Normal View History

2020-06-03 15:31:18 +00:00
<?php
2023-08-27 03:31:32 +00:00
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['leave'])) {
include_once 'app/FormValidator.php';
$validator = new FormValidator(array(
'group' => array('required' => true, 'regex' => '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/')
));
2023-08-27 03:31:32 +00:00
if ($validator->isValid($_POST)) {
$statementMembership = $RUNTIME['PDO']->prepare("DELETE FROM os_groups_membership WHERE GroupID = ? AND PrincipalID = ?");
$statementMembership->execute(array($_REQUEST['group'], $_SESSION['UUID']));
}
}
2023-08-23 16:16:34 +00:00
header('Location: index.php?page=groups');
die();
2021-01-06 14:28:13 +00:00
}
2023-08-27 03:31:32 +00:00
include_once 'app/OpenSim.php';
$opensim = new OpenSim();
2023-08-23 16:16:34 +00:00
$HTML->setHTMLTitle("Gruppen");
2023-08-23 16:16:35 +00:00
$HTML->importSeitenInhalt("deine-regionen.html");
2023-08-23 16:16:34 +00:00
2020-06-03 15:31:18 +00:00
$table = '<table class="table"><thead><tr><th scope="col">Name</th><th scope="col">Gründer</th><th scope="col">Aktionen</th></thead><tbody>%%ENTRY%%</tbody></table>';
2023-08-23 16:16:36 +00:00
$statementGroups = $RUNTIME['PDO']->prepare("SELECT Name,FounderID,os_groups_membership.GroupID FROM os_groups_groups JOIN os_groups_membership ON os_groups_groups.GroupID = os_groups_membership.GroupID WHERE PrincipalID = ?");
$statementGroups->execute(array($_SESSION['UUID']));
2020-06-03 15:31:18 +00:00
2023-08-27 03:31:32 +00:00
while ($rowGroups = $statementGroups->fetch()) {
2023-08-23 16:16:36 +00:00
$entry = '<tr><td>'.htmlspecialchars($rowGroups['Name']).'</td><td>'.htmlspecialchars($opensim->getUserName($rowGroups['FounderID'])).'</td><td><form action="index.php?page=groups" method="post">%%CSRF%%<input type="hidden" name="group" value="'.htmlspecialchars($rowGroups['GroupID']).'"><button type="submit" name="leave" class="btn btn-danger btn-sm">VERLASSEN</button></form></td></tr>';
$table = str_replace("%%ENTRY%%", $entry."%%ENTRY%%", $table);
2020-06-03 15:31:18 +00:00
}
$table = str_replace("%%ENTRY%%", "", $table);
$HTML->ReplaceSeitenInhalt("%%REGION-LIST%%", $table);
$HTML->build();
echo $HTML->ausgabe();