The user list gets a switch "Mitglieder dürfen ihre Discord-Verknüpfung im Profil lösen" (users.edit, default on). Turned off, the profile shows a note instead of the button and discord_unlink.php refuses the request. The value lives in a new settings table, created automatically like the other schema additions (SCHEMA_VERSION 2). The user and group tables were wider than the 1100px content column, so the actions column (edit/delete/approve) scrolled out of view. Both pages now use the wide container and the actions column sticks to the right edge. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* Einstellungen der Website, die die Leitung in der Oberflaeche aendert (Tabelle settings).
|
|
* Fehlt ein Eintrag, gilt der Standardwert aus dem Code.
|
|
*/
|
|
|
|
// Einstellungen, die ueber admin/settings_action.php geaendert werden duerfen: Schluessel => Standardwert.
|
|
const SETTINGS_DEFAULTS = [
|
|
'discord_unlink_allowed' => '1',
|
|
];
|
|
|
|
function setting_get(string $key): string
|
|
{
|
|
static $cache = null;
|
|
if ($cache === null) {
|
|
$cache = [];
|
|
try {
|
|
foreach (db()->query('SELECT `key`, value FROM settings')->fetchAll() as $row) {
|
|
$cache[$row['key']] = (string) $row['value'];
|
|
}
|
|
} catch (PDOException $e) {
|
|
// Tabelle (noch) nicht vorhanden - Standardwerte verwenden.
|
|
}
|
|
}
|
|
|
|
return $cache[$key] ?? (SETTINGS_DEFAULTS[$key] ?? '');
|
|
}
|
|
|
|
function setting_set(string $key, string $value): void
|
|
{
|
|
db()->prepare('INSERT INTO settings (`key`, value) VALUES (?, ?) ON DUPLICATE KEY UPDATE value = VALUES(value)')
|
|
->execute([$key, $value]);
|
|
}
|
|
|
|
/** Duerfen Mitglieder ihre Discord-Verknuepfung selbst loesen? */
|
|
function discord_unlink_allowed(): bool
|
|
{
|
|
return setting_get('discord_unlink_allowed') === '1';
|
|
}
|