Autosave: 20260215-235418
This commit is contained in:
parent
b5ae307f55
commit
c987b0caba
@ -54,6 +54,27 @@ if ($_SERVER['REQUEST_METHOD'] === 'DELETE') {
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'PATCH') {
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
if (isset($data['order'])) {
|
||||
// Bulk reorder
|
||||
foreach ($data['order'] as $index => $id) {
|
||||
// Basic permission check (optional but recommended: verify all rules belong to same server user can manage)
|
||||
if ($index === 0) {
|
||||
$stmt = db()->prepare("SELECT c.server_id FROM channels c JOIN channel_rules r ON c.id = r.channel_id WHERE r.id = ?");
|
||||
$stmt->execute([$id]);
|
||||
$res = $stmt->fetch();
|
||||
if (!$res || !Permissions::hasPermission($user_id, $res['server_id'], Permissions::MANAGE_CHANNELS)) {
|
||||
echo json_encode(['success' => false, 'error' => 'Unauthorized']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$stmt = db()->prepare("UPDATE channel_rules SET position = ? WHERE id = ?");
|
||||
$stmt->execute([$index + 1, $id]);
|
||||
}
|
||||
echo json_encode(['success' => true]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = $data['id'] ?? 0;
|
||||
$dir = $data['dir'] ?? 'up';
|
||||
|
||||
|
||||
@ -890,7 +890,11 @@ body {
|
||||
/* Rules Style */
|
||||
.rule-item {
|
||||
transition: transform 0.2s;
|
||||
cursor: default;
|
||||
cursor: grab;
|
||||
}
|
||||
|
||||
.rule-item:active {
|
||||
cursor: grabbing;
|
||||
}
|
||||
|
||||
.rule-item:hover {
|
||||
|
||||
@ -128,7 +128,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
// Scroll to bottom
|
||||
scrollToBottom(true);
|
||||
|
||||
const currentChannel = new URLSearchParams(window.location.search).get('channel_id') || 1;
|
||||
const currentChannel = window.activeChannelId || new URLSearchParams(window.location.search).get('channel_id') || 1;
|
||||
const currentThread = new URLSearchParams(window.location.search).get('thread_id');
|
||||
let typingTimeout;
|
||||
|
||||
@ -1868,8 +1868,25 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
// Rules: Add Rule
|
||||
const addRuleBtn = document.getElementById('add-rule-btn');
|
||||
addRuleBtn?.addEventListener('click', async () => {
|
||||
const content = prompt('Rule Content:');
|
||||
const addRuleForm = document.getElementById('add-rule-form');
|
||||
const newRuleContent = document.getElementById('new-rule-content');
|
||||
const saveNewRuleBtn = document.getElementById('save-new-rule-btn');
|
||||
const cancelNewRuleBtn = document.getElementById('cancel-new-rule-btn');
|
||||
|
||||
addRuleBtn?.addEventListener('click', () => {
|
||||
addRuleBtn.style.display = 'none';
|
||||
addRuleForm.style.display = 'block';
|
||||
newRuleContent.focus();
|
||||
});
|
||||
|
||||
cancelNewRuleBtn?.addEventListener('click', () => {
|
||||
addRuleBtn.style.display = 'block';
|
||||
addRuleForm.style.display = 'none';
|
||||
newRuleContent.value = '';
|
||||
});
|
||||
|
||||
saveNewRuleBtn?.addEventListener('click', async () => {
|
||||
const content = newRuleContent.value.trim();
|
||||
if (!content) return;
|
||||
|
||||
try {
|
||||
@ -1886,6 +1903,28 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
} catch (e) { console.error(e); }
|
||||
});
|
||||
|
||||
const rulesListSortable = document.getElementById('rules-list-sortable');
|
||||
if (typeof Sortable !== 'undefined' && rulesListSortable) {
|
||||
new Sortable(rulesListSortable, {
|
||||
animation: 150,
|
||||
ghostClass: 'sortable-ghost',
|
||||
onEnd: async () => {
|
||||
const order = Array.from(rulesListSortable.querySelectorAll('.rule-item')).map(el => el.dataset.id);
|
||||
// Update numbers in UI
|
||||
rulesListSortable.querySelectorAll('.rule-item').forEach((item, index) => {
|
||||
const numEl = item.querySelector('.rule-number');
|
||||
if (numEl) numEl.textContent = `${index + 1}.`;
|
||||
});
|
||||
|
||||
await fetch('api_v1_rules.php', {
|
||||
method: 'PATCH',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ order: order })
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Rules: Delete/Edit
|
||||
document.addEventListener('click', async (e) => {
|
||||
if (e.target.classList.contains('delete-rule-btn')) {
|
||||
|
||||
@ -2,3 +2,7 @@
|
||||
2026-02-15 23:35:48 - Server: 1 - Orders: [{"id":"10","position":0,"category_id":null},{"id":"1","position":1,"category_id":null},{"id":"6","position":2,"category_id":null},{"id":"2","position":3,"category_id":null},{"id":"9","position":4,"category_id":null},{"id":"3","position":5,"category_id":null}]
|
||||
2026-02-15 23:36:25 - Server: 1 - Orders: [{"id":"10","position":0,"category_id":null},{"id":"1","position":1,"category_id":"10"},{"id":"6","position":2,"category_id":"10"},{"id":"2","position":3,"category_id":null},{"id":"9","position":4,"category_id":null},{"id":"3","position":5,"category_id":null}]
|
||||
2026-02-15 23:36:28 - Server: 1 - Orders: [{"id":"10","position":0,"category_id":null},{"id":"1","position":1,"category_id":"10"},{"id":"6","position":2,"category_id":"10"},{"id":"2","position":3,"category_id":"10"},{"id":"9","position":4,"category_id":null},{"id":"3","position":5,"category_id":null}]
|
||||
2026-02-15 23:39:25 - Server: 1 - Orders: [{"id":"11","position":0,"category_id":null},{"id":"10","position":1,"category_id":null},{"id":"1","position":2,"category_id":"10"},{"id":"6","position":3,"category_id":"10"},{"id":"2","position":4,"category_id":"10"},{"id":"9","position":5,"category_id":null},{"id":"3","position":6,"category_id":null}]
|
||||
2026-02-15 23:39:45 - Server: 1 - Orders: [{"id":"11","position":0,"category_id":null},{"id":"12","position":1,"category_id":null},{"id":"10","position":2,"category_id":null},{"id":"1","position":3,"category_id":"10"},{"id":"6","position":4,"category_id":"10"},{"id":"2","position":5,"category_id":"10"},{"id":"9","position":6,"category_id":null},{"id":"3","position":7,"category_id":null}]
|
||||
2026-02-15 23:40:11 - Server: 1 - Orders: [{"id":"11","position":0,"category_id":null},{"id":"12","position":1,"category_id":null},{"id":"10","position":2,"category_id":null},{"id":"1","position":3,"category_id":"10"},{"id":"6","position":4,"category_id":"10"},{"id":"2","position":5,"category_id":"10"},{"id":"13","position":6,"category_id":null},{"id":"9","position":7,"category_id":null},{"id":"3","position":8,"category_id":null}]
|
||||
2026-02-15 23:40:20 - Server: 1 - Orders: [{"id":"11","position":0,"category_id":null},{"id":"12","position":1,"category_id":null},{"id":"10","position":2,"category_id":null},{"id":"1","position":3,"category_id":"10"},{"id":"6","position":4,"category_id":"10"},{"id":"2","position":5,"category_id":"10"},{"id":"14","position":6,"category_id":null},{"id":"13","position":7,"category_id":null},{"id":"9","position":8,"category_id":null},{"id":"3","position":9,"category_id":null}]
|
||||
|
||||
13
index.php
13
index.php
@ -234,6 +234,7 @@ $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.activeChannelId = <?php echo $active_channel_id; ?>;
|
||||
window.currentChannelName = "<?php echo addslashes($current_channel_name); ?>";
|
||||
window.isDndMode = <?php echo ($user['dnd_mode'] ?? 0) ? 'true' : 'false'; ?>;
|
||||
window.soundNotifications = <?php echo ($user['sound_notifications'] ?? 0) ? 'true' : 'false'; ?>;
|
||||
@ -580,9 +581,10 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
<div class="rules-container p-4">
|
||||
<h2 class="mb-4">📜 <?php echo htmlspecialchars($current_channel_name); ?></h2>
|
||||
<div id="rules-list-sortable">
|
||||
<?php foreach($rules as $rule): ?>
|
||||
<?php $i = 1; foreach($rules as $rule): ?>
|
||||
<div class="rule-item mb-3 p-3 rounded bg-dark border-start border-4 border-primary d-flex justify-content-between align-items-center" data-id="<?php echo $rule['id']; ?>">
|
||||
<div class="rule-content flex-grow-1">
|
||||
<span class="rule-number fw-bold me-2"><?php echo $i++; ?>.</span>
|
||||
<?php echo nl2br(htmlspecialchars($rule['content'])); ?>
|
||||
</div>
|
||||
<?php if($can_manage_channels): ?>
|
||||
@ -597,7 +599,14 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php if($can_manage_channels): ?>
|
||||
<button class="btn btn-primary mt-3" id="add-rule-btn">+ Add a Rule</button>
|
||||
<div id="add-rule-form" style="display: none;" class="mt-3 p-3 rounded bg-dark border border-secondary">
|
||||
<textarea id="new-rule-content" class="form-control bg-dark text-white mb-2" placeholder="Saisissez la règle ici..." rows="3"></textarea>
|
||||
<div class="d-flex gap-2">
|
||||
<button class="btn btn-success btn-sm" id="save-new-rule-btn">Enregistrer</button>
|
||||
<button class="btn btn-secondary btn-sm" id="cancel-new-rule-btn">Annuler</button>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-primary mt-3" id="add-rule-btn">+ Ajouter une règle</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php elseif($channel_type === 'forum'): ?>
|
||||
|
||||
39
requests.log
39
requests.log
@ -10,3 +10,42 @@
|
||||
2026-02-15 23:36:35 - GET /index.php?server_id=1&channel_id=2 - POST: []
|
||||
2026-02-15 23:38:20 - GET /index.php?server_id=1&channel_id=6 - POST: []
|
||||
2026-02-15 23:38:22 - GET /index.php?server_id=1&channel_id=1 - POST: []
|
||||
2026-02-15 23:39:19 - GET /index.php?server_id=1&channel_id=11 - POST: []
|
||||
2026-02-15 23:39:43 - GET /index.php?server_id=1&channel_id=12 - POST: []
|
||||
2026-02-15 23:39:49 - GET /index.php?server_id=1&channel_id=12 - POST: []
|
||||
2026-02-15 23:40:05 - GET /index.php?server_id=1&channel_id=13 - POST: []
|
||||
2026-02-15 23:40:17 - GET /index.php?server_id=1&channel_id=14 - POST: []
|
||||
2026-02-15 23:40:21 - GET /index.php?server_id=1&channel_id=13 - POST: []
|
||||
2026-02-15 23:40:49 - GET /index.php?server_id=1&channel_id=11 - POST: []
|
||||
2026-02-15 23:42:44 - GET /?fl_project=38443 - POST: []
|
||||
2026-02-15 23:42:55 - GET /index.php?server_id=1&channel_id=11 - POST: []
|
||||
2026-02-15 23:43:28 - GET /index.php - POST: []
|
||||
2026-02-15 23:44:37 - GET /index.php?server_id=1&channel_id=11 - POST: []
|
||||
2026-02-15 23:44:49 - GET /index.php?server_id=1&channel_id=12 - POST: []
|
||||
2026-02-15 23:44:52 - GET /index.php?server_id=1&channel_id=11 - POST: []
|
||||
2026-02-15 23:44:58 - GET /index.php?server_id=1&channel_id=1 - POST: []
|
||||
2026-02-15 23:45:04 - GET /index.php?server_id=1&channel_id=2 - POST: []
|
||||
2026-02-15 23:45:05 - GET /index.php?server_id=1&channel_id=6 - POST: []
|
||||
2026-02-15 23:45:11 - GET /index.php?server_id=1&channel_id=2 - POST: []
|
||||
2026-02-15 23:45:12 - GET /index.php?server_id=1&channel_id=2 - POST: []
|
||||
2026-02-15 23:45:13 - GET /index.php?server_id=1&channel_id=1 - POST: []
|
||||
2026-02-15 23:45:17 - GET /index.php?server_id=1&channel_id=6 - POST: []
|
||||
2026-02-15 23:45:41 - GET /index.php?server_id=1&channel_id=6 - POST: []
|
||||
2026-02-15 23:46:38 - GET /index.php?server_id=1&channel_id=1 - POST: []
|
||||
2026-02-15 23:46:40 - GET /index.php?server_id=1&channel_id=2 - POST: []
|
||||
2026-02-15 23:46:42 - GET /index.php?server_id=1&channel_id=6 - POST: []
|
||||
2026-02-15 23:46:50 - GET /index.php?server_id=1&channel_id=6 - POST: []
|
||||
2026-02-15 23:47:06 - GET /index.php?server_id=1&channel_id=2 - POST: []
|
||||
2026-02-15 23:47:16 - GET /index.php?server_id=1&channel_id=2 - POST: []
|
||||
2026-02-15 23:47:23 - GET /index.php?server_id=1&channel_id=2 - POST: []
|
||||
2026-02-15 23:47:45 - GET /index.php?server_id=1&channel_id=6 - POST: []
|
||||
2026-02-15 23:48:03 - GET /index.php?server_id=1&channel_id=2 - POST: []
|
||||
2026-02-15 23:49:16 - GET /index.php?server_id=1&channel_id=6 - POST: []
|
||||
2026-02-15 23:52:12 - GET /?fl_project=38443 - POST: []
|
||||
2026-02-15 23:52:32 - GET /index.php?server_id=1&channel_id=2 - POST: []
|
||||
2026-02-15 23:52:37 - GET /index.php?server_id=1&channel_id=2 - POST: []
|
||||
2026-02-15 23:52:45 - GET /index.php?server_id=1&channel_id=11 - POST: []
|
||||
2026-02-15 23:52:53 - GET /index.php?server_id=1&channel_id=11 - POST: []
|
||||
2026-02-15 23:52:56 - GET /index.php?server_id=1&channel_id=11 - POST: []
|
||||
2026-02-15 23:53:22 - GET /index.php?server_id=1&channel_id=11 - POST: []
|
||||
2026-02-15 23:54:12 - GET /index.php?server_id=1&channel_id=11 - POST: []
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user