Simplifies Plesk/shared-hosting deployment (no need to set a separate document root subfolder). config.php, includes/ and sql/ are now protected via .htaccess rules instead of living outside the webroot. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
33 lines
1 KiB
PHP
33 lines
1 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../includes/bootstrap.php';
|
|
require_permission('roles.manage');
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
redirect('/admin/roles.php');
|
|
}
|
|
|
|
verify_csrf();
|
|
|
|
$id = (int) ($_POST['id'] ?? 0);
|
|
$pdo = db();
|
|
|
|
$stmt = $pdo->prepare('SELECT is_system FROM roles WHERE id = ?');
|
|
$stmt->execute([$id]);
|
|
$role = $stmt->fetch();
|
|
|
|
if (!$role) {
|
|
set_flash('error', 'Berechtigungsgruppe wurde nicht gefunden.');
|
|
} elseif ((int) $role['is_system'] === 1) {
|
|
set_flash('error', 'Diese System-Gruppe kann nicht geloescht werden.');
|
|
} else {
|
|
$countStmt = $pdo->prepare('SELECT COUNT(*) FROM user_roles WHERE role_id = ?');
|
|
$countStmt->execute([$id]);
|
|
if ((int) $countStmt->fetchColumn() > 0) {
|
|
set_flash('error', 'Diese Gruppe ist noch Benutzern zugewiesen. Bitte zuerst die Zuweisung entfernen.');
|
|
} else {
|
|
$pdo->prepare('DELETE FROM roles WHERE id = ?')->execute([$id]);
|
|
set_flash('success', 'Berechtigungsgruppe wurde geloescht.');
|
|
}
|
|
}
|
|
|
|
redirect('/admin/roles.php');
|