From: Marcel Werk Date: Thu, 2 May 2013 13:45:48 +0000 (+0200) Subject: Added user ban function X-Git-Tag: 2.0.0_Beta_1~265 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=11cf19be278579e493e8b32b52f1d3b18ebebc24;p=GitHub%2FWoltLab%2FWCF.git Added user ban function --- diff --git a/wcfsetup/install/files/acp/js/WCF.ACP.js b/wcfsetup/install/files/acp/js/WCF.ACP.js index 81d70fade3..22f58eb772 100644 --- a/wcfsetup/install/files/acp/js/WCF.ACP.js +++ b/wcfsetup/install/files/acp/js/WCF.ACP.js @@ -1729,3 +1729,110 @@ WCF.ACP.Search = WCF.Search.Base.extend({ window.location = this._list.find('li.dropdownNavigationItem > a').attr('href'); } }); + +/** + * Namespace for user management. + */ +WCF.ACP.User = { }; + +/** + * Generic implementation to ban users. + */ +WCF.ACP.User.BanHandler = { + /** + * callback object + * @var object + */ + _callback: null, + + /** + * dialog overlay + * @var jQuery + */ + _dialog: null, + + /** + * action proxy + * @var WCF.Action.Proxy + */ + _proxy: null, + + /** + * Initializes WCF.ACP.User.BanHandler on first use. + */ + init: function() { + this._dialog = $('
').hide().appendTo(document.body); + this._proxy = new WCF.Action.Proxy({ + success: $.proxy(this._success, this) + }); + + $('.jsBanButton').click($.proxy(function(event) { + var $button = $(event.currentTarget); + if ($button.data('banned')) { + this.unban([ $button.data('objectID') ]); + } + else { + this.ban([ $button.data('objectID') ]); + } + }, this)); + }, + + /** + * Unbans users. + * + * @param array userIDs + */ + unban: function(userIDs) { + this._proxy.setOption('data', { + actionName: 'unban', + className: 'wcf\\data\\user\\UserAction', + objectIDs: userIDs + }); + this._proxy.sendRequest(); + }, + + /** + * Bans users. + * + * @param array userIDs + */ + ban: function(userIDs) { + WCF.System.Confirmation.show(WCF.Language.get('wcf.acp.user.ban.sure'), $.proxy(function(action) { + if (action === 'confirm') { + this._proxy.setOption('data', { + actionName: 'ban', + className: 'wcf\\data\\user\\UserAction', + objectIDs: userIDs, + parameters: { + banReason: $('#userBanReason').val() + } + }); + this._proxy.sendRequest(); + } + }, this), '', $('