From f6047135299446e7c39f5ce73e32c9fe318a709b Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sun, 15 Feb 2026 22:48:16 +0000 Subject: [PATCH] =?UTF-8?q?barre=20de=20s=C3=A9paration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api_v1_channels.php | 4 +++- assets/css/discord.css | 13 +++++++++++ index.php | 49 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/api_v1_channels.php b/api_v1_channels.php index 1cb0822..4affb2a 100644 --- a/api_v1_channels.php +++ b/api_v1_channels.php @@ -60,6 +60,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $chan = $stmt->fetch(); if ($chan && Permissions::hasPermission($user_id, $chan['server_id'], Permissions::MANAGE_CHANNELS)) { + if ($type === 'separator' && !$name) $name = 'separator'; $name = strtolower(preg_replace('/[^a-zA-Z0-9\-]/', '-', $name)); $stmt = db()->prepare("UPDATE channels SET name = ?, type = ?, status = ?, allow_file_sharing = ?, message_limit = ?, icon = ?, category_id = ? WHERE id = ?"); $stmt->execute([$name, $type, $status, $allow_file_sharing, $message_limit, $icon, $category_id, $channel_id]); @@ -87,8 +88,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $user_id = $_SESSION['user_id']; // Check if user has permission to manage channels - if (Permissions::hasPermission($user_id, $server_id, Permissions::MANAGE_CHANNELS) && $name) { + if (Permissions::hasPermission($user_id, $server_id, Permissions::MANAGE_CHANNELS) && ($name || $type === 'separator')) { try { + if ($type === 'separator' && !$name) $name = 'separator'; // Basic sanitization for channel name $name = strtolower(preg_replace('/[^a-zA-Z0-9\-]/', '-', $name)); $allow_file_sharing = isset($_POST['allow_file_sharing']) ? 1 : 0; diff --git a/assets/css/discord.css b/assets/css/discord.css index 77347c5..00cafb0 100644 --- a/assets/css/discord.css +++ b/assets/css/discord.css @@ -229,6 +229,19 @@ body { min-height: 5px; } +.channel-item-container.separator-item { + cursor: default; +} +.channel-item-container.separator-item:hover { + background-color: transparent !important; +} +.channel-item-container.separator-item .channel-settings-btn { + opacity: 0; +} +.channel-item-container.separator-item:hover .channel-settings-btn { + opacity: 0.7 !important; +} + .sortable-ghost { opacity: 0.4; background-color: var(--blurple) !important; diff --git a/index.php b/index.php index 2e82db5..683c6a8 100644 --- a/index.php +++ b/index.php @@ -338,6 +338,28 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; // Helper to render a channel item function renderChannelItem($c, $active_channel_id, $active_server_id, $can_manage_channels) { + if ($c['type'] === 'separator') { + ?> +
+
+ + + + + +
+
Rules - + +
@@ -1166,6 +1189,7 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; +
@@ -1512,11 +1536,34 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; if (type === 'announcement') return ''; if (type === 'rules') return ''; if (type === 'forum') return ''; + if (type === 'separator') return '—'; return '#'; } function updatePrefix(typeSelect, iconSelect, prefixSpan) { if (!prefixSpan || !typeSelect) return; + + // Handle name input visibility for separator + const modal = typeSelect.closest('.modal'); + const nameInputContainer = modal.querySelector('input[name="name"]')?.closest('.mb-3'); + const iconSelectContainer = modal.querySelector('select[name="icon"]')?.closest('.mb-3'); + const fileSharingContainer = modal.querySelector('input[name="allow_file_sharing"]')?.closest('.mb-3') || modal.querySelector('input[name="allow_file_sharing"]')?.closest('.form-check'); + const limitContainer = modal.querySelector('input[name="message_limit"]')?.closest('.mb-3'); + + if (typeSelect.value === 'separator') { + if (nameInputContainer) nameInputContainer.style.display = 'none'; + if (iconSelectContainer) iconSelectContainer.style.display = 'none'; + if (fileSharingContainer) fileSharingContainer.style.display = 'none'; + if (limitContainer) limitContainer.style.display = 'none'; + if (modal.querySelector('input[name="name"]')) modal.querySelector('input[name="name"]').required = false; + } else { + if (nameInputContainer) nameInputContainer.style.display = 'block'; + if (iconSelectContainer) iconSelectContainer.style.display = 'block'; + if (fileSharingContainer) fileSharingContainer.style.display = 'block'; + if (limitContainer) limitContainer.style.display = 'block'; + if (modal.querySelector('input[name="name"]')) modal.querySelector('input[name="name"]').required = true; + } + let prefix = getPrefixForType(typeSelect.value); if (iconSelect && iconSelect.value) { prefix += ` `;