2024-07-27 12:07:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
function update_language(): void
|
|
|
|
{
|
|
|
|
global $user;
|
2024-10-29 17:59:36 +00:00
|
|
|
if (is_null($user)) {
|
|
|
|
$user['id'] = DEMO_USER;
|
|
|
|
}
|
2024-07-27 12:07:27 +00:00
|
|
|
set_user_language($_POST['lang'], $user['id']);
|
2024-10-29 17:59:36 +00:00
|
|
|
location('/settings/region?success=true');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (array_key_exists('success', $query)) {
|
|
|
|
if ($query['success'] == 'true') {
|
|
|
|
flash(get_string('generic.languageUpdated'), $flash);
|
|
|
|
}
|
2024-07-27 12:07:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($path[3])) {
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|
|
|
switch ($path[3]) {
|
|
|
|
case 'set_language':
|
|
|
|
update_language();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
location('/settings/region');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
location('/settings/region');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
<!doctype html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<?php require 'partials/head.php'; ?>
|
|
|
|
<title><?= get_string('page.settings'); ?> ~> ByeCorps ID </title>
|
|
|
|
<link rel="stylesheet" href="/styles/dashboard.css" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<?php include "partials/header.php" ?>
|
|
|
|
|
|
|
|
<main>
|
|
|
|
<h1><span class="fa-solid fa-fw fa-cog"></span> <?= get_string('page.settings'); ?></h1>
|
|
|
|
<div class="grid">
|
2024-10-29 17:59:36 +00:00
|
|
|
<?php
|
|
|
|
if ($_SESSION['auth']) {
|
|
|
|
include 'partials/settings_list.php';
|
|
|
|
}
|
|
|
|
?>
|
2024-07-27 12:07:27 +00:00
|
|
|
<div class="settingsthingy">
|
|
|
|
<h2><?= get_string('settings.region') ?></h2>
|
|
|
|
<p>Here you can set the language ByeCorps ID is displayed in.</p>
|
|
|
|
<form action="/settings/region/set_language" method="post">
|
2024-10-29 17:59:36 +00:00
|
|
|
<?= show_flash($flash); ?>
|
2024-07-27 12:07:27 +00:00
|
|
|
<div class="language-selector">
|
|
|
|
<?php
|
|
|
|
foreach (LANGAUGES as $lang) {
|
|
|
|
$checked = '';
|
|
|
|
if ($lang['code'] == $_SESSION['lang']) {
|
|
|
|
$checked = 'checked="checked"';
|
|
|
|
}
|
|
|
|
echo '<label>
|
|
|
|
<input type="radio" name="lang" '.$checked.' id="lang" value="'. $lang['code'] . '" />
|
2024-10-29 17:59:36 +00:00
|
|
|
'. get_string('language.'.$lang['code']) .' - '. $lang['name'] .'
|
2024-07-27 12:07:27 +00:00
|
|
|
</label>';
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
<button class='primary' type="submit"><?= get_string('button.submit') ?></button>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
|
|
|
|
<?php include 'partials/footer.php' ?>
|
|
|
|
</body>
|
|
|
|
</html>
|