ReleaseV15+SondageRights
This commit is contained in:
parent
87f01a5179
commit
f6a1c63d68
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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 = ?");
|
||||
|
||||
26
index.php
26
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 = <?php echo ($is_owner ?? false) ? 'true' : 'false'; ?>;
|
||||
window.canManageServer = <?php echo ($can_manage_server ?? false) ? 'true' : 'false'; ?>;
|
||||
window.canManageChannels = <?php echo ($can_manage_channels ?? false) ? 'true' : 'false'; ?>;
|
||||
window.canCreatePoll = <?php echo ($can_create_poll ?? false) ? 'true' : 'false'; ?>;
|
||||
window.canCreateAnnouncement = <?php echo ($can_create_announcement ?? false) ? 'true' : 'false'; ?>;
|
||||
window.activeChannelId = <?php echo $active_channel_id; ?>;
|
||||
window.activeChannelType = "<?php echo $channel_type ?? 'chat'; ?>";
|
||||
window.currentChannelName = "<?php echo addslashes($current_channel_name); ?>";
|
||||
@ -969,7 +972,7 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
<h2 class="mb-0"><i class="fa-solid fa-square-poll-vertical me-2"></i>Sondages</h2>
|
||||
<p class="text-muted small mb-0">Participez aux sondages de la communauté.</p>
|
||||
</div>
|
||||
<?php if (Permissions::canSendInChannel($current_user_id, $active_channel_id)): ?>
|
||||
<?php if ($can_create_poll): ?>
|
||||
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addPollModal">
|
||||
<i class="fa-solid fa-plus me-1"></i> Ajouter un sondage
|
||||
</button>
|
||||
@ -983,7 +986,7 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
<i class="fa-solid fa-square-poll-vertical" style="font-size: 4rem;"></i>
|
||||
</div>
|
||||
<h4 class="text-muted">Aucun sondage pour le moment.</h4>
|
||||
<?php if (Permissions::canSendInChannel($current_user_id, $active_channel_id)): ?>
|
||||
<?php if ($can_create_poll): ?>
|
||||
<p class="text-muted">Soyez le premier à poser une question !</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@ -3244,6 +3247,25 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="permission-item poll-permission-only mb-3 p-2 rounded" style="background: var(--separator-soft); display: none;">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div class="pe-3">
|
||||
<div class="fw-bold" style="color: #ffffff; font-size: 0.9em;">Créer des sondages</div>
|
||||
<div style="font-size: 0.75em; color: #b5bac1;">Permet de créer de nouveaux sondages dans ce salon.</div>
|
||||
</div>
|
||||
<div class="btn-group btn-group-sm perm-tri-state" data-perm-bit="65536">
|
||||
<input type="radio" class="btn-check" name="perm_65536" id="perm_65536_deny" value="deny">
|
||||
<label class="btn btn-outline-danger border-0" for="perm_65536_deny" title="Refuser"><i class="fa-solid fa-xmark"></i></label>
|
||||
|
||||
<input type="radio" class="btn-check" name="perm_65536" id="perm_65536_neutral" value="neutral" checked>
|
||||
<label class="btn btn-outline-secondary border-0" for="perm_65536_neutral" title="Neutre">/</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="perm_65536" id="perm_65536_allow" value="allow">
|
||||
<label class="btn btn-outline-success border-0" for="perm_65536_allow" title="Autoriser"><i class="fa-solid fa-check"></i></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="permission-item mb-3 p-2 rounded" style="background: var(--separator-soft);">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div class="pe-3">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user