Alpha V2.5.7
This commit is contained in:
parent
c7144cbd7e
commit
15a8dc0231
31
admin.php
31
admin.php
@ -130,15 +130,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['
|
||||
$id = (int)$_POST['id'];
|
||||
$name = $_POST["name"];
|
||||
$slug = $_POST['slug'];
|
||||
$color = $_POST["color"] ?? "#ffffff";
|
||||
$allowed_user_type = $_POST['allowed_user_type'];
|
||||
$required_level = (int)$_POST['required_level'];
|
||||
|
||||
if ($id > 0) {
|
||||
$stmt = $db->prepare("UPDATE titles SET name = ?, slug = ?, allowed_user_type = ?, required_level = ? WHERE id = ?");
|
||||
$stmt->execute([$name, $slug, $allowed_user_type, $required_level, $id]);
|
||||
$stmt = $db->prepare("UPDATE titles SET name = ?, slug = ?, allowed_user_type = ?, required_level = ?, color = ? WHERE id = ?");
|
||||
$stmt->execute([$name, $slug, $allowed_user_type, $required_level, $color, $id]);
|
||||
} else {
|
||||
$stmt = $db->prepare("INSERT INTO titles (name, slug, allowed_user_type, required_level) VALUES (?, ?, ?, ?)");
|
||||
$stmt->execute([$name, $slug, $allowed_user_type, $required_level]);
|
||||
$stmt = $db->prepare("INSERT INTO titles (name, slug, allowed_user_type, required_level, color) VALUES (?, ?, ?, ?, ?)");
|
||||
$stmt->execute([$name, $slug, $allowed_user_type, $required_level, $color]);
|
||||
}
|
||||
header("Location: admin.php?tab=badges&success=1");
|
||||
exit;
|
||||
@ -1097,6 +1098,10 @@ if ($tab === 'users') {
|
||||
<label>Niveau minimum requis</label>
|
||||
<input type="number" name="required_level" id="title_req_level" value="0" min="0">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Couleur du titre</label>
|
||||
<input type="color" name="color" id="title_color" value="#ffffff">
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 10px;">
|
||||
<button type="submit" class="btn btn-add" style="flex: 1;">ENREGISTRER</button>
|
||||
@ -1110,17 +1115,19 @@ if ($tab === 'users') {
|
||||
<th>Titre</th>
|
||||
<th>Slug</th>
|
||||
<th>Niveau</th>
|
||||
<th>Couleur</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($titles_list as $t): ?>
|
||||
<tr>
|
||||
<td><strong><?php echo htmlspecialchars($t['name']); ?></strong></td>
|
||||
<td><strong style="color: <?php echo $t['color'] ?: '#ffffff'; ?>;"><?php echo htmlspecialchars($t['name']); ?></strong></td>
|
||||
<td><code style="color: #ebcb8b;"><?php echo htmlspecialchars($t['slug']); ?></code></td>
|
||||
<td><?php echo $t['required_level']; ?></td>
|
||||
<td><div style="width: 20px; height: 20px; border-radius: 50%; background: <?php echo $t['color'] ?: '#ffffff'; ?>; border: 1px solid #2d3545;"></div></td>
|
||||
<td>
|
||||
<button class="btn btn-edit" onclick='editTitle(<?php echo json_encode($t); ?>)'>Edit</button>
|
||||
<button class="btn btn-edit" onclick='editTitle(<?php echo json_encode($t, JSON_HEX_APOS); ?>)'>Edit</button>
|
||||
<a href="?tab=badges&delete_title=<?php echo $t['id']; ?>" class="btn btn-del" onclick="return confirm('Supprimer ce titre ?')">X</a>
|
||||
</td>
|
||||
</tr>
|
||||
@ -1183,9 +1190,10 @@ if ($tab === 'users') {
|
||||
<th>Visuel</th>
|
||||
<th>Badge</th>
|
||||
<th>Slug</th>
|
||||
<th>Niveau</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($badges_list as $b): ?>
|
||||
<tr>
|
||||
@ -1194,8 +1202,9 @@ if ($tab === 'users') {
|
||||
</td>
|
||||
<td><strong><?php echo htmlspecialchars($b['name']); ?></strong></td>
|
||||
<td><code style="color: #ebcb8b;"><?php echo htmlspecialchars($b['slug']); ?></code></td>
|
||||
<td><?php echo $b['required_level']; ?></td>
|
||||
<td>
|
||||
<button class="btn btn-edit" onclick='editBadge(<?php echo json_encode($b); ?>)'>Edit</button>
|
||||
<button class="btn btn-edit" onclick='editBadge(<?php echo json_encode($b, JSON_HEX_APOS); ?>)'>Edit</button>
|
||||
<a href="?tab=badges&delete_badge=<?php echo $b['id']; ?>" class="btn btn-del" onclick="return confirm('Supprimer ce badge ?')">X</a>
|
||||
</td>
|
||||
</tr>
|
||||
@ -2235,12 +2244,14 @@ function editStatus(data) {
|
||||
document.getElementById('title_name').value = data.name;
|
||||
document.getElementById('title_slug').value = data.slug;
|
||||
document.getElementById('title_allowed_type').value = data.allowed_user_type;
|
||||
document.getElementById('title_req_level').value = data.required_level;
|
||||
document.getElementById("title_req_level").value = data.required_level;
|
||||
document.getElementById("title_color").value = data.color || "#ffffff";
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
}
|
||||
function resetTitleForm() {
|
||||
document.getElementById('titleForm').reset();
|
||||
document.getElementById('title_id').value = 0;
|
||||
document.getElementById("title_id").value = 0;
|
||||
document.getElementById("title_color").value = "#ffffff";
|
||||
}
|
||||
function editBadge(data) {
|
||||
document.getElementById('badge_id').value = data.id;
|
||||
|
||||
BIN
assets/images/badges/badge_badge_green_1772794507.png
Normal file
BIN
assets/images/badges/badge_badge_green_1772794507.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
BIN
assets/images/badges/badge_badge_red_1772794493.png
Normal file
BIN
assets/images/badges/badge_badge_red_1772794493.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
28
index.php
28
index.php
@ -6,9 +6,14 @@ $db = db();
|
||||
|
||||
$user_role = 'user';
|
||||
if (isset($_SESSION['user_id'])) {
|
||||
$stmt = $db->prepare("SELECT u.role, u.display_name, u.username, l.name as level_raw
|
||||
$stmt = $db->prepare("SELECT u.role, u.display_name, u.username, l.name as level_raw,
|
||||
u.selected_title_id, u.selected_badge_id,
|
||||
t.name as title_name,
|
||||
b.name as badge_name, b.image_url as badge_image
|
||||
FROM users u
|
||||
LEFT JOIN levels l ON u.level_id = l.id
|
||||
LEFT JOIN titles t ON u.selected_title_id = t.id
|
||||
LEFT JOIN badges b ON u.selected_badge_id = b.id
|
||||
WHERE u.id = ?");
|
||||
$stmt->execute([$_SESSION['user_id']]);
|
||||
$u_data = $stmt->fetch();
|
||||
@ -19,6 +24,11 @@ if (isset($_SESSION['user_id'])) {
|
||||
$level_num = (int)filter_var($u_data['level_raw'], FILTER_SANITIZE_NUMBER_INT);
|
||||
$_SESSION['level'] = $level_num;
|
||||
|
||||
// Save title and badge to session for modal
|
||||
$_SESSION['selected_title_name'] = $u_data['title_name'];
|
||||
$_SESSION['selected_badge_name'] = $u_data['badge_name'];
|
||||
$_SESSION['selected_badge_image'] = $u_data['badge_image'];
|
||||
|
||||
$grade_type = ($user_role === 'admin') ? 'admin' : 'utilisateur';
|
||||
$g_stmt = $db->prepare("SELECT name, image_url FROM grades
|
||||
WHERE user_type = ?
|
||||
@ -1003,9 +1013,23 @@ function getStatusColor($status, $statuses_map) {
|
||||
<?php echo htmlspecialchars($_SESSION["display_name"] ?? $_SESSION["username"]); ?>
|
||||
</span>
|
||||
</div>
|
||||
<div style="font-size: 16px; color: #88c0d0; opacity: 0.8;">
|
||||
|
||||
<?php if (!empty($_SESSION['selected_title_name'])): ?>
|
||||
<div style="font-size: 14px; font-weight: bold; color: #ebcb8b; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 5px;">
|
||||
« <?php echo htmlspecialchars($_SESSION['selected_title_name']); ?> »
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div style="font-size: 16px; color: #88c0d0; opacity: 0.8; margin-bottom: 20px;">
|
||||
Niveau <?php echo htmlspecialchars($_SESSION["level"] ?? "1"); ?>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($_SESSION['selected_badge_image'])): ?>
|
||||
<div style="margin-top: 20px; padding: 15px; background: rgba(30, 41, 59, 0.3); border-radius: 12px; display: inline-block;">
|
||||
<img src="<?php echo htmlspecialchars($_SESSION['selected_badge_image']); ?>?v=<?php echo time(); ?>" style="width: 80px; height: 80px; object-fit: contain; filter: drop-shadow(0 0 10px rgba(136, 192, 208, 0.2));" title="<?php echo htmlspecialchars($_SESSION['selected_badge_name'] ?? ''); ?>">
|
||||
<div style="font-size: 10px; color: #8c92a3; margin-top: 8px; text-transform: uppercase;">Badge Équipé</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user