From 2a5d6b5700f345e261cd63d639276cc02bc17f8b Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sun, 15 Jun 2014 20:03:13 +0200 Subject: [PATCH] Add possibility to copy user groups --- wcfsetup/install/files/acp/js/WCF.ACP.js | 58 +++++++ .../files/acp/templates/userGroupAdd.tpl | 43 +++-- .../data/user/group/UserGroupAction.class.php | 150 +++++++++++++++++- wcfsetup/install/lang/de.xml | 8 + wcfsetup/install/lang/en.xml | 8 + 5 files changed, 255 insertions(+), 12 deletions(-) diff --git a/wcfsetup/install/files/acp/js/WCF.ACP.js b/wcfsetup/install/files/acp/js/WCF.ACP.js index 845c5b5c96..549baef027 100644 --- a/wcfsetup/install/files/acp/js/WCF.ACP.js +++ b/wcfsetup/install/files/acp/js/WCF.ACP.js @@ -2090,6 +2090,64 @@ WCF.ACP.User.BanHandler = { } }; +/** + * Namespace for user group management. + */ +WCF.ACP.User.Group = { }; + +/** + * Handles copying user groups. + */ +WCF.ACP.User.Group.Copy = Class.extend({ + /** + * id of the copied group + * @var integer + */ + _groupID: 0, + + /** + * Initializes a new instance of WCF.ACP.User.Group.Copy. + * + * @param integer groupID + */ + init: function(groupID) { + this._groupID = groupID; + + $('.jsButtonUserGroupCopy').click($.proxy(this._click, this)); + }, + + /** + * Handles clicking on a 'copy user group' button. + */ + _click: function() { + var $template = $('
'); + $template.append($('
' + WCF.Language.get('wcf.acp.group.copy.copyMembers.description') + '
')); + $template.append($('
' + WCF.Language.get('wcf.acp.group.copy.copyUserGroupOptions.description') + '
')); + $template.append($('
' + WCF.Language.get('wcf.acp.group.copy.copyACLOptions.description') + '
')); + + WCF.System.Confirmation.show(WCF.Language.get('wcf.acp.group.copy.confirmMessage'), $.proxy(function(action) { + if (action === 'confirm') { + new WCF.Action.Proxy({ + autoSend: true, + data: { + actionName: 'copy', + className: 'wcf\\data\\user\\group\\UserGroupAction', + objectIDs: [ this._groupID ], + parameters: { + copyACLOptions: $('#copyACLOptions').is(':checked'), + copyMembers: $('#copyMembers').is(':checked'), + copyUserGroupOptions: $('#copyUserGroupOptions').is(':checked') + } + }, + success: function(data) { + window.location = data.returnValues.redirectURL; + } + }); + } + }, this), '', $template); + } +}); + /** * Generic implementation to enable users. */ diff --git a/wcfsetup/install/files/acp/templates/userGroupAdd.tpl b/wcfsetup/install/files/acp/templates/userGroupAdd.tpl index 7ec89d3654..293f02bf78 100644 --- a/wcfsetup/install/files/acp/templates/userGroupAdd.tpl +++ b/wcfsetup/install/files/acp/templates/userGroupAdd.tpl @@ -4,7 +4,22 @@ //groupType == 4 && $__wcf->session->getPermission('admin.user.canAddGroup')} + WCF.Language.addObject({ + 'wcf.acp.group.copy.confirmMessage': '{lang}wcf.acp.group.copy.confirmMessage{/lang}', + 'wcf.acp.group.copy.copyACLOptions': '{lang}wcf.acp.group.copy.copyACLOptions{/lang}', + 'wcf.acp.group.copy.copyACLOptions.description': '{lang}wcf.acp.group.copy.copyACLOptions.description{/lang}', + 'wcf.acp.group.copy.copyMembers': '{lang}wcf.acp.group.copy.copyMembers{/lang}', + 'wcf.acp.group.copy.copyMembers.description': '{lang}wcf.acp.group.copy.copyMembers.description{/lang}', + 'wcf.acp.group.copy.copyUserGroupOptions': '{lang}wcf.acp.group.copy.copyUserGroupOptions{/lang}', + 'wcf.acp.group.copy.copyUserGroupOptions.description': '{lang}wcf.acp.group.copy.copyUserGroupOptions.description{/lang}' + }); + + new WCF.ACP.User.Group.Copy({@$groupID}); + {/if} }); //]]> @@ -26,17 +41,23 @@