diff --git a/api_v1_messages.php b/api_v1_messages.php index 30608ee..9d54e6b 100644 --- a/api_v1_messages.php +++ b/api_v1_messages.php @@ -357,7 +357,7 @@ if (isset($_POST['is_announcement']) && $_POST['is_announcement'] == '1') { // Clear content for the message text itself if we want it only in the embed // But keeping it in content might be good for search/fallback } elseif (isset($_POST['is_poll']) && $_POST['is_poll'] == '1') { - if (!Permissions::canSendInChannel($user_id, $channel_id)) { + if (!Permissions::canDoInChannel($user_id, $channel_id, Permissions::CREATE_POLL)) { echo json_encode(['success' => false, 'error' => 'You do not have permission to create polls in this channel.']); exit; } diff --git a/api_v1_roles.php b/api_v1_roles.php index 2d90d80..efeecc3 100644 --- a/api_v1_roles.php +++ b/api_v1_roles.php @@ -75,7 +75,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ['value' => 2048, 'name' => 'Speak'], ['value' => 4096, 'name' => 'Créer un événement'], ['value' => 8192, 'name' => 'Modifier un événement'], - ['value' => 16384, 'name' => 'Supprimer un événement'] + ['value' => 16384, 'name' => 'Supprimer un événement'], + ['value' => 32768, 'name' => 'Créer une annonce'], + ['value' => 65536, 'name' => 'Créer un sondage'] ] ]); exit; diff --git a/assets/js/main.js b/assets/js/main.js index 14e0f57..eccbe68 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -1625,6 +1625,12 @@ document.addEventListener('DOMContentLoaded', () => { annPerms.forEach(p => { p.style.setProperty('display', channelType === 'announcement' ? 'block' : 'none', channelType === 'announcement' ? '' : 'important'); }); + + // Show/Hide poll permissions + const pollPerms = document.querySelectorAll('.poll-permission-only'); + pollPerms.forEach(p => { + p.style.setProperty('display', channelType === 'poll' ? 'block' : 'none', channelType === 'poll' ? '' : 'important'); + }); }); }); @@ -1656,6 +1662,12 @@ document.addEventListener('DOMContentLoaded', () => { p.style.setProperty('display', type === 'announcement' ? 'block' : 'none', type === 'announcement' ? '' : 'important'); }); + // Show/Hide poll permissions + const pollPerms = document.querySelectorAll('.poll-permission-only'); + pollPerms.forEach(p => { + p.style.setProperty('display', type === 'poll' ? 'block' : 'none', type === 'poll' ? '' : 'important'); + }); + // Rules specific visibility const rulesRoleContainer = document.getElementById('edit-channel-rules-role-container'); if (rulesRoleContainer) { diff --git a/includes/permissions.php b/includes/permissions.php index a5da920..80bc29f 100644 --- a/includes/permissions.php +++ b/includes/permissions.php @@ -17,6 +17,7 @@ class Permissions { const EDIT_EVENT = 8192; const DELETE_EVENT = 16384; const CREATE_ANNOUNCEMENT = 32768; + const CREATE_POLL = 65536; public static function hasPermission($user_id, $server_id, $permission) { $stmt = db()->prepare("SELECT is_admin FROM users WHERE id = ?"); diff --git a/index.php b/index.php index dda8b8f..441d9f0 100644 --- a/index.php +++ b/index.php @@ -240,6 +240,7 @@ if ($is_dm_view) { $can_edit_event = Permissions::canDoInChannel($current_user_id, $active_channel_id, Permissions::EDIT_EVENT); $can_delete_event = Permissions::canDoInChannel($current_user_id, $active_channel_id, Permissions::DELETE_EVENT); $can_create_announcement = Permissions::canDoInChannel($current_user_id, $active_channel_id, Permissions::CREATE_ANNOUNCEMENT); + $can_create_poll = Permissions::canDoInChannel($current_user_id, $active_channel_id, Permissions::CREATE_POLL); break; } @@ -461,6 +462,8 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? ''; window.isServerOwner = ; window.canManageServer = ; window.canManageChannels = ; + window.canCreatePoll = ; + window.canCreateAnnouncement = ; window.activeChannelId = ; window.activeChannelType = ""; window.currentChannelName = ""; @@ -969,7 +972,7 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
Participez aux sondages de la communauté.
- + @@ -983,7 +986,7 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';Soyez le premier à poser une question !
@@ -3244,6 +3247,25 @@ document.addEventListener('DOMContentLoaded', () => { + +