diff --git a/api_v1_channels.php b/api_v1_channels.php index d0ac881..2eca980 100644 --- a/api_v1_channels.php +++ b/api_v1_channels.php @@ -127,13 +127,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $stmt = db()->prepare("INSERT INTO channels (server_id, name, type, allow_file_sharing, ai_moderation_enabled, message_limit, icon, category_id, position, rules_role_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); $stmt->execute([$server_id, $name, $type, $allow_file_sharing, $ai_moderation_enabled, $message_limit, $icon, $category_id, $nextPos, $rules_role_id]); $channel_id = db()->lastInsertId(); - - if ($type === 'support') { - $stmtTags = db()->prepare("INSERT INTO forum_tags (channel_id, name, color) VALUES (?, ?, ?)"); - $stmtTags->execute([$channel_id, 'Ticket prioritaire', '#dc3545']); - $stmtTags->execute([$channel_id, 'Ticket non prioritaire', '#6c757d']); - $stmtTags->execute([$channel_id, 'Ticket urgent', '#ffc107']); - } header('Location: index.php?server_id=' . $server_id . '&channel_id=' . $channel_id); exit; @@ -142,4 +135,4 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } } } -header('Location: index.php'); \ No newline at end of file +header('Location: index.php'); diff --git a/api_v1_tags.php b/api_v1_tags.php index 8da7fdb..ae4e341 100644 --- a/api_v1_tags.php +++ b/api_v1_tags.php @@ -46,28 +46,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { echo json_encode(['success' => true, 'tag_id' => db()->lastInsertId()]); } elseif ($action === 'delete') { $tag_id = $data['tag_id'] ?? 0; - - // Check if it's a default tag in a support channel - $stmtCheck = db()->prepare(" - SELECT t.name, c.type - FROM forum_tags t - JOIN channels c ON t.channel_id = c.id - WHERE t.id = ? - "); - $stmtCheck->execute([$tag_id]); - $tag = $stmtCheck->fetch(); - - if ($tag && $tag['type'] === 'support') { - $defaults = ['Ticket prioritaire', 'Ticket non prioritaire', 'Ticket urgent']; - if (in_array($tag['name'], $defaults)) { - echo json_encode(['success' => false, 'error' => 'Default support tags cannot be deleted']); - exit; - } - } - $stmt = db()->prepare("DELETE FROM forum_tags WHERE id = ? AND channel_id = ?"); $stmt->execute([$tag_id, $channel_id]); echo json_encode(['success' => true]); } exit; -} \ No newline at end of file +} diff --git a/api_v1_threads.php b/api_v1_threads.php index 2a487d0..2903d23 100644 --- a/api_v1_threads.php +++ b/api_v1_threads.php @@ -4,13 +4,10 @@ require_once 'auth/session.php'; require_once 'includes/permissions.php'; requireLogin(); -$user_id = $_SESSION['user_id']; - if ($_SERVER['REQUEST_METHOD'] === 'POST') { $channel_id = $_POST['channel_id'] ?? 0; $title = $_POST['title'] ?? ''; - $is_private = isset($_POST['is_private']) && $_POST['is_private'] == '1' ? 1 : 0; - $content = $_POST['content'] ?? ''; + $user_id = $_SESSION['user_id']; if (!$channel_id || !$title) { echo json_encode(['success' => false, 'error' => 'Missing data']); @@ -29,8 +26,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { try { db()->beginTransaction(); - $stmt = db()->prepare("INSERT INTO forum_threads (channel_id, user_id, title, is_private) VALUES (?, ?, ?, ?)"); - $stmt->execute([$channel_id, $user_id, $title, $is_private]); + $stmt = db()->prepare("INSERT INTO forum_threads (channel_id, user_id, title) VALUES (?, ?, ?)"); + $stmt->execute([$channel_id, $user_id, $title]); $thread_id = db()->lastInsertId(); if (!empty($tag_ids)) { @@ -39,23 +36,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($tag_id) $stmtTag->execute([$thread_id, $tag_id]); } } - - if ($content) { - $stmtMsg = db()->prepare("INSERT INTO messages (channel_id, thread_id, user_id, content) VALUES (?, ?, ?, ?)"); - $stmtMsg->execute([$channel_id, $thread_id, $user_id, $content]); - $message_id = db()->lastInsertId(); - - // Default reactions for support tickets - $stmtChan = db()->prepare("SELECT type FROM channels WHERE id = ?"); - $stmtChan->execute([$channel_id]); - $chan = $stmtChan->fetch(); - if ($chan && $chan['type'] === 'support') { - $stmtReact = db()->prepare("INSERT IGNORE INTO message_reactions (message_id, user_id, emoji) VALUES (?, ?, ?)"); - $stmtReact->execute([$message_id, $user_id, '👍']); - $stmtReact->execute([$message_id, $user_id, '👎']); - } - } - db()->commit(); echo json_encode(['success' => true, 'thread_id' => $thread_id]); } catch (Exception $e) { @@ -75,6 +55,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'PATCH' || $_SERVER['REQUEST_METHOD'] === 'DE $action = 'delete'; } + $user_id = $_SESSION['user_id']; + if (!$thread_id) { echo json_encode(['success' => false, 'error' => 'Missing thread_id']); exit; @@ -151,4 +133,4 @@ if ($_SERVER['REQUEST_METHOD'] === 'PATCH' || $_SERVER['REQUEST_METHOD'] === 'DE echo json_encode(['success' => false, 'error' => $e->getMessage()]); } exit; -} \ No newline at end of file +} diff --git a/assets/js/main.js b/assets/js/main.js index 20b558e..3f22b38 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -2665,17 +2665,6 @@ document.addEventListener('DOMContentLoaded', () => { } } catch (e) { console.error(e); } - const privacySection = document.getElementById("new-thread-privacy-section"); - if (window.activeChannelType === "support") { - privacySection.classList.remove("d-none"); - document.getElementById("newThreadModal").querySelector(".modal-title").textContent = "Nouveau Ticket"; - document.getElementById("submit-new-thread-btn").textContent = "Créer le ticket"; - } else { - privacySection.classList.add("d-none"); - document.getElementById("newThreadModal").querySelector(".modal-title").textContent = "Nouvelle discussion"; - document.getElementById("submit-new-thread-btn").textContent = "Créer la discussion"; - } - newThreadModal.show(); }); diff --git a/assets/pasted-20260314-230223-381646c4.png b/assets/pasted-20260314-230223-381646c4.png new file mode 100644 index 0000000..7fa50c6 Binary files /dev/null and b/assets/pasted-20260314-230223-381646c4.png differ diff --git a/includes/permissions.php b/includes/permissions.php index ce064d0..80bc29f 100644 --- a/includes/permissions.php +++ b/includes/permissions.php @@ -53,34 +53,6 @@ class Permissions { return self::canDoInChannel($user_id, $channel_id, self::SEND_MESSAGES); } - public static function canViewThread($user_id, $thread_id) { - $stmt = db()->prepare(" - SELECT t.*, c.type as channel_type, c.server_id - FROM forum_threads t - JOIN channels c ON t.channel_id = c.id - WHERE t.id = ? - "); - $stmt->execute([$thread_id]); - $thread = $stmt->fetch(); - if (!$thread) return false; - - // If it's not private, anyone who can view the channel can view the thread - if (!$thread['is_private']) { - return self::canViewChannel($user_id, $thread['channel_id']); - } - - // If private: - // 1. Creator can view - if ($thread['user_id'] == $user_id) return true; - - // 2. Admins/Moderators can view - if (self::hasPermission($user_id, $thread['server_id'], self::ADMINISTRATOR)) return true; - if (self::hasPermission($user_id, $thread['server_id'], self::MANAGE_MESSAGES)) return true; - if (self::hasPermission($user_id, $thread['server_id'], self::MANAGE_CHANNELS)) return true; - - return false; - } - public static function canDoInChannel($user_id, $channel_id, $permission) { $stmt = db()->prepare("SELECT server_id FROM channels WHERE id = ?"); $stmt->execute([$channel_id]); @@ -155,4 +127,4 @@ class Permissions { // Fallback to base permissions return self::hasPermission($user_id, $server_id, $permission); } -} \ No newline at end of file +} diff --git a/index.php b/index.php index 9b3390d..1211b2b 100644 --- a/index.php +++ b/index.php @@ -234,11 +234,10 @@ if ($is_dm_view) { $active_server = $s; $is_owner = ($s['owner_id'] == $current_user_id); $can_manage_channels = Permissions::hasPermission($current_user_id, $active_server_id, Permissions::MANAGE_CHANNELS) || $is_owner; - $can_manage_server = Permissions::hasPermission($current_user_id, $active_server_id, Permissions::MANAGE_SERVER) || + $can_manage_server = Permissions::hasPermission($current_user_id, $active_server_id, Permissions::MANAGE_SERVER) || Permissions::hasPermission($current_user_id, $active_server_id, Permissions::MANAGE_MESSAGES) || - Permissions::hasPermission($current_user_id, $active_server_id, Permissions::ADMINISTRATOR) || + Permissions::hasPermission($current_user_id, $active_server_id, Permissions::ADMINISTRATOR) || $is_owner; - $can_manage_support = $can_manage_server || Permissions::hasPermission($current_user_id, $active_server_id, Permissions::MANAGE_CHANNELS); // Event permissions $can_create_event = Permissions::canDoInChannel($current_user_id, $active_channel_id, Permissions::CREATE_EVENT); @@ -258,7 +257,7 @@ if ($is_dm_view) { $active_thread = null; if ($active_thread_id) { - $stmt = db()->prepare("SELECT t.*, u.display_name as username, u.username as login_name FROM forum_threads t JOIN users u ON t.user_id = u.id WHERE t.id = ?"); + $stmt = db()->prepare("SELECT t.*, (SELECT GROUP_CONCAT(CONCAT(ft.name, ':', ft.color) SEPARATOR '|') FROM thread_tags tt JOIN forum_tags ft ON tt.tag_id = ft.id WHERE tt.thread_id = t.id) as tags, u.display_name as username, u.username as login_name FROM forum_threads t JOIN users u ON t.user_id = u.id WHERE t.id = ?"); $stmt->execute([$active_thread_id]); $active_thread = $stmt->fetch(); @@ -298,32 +297,26 @@ if ($is_dm_view) { } elseif ($channel_type === 'autorole') { $stmt = db()->prepare("SELECT ca.*, r.name as role_name FROM channel_autoroles ca JOIN roles r ON ca.role_id = r.id WHERE ca.channel_id = ? ORDER BY ca.id ASC"); $stmt->execute([$active_channel_id]); - } elseif ($channel_type === "forum" || $channel_type === "support") { + $autoroles = $stmt->fetchAll(); + } elseif ($channel_type === 'forum') { $tag_where = ""; - $private_where = ""; $query_params = [$active_server_id, $active_server_id, $active_channel_id]; if (!empty($selected_tag_ids)) { - $placeholders = implode(",", array_fill(0, count($selected_tag_ids), "?")); + $placeholders = implode(',', array_fill(0, count($selected_tag_ids), '?')); $tag_where = " AND EXISTS (SELECT 1 FROM thread_tags tt WHERE tt.thread_id = t.id AND tt.tag_id IN ($placeholders))"; foreach ($selected_tag_ids as $tid) $query_params[] = $tid; } - if (!$can_manage_support) { - $private_where = " AND (t.is_private = 0 OR t.user_id = ?)"; - $query_params[] = $current_user_id; - } - $stmt = db()->prepare(" - SELECT t.*, u.display_name as username, u.avatar_url, + SELECT t.*, (SELECT GROUP_CONCAT(CONCAT(ft.name, ':', ft.color) SEPARATOR '|') FROM thread_tags tt JOIN forum_tags ft ON tt.tag_id = ft.id WHERE tt.thread_id = t.id) as tags, u.display_name as username, u.avatar_url, (SELECT COUNT(*) FROM messages m WHERE m.thread_id = t.id) as message_count, (SELECT MAX(created_at) FROM messages m WHERE m.thread_id = t.id) as last_message_at, (SELECT r.color FROM roles r JOIN user_roles ur ON r.id = ur.role_id WHERE ur.user_id = u.id AND r.server_id = ? ORDER BY r.position DESC LIMIT 1) as role_color, - (SELECT r.icon_url FROM roles r JOIN user_roles ur ON r.id = ur.role_id WHERE ur.user_id = u.id AND r.server_id = ? ORDER BY r.position DESC LIMIT 1) as role_icon, - (SELECT GROUP_CONCAT(CONCAT(ft.name, "-", ft.color) SEPARATOR "|") FROM thread_tags tt JOIN forum_tags ft ON tt.tag_id = ft.id WHERE tt.thread_id = t.id) as tags + (SELECT r.icon_url FROM roles r JOIN user_roles ur ON r.id = ur.role_id WHERE ur.user_id = u.id AND r.server_id = ? ORDER BY r.position DESC LIMIT 1) as role_icon FROM forum_threads t JOIN users u ON t.user_id = u.id - WHERE t.channel_id = ? $tag_where $private_where + WHERE t.channel_id = ? $tag_where ORDER BY t.is_pinned DESC, last_message_at DESC "); $stmt->execute($query_params); @@ -706,7 +699,6 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; - elseif ($c["type"] === "support") echo ""; () @@ -853,7 +845,6 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; elseif ($active_channel['type'] === 'autorole') echo ''; elseif ($active_channel['type'] === 'forum') echo ''; elseif ($active_channel['type'] === 'voice') echo ''; - elseif ($active_channel["type"] === "support") echo ""; elseif ($active_channel['type'] === 'poll') echo ''; else echo ''; @@ -935,11 +926,8 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
"> - - - SOLUTION - -
+ +
@@ -954,6 +942,9 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
+ + SOLUTION +
@@ -1374,11 +1365,11 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
- +
-

+

🏛️

- Dernière activité : + Dernière activité :
@@ -1493,7 +1484,22 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; - + + +
+ + + + + + + + + + + +
+ @@ -2733,7 +2739,6 @@ document.addEventListener('DOMContentLoaded', () => { - @@ -2759,7 +2764,6 @@ document.addEventListener('DOMContentLoaded', () => { - @@ -3543,21 +3547,14 @@ document.addEventListener('DOMContentLoaded', () => {
-
- -
-
-
- - -
-
+
+ diff --git a/index.php_partial_fix b/index.php_partial_fix deleted file mode 100644 index 4f618ac..0000000 --- a/index.php_partial_fix +++ /dev/null @@ -1,104 +0,0 @@ - -
-
📊 SONDAGE
- -
- - -
- - - -
- $opt): - $count = 0; - $user_voted = false; - if (isset($m['votes_data'])) { - foreach($m['votes_data'] as $v) { - if ($v['option_index'] == $idx) { - $count = $v['vote_count']; - $user_ids = explode(',', $v['user_ids'] ?? ''); - if (in_array($current_user_id, $user_ids)) { - $user_voted = true; - } - break; - } - } - } - $percent = $total_votes > 0 ? round(($count / $total_votes) * 100) : 0; - $is_expired = !empty($meta['end_date']) && strtotime($meta['end_date']) < time(); - ?> -
-
-
- - % () -
-
- -
- -
- -
- -
- - - - - -
- - - -
- -
- - -
- -
- - -
- - - - - - -
- -
- -
- - \ No newline at end of file