mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-08-29 12:16:03 +02:00
@@ -11,98 +11,105 @@ define('forum/account/moderate', [
|
||||
AccountModerate.banAccount = function (theirid, onSuccess) {
|
||||
theirid = theirid || ajaxify.data.theirid;
|
||||
|
||||
Benchpress.render('modals/temporary-ban', {}).then(function (html) {
|
||||
bootbox.dialog({
|
||||
className: 'ban-modal',
|
||||
title: '[[user:ban-account]]',
|
||||
message: html,
|
||||
show: true,
|
||||
buttons: {
|
||||
close: {
|
||||
label: '[[global:close]]',
|
||||
className: 'btn-link',
|
||||
},
|
||||
submit: {
|
||||
label: '[[user:ban-account]]',
|
||||
callback: function () {
|
||||
const formData = $('.ban-modal form').serializeArray().reduce(function (data, cur) {
|
||||
data[cur.name] = cur.value;
|
||||
return data;
|
||||
}, {});
|
||||
throwModal({
|
||||
tpl: 'modals/temporary-ban',
|
||||
title: '[[user:ban-account]]',
|
||||
onSubmit: function (formData) {
|
||||
const until = formData.length > 0 ? (
|
||||
Date.now() + (formData.length * 1000 * 60 * 60 * (parseInt(formData.unit, 10) ? 24 : 1))
|
||||
) : 0;
|
||||
api.put('/users/' + theirid + '/ban', {
|
||||
until: until,
|
||||
reason: formData.reason || '',
|
||||
}).then(() => {
|
||||
if (typeof onSuccess === 'function') {
|
||||
return onSuccess();
|
||||
}
|
||||
|
||||
const until = formData.length > 0 ? (
|
||||
Date.now() + (formData.length * 1000 * 60 * 60 * (parseInt(formData.unit, 10) ? 24 : 1))
|
||||
) : 0;
|
||||
|
||||
api.put('/users/' + theirid + '/ban', {
|
||||
until: until,
|
||||
reason: formData.reason || '',
|
||||
}).then(() => {
|
||||
if (typeof onSuccess === 'function') {
|
||||
return onSuccess();
|
||||
}
|
||||
|
||||
ajaxify.refresh();
|
||||
}).catch(alerts.error);
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
ajaxify.refresh();
|
||||
}).catch(alerts.error);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
AccountModerate.unbanAccount = function (theirid) {
|
||||
api.del('/users/' + theirid + '/ban').then(() => {
|
||||
ajaxify.refresh();
|
||||
}).catch(alerts.error);
|
||||
throwModal({
|
||||
tpl: 'modals/unban',
|
||||
title: '[[user:unban-account]]',
|
||||
onSubmit: function (formData) {
|
||||
api.del('/users/' + theirid + '/ban', {
|
||||
reason: formData.reason || '',
|
||||
}).then(() => {
|
||||
ajaxify.refresh();
|
||||
}).catch(alerts.error);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
AccountModerate.muteAccount = function (theirid, onSuccess) {
|
||||
theirid = theirid || ajaxify.data.theirid;
|
||||
Benchpress.render('modals/temporary-mute', {}).then(function (html) {
|
||||
bootbox.dialog({
|
||||
className: 'mute-modal',
|
||||
title: '[[user:mute-account]]',
|
||||
throwModal({
|
||||
tpl: 'modals/temporary-mute',
|
||||
title: '[[user:mute-account]]',
|
||||
onSubmit: function (formData) {
|
||||
const until = formData.length > 0 ? (
|
||||
Date.now() + (formData.length * 1000 * 60 * 60 * (parseInt(formData.unit, 10) ? 24 : 1))
|
||||
) : 0;
|
||||
|
||||
api.put('/users/' + theirid + '/mute', {
|
||||
until: until,
|
||||
reason: formData.reason || '',
|
||||
}).then(() => {
|
||||
if (typeof onSuccess === 'function') {
|
||||
return onSuccess();
|
||||
}
|
||||
ajaxify.refresh();
|
||||
}).catch(alerts.error);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
AccountModerate.unmuteAccount = function (theirid) {
|
||||
throwModal({
|
||||
tpl: 'modals/unmute',
|
||||
title: '[[user:unmute-account]]',
|
||||
onSubmit: function (formData) {
|
||||
api.del('/users/' + theirid + '/mute', {
|
||||
reason: formData.reason || '',
|
||||
}).then(() => {
|
||||
ajaxify.refresh();
|
||||
}).catch(alerts.error);
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
function throwModal(options) {
|
||||
Benchpress.render(options.tpl, {}).then(function (html) {
|
||||
const modal = bootbox.dialog({
|
||||
title: options.title,
|
||||
message: html,
|
||||
show: true,
|
||||
onEscape: true,
|
||||
buttons: {
|
||||
close: {
|
||||
label: '[[global:close]]',
|
||||
className: 'btn-link',
|
||||
},
|
||||
submit: {
|
||||
label: '[[user:mute-account]]',
|
||||
label: options.title,
|
||||
callback: function () {
|
||||
const formData = $('.mute-modal form').serializeArray().reduce(function (data, cur) {
|
||||
const formData = modal.find('form').serializeArray().reduce(function (data, cur) {
|
||||
data[cur.name] = cur.value;
|
||||
return data;
|
||||
}, {});
|
||||
|
||||
const until = formData.length > 0 ? (
|
||||
Date.now() + (formData.length * 1000 * 60 * 60 * (parseInt(formData.unit, 10) ? 24 : 1))
|
||||
) : 0;
|
||||
|
||||
api.put('/users/' + theirid + '/mute', {
|
||||
until: until,
|
||||
reason: formData.reason || '',
|
||||
}).then(() => {
|
||||
if (typeof onSuccess === 'function') {
|
||||
return onSuccess();
|
||||
}
|
||||
ajaxify.refresh();
|
||||
}).catch(alerts.error);
|
||||
options.onSubmit(formData);
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
AccountModerate.unmuteAccount = function (theirid) {
|
||||
api.del('/users/' + theirid + '/mute').then(() => {
|
||||
ajaxify.refresh();
|
||||
}).catch(alerts.error);
|
||||
};
|
||||
}
|
||||
|
||||
return AccountModerate;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user