From: Alexander Ebert Date: Fri, 3 May 2013 14:39:19 +0000 (+0200) Subject: Merge branch 'master' of github.com:WoltLab/WCF X-Git-Tag: 2.0.0_Beta_1~261^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bc3b71fd1aecdf310d7f4da28a07a885dcd57b2f;p=GitHub%2FWoltLab%2FWCF.git Merge branch 'master' of github.com:WoltLab/WCF --- bc3b71fd1aecdf310d7f4da28a07a885dcd57b2f diff --cc wcfsetup/install/files/acp/js/WCF.ACP.js index 3e686ff6f7,9fe1300af9..174efe6e0b --- a/wcfsetup/install/files/acp/js/WCF.ACP.js +++ b/wcfsetup/install/files/acp/js/WCF.ACP.js @@@ -1849,3 -1729,136 +1849,136 @@@ 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)); + + // bind listener + $('.jsClipboardEditor').each($.proxy(function(index, container) { + var $container = $(container); + var $types = eval($container.data('types')); + if (WCF.inArray('com.woltlab.wcf.user', $types)) { + $container.on('clipboardAction', $.proxy(this._execute, this)); + return false; + } + }, this)); + }, + + /** + * Handles clipboard actions. + * + * @param object event + * @param string type + * @param string actionName + * @param object parameters + */ + _execute: function(event, type, actionName, parameters) { + if (actionName == 'com.woltlab.wcf.user.ban') { + this.ban(parameters.objectIDs); + } + }, + + /** + * 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), '', $('