This commit is contained in:
2026-09-20 21:43:02 +02:00
parent 5601c282b7
commit 4e857fd5ef
26 changed files with 3567 additions and 142 deletions
+34
View File
@@ -926,6 +926,40 @@
}
}, { hideReason: true, confirmText: 'Apply Role', unsafeContent: true });
}
async function adminSetGroups(btn) {
var id = btn.dataset.id;
var userName = btn.dataset.name;
var currentGroups = (btn.dataset.groups || '').split(',').map(function(s) { return s.trim().toLowerCase(); }).filter(Boolean);
var is4chan = currentGroups.indexOf('4chan') !== -1;
var hint = 'Manage groups for <strong>' + escHTML(userName) + '</strong>:<br><br>' +
'<label style="display:flex;align-items:center;gap:10px;cursor:pointer;padding:8px 12px;background:rgba(255,255,255,0.05);border-radius:6px;border:1px solid rgba(255,255,255,0.1);">' +
'<input type="checkbox" id="group-4chan-checkbox" value="4chan"' + (is4chan ? ' checked' : '') + ' style="width:18px;height:18px;accent-color:#4ade80;cursor:pointer;">' +
'<span><strong style="color:#4ade80;">🍀 4chan</strong> — Grants access to the 4chan catalogue, thread viewer, and rehosting</span>' +
'</label>';
ModAction.confirm('Manage Groups', hint, async () => {
var chk = document.getElementById('group-4chan-checkbox') || document.querySelector('#mod-action-content input[type="checkbox"]');
var newGroups = [];
if (chk && chk.checked) newGroups.push('4chan');
var res = await fetch('/api/v2/admin/users/set-groups', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': window.f0ckSession?.csrf_token },
body: JSON.stringify({ user_id: id, groups: newGroups })
});
var data = await res.json();
if (data.success) {
showFlash(data.msg, 'success');
btn.dataset.groups = newGroups.join(',');
var labelEl = document.querySelector('.groups-label-' + id);
if (labelEl) labelEl.textContent = newGroups.indexOf('4chan') !== -1 ? '4chan' : 'Groups';
} else {
throw new Error(data.msg || 'Failed to update groups');
}
}, { hideReason: true, confirmText: 'Save Groups', unsafeContent: true });
}
</script>
</div>
</div>