From f034d0ecabafc013008639356465c2c606401f7d Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sat, 28 Jun 2014 12:06:08 +0200 Subject: [PATCH] Add expiration date for user ban and disabled avatar/signature --- com.woltlab.wcf/cronjob.xml | 14 +++ com.woltlab.wcf/templates/user.tpl | 12 ++ wcfsetup/install/files/acp/js/WCF.ACP.js | 67 ++++++++--- .../install/files/acp/templates/userAdd.tpl | 110 +++++++++++++++++- .../install/files/acp/templates/userList.tpl | 3 + wcfsetup/install/files/js/WCF.User.js | 56 +++++++-- .../files/lib/acp/form/UserAddForm.class.php | 26 ++++- .../files/lib/acp/form/UserEditForm.class.php | 83 ++++++++++--- .../files/lib/data/user/UserAction.class.php | 62 ++++++++-- .../system/cronjob/UserBanCronjob.class.php | 65 +++++++++++ wcfsetup/install/lang/de.xml | 18 +++ wcfsetup/install/lang/en.xml | 18 +++ wcfsetup/setup/db/install.sql | 3 + 13 files changed, 484 insertions(+), 53 deletions(-) create mode 100644 wcfsetup/install/files/lib/system/cronjob/UserBanCronjob.class.php diff --git a/com.woltlab.wcf/cronjob.xml b/com.woltlab.wcf/cronjob.xml index 6a46e9969f..00a2771b30 100644 --- a/com.woltlab.wcf/cronjob.xml +++ b/com.woltlab.wcf/cronjob.xml @@ -162,5 +162,19 @@ 1 1 + + + + + + 0 + 1 + * + * + * + 1 + 1 + 1 + \ No newline at end of file diff --git a/com.woltlab.wcf/templates/user.tpl b/com.woltlab.wcf/templates/user.tpl index b75979ee98..75ea943af9 100644 --- a/com.woltlab.wcf/templates/user.tpl +++ b/com.woltlab.wcf/templates/user.tpl @@ -82,12 +82,24 @@ WCF.Language.addObject({ 'wcf.user.ban': '{lang}wcf.user.ban{/lang}', 'wcf.user.ban.confirmMessage': '{lang}wcf.user.ban.confirmMessage{/lang}', + 'wcf.user.ban.expires': '{lang}wcf.user.ban.expires{/lang}', + 'wcf.user.ban.expires.description': '{lang}wcf.user.ban.expires.description{/lang}', + 'wcf.user.ban.neverExpires': '{lang}wcf.user.ban.neverExpires{/lang}', 'wcf.user.ban.reason.description': '{lang}wcf.user.ban.reason.description{/lang}', 'wcf.user.unban': '{lang}wcf.user.unban{/lang}', 'wcf.user.disableAvatar': '{lang}wcf.user.disableAvatar{/lang}', + 'wcf.user.ban.expires': '{lang}wcf.user.ban.expires{/lang}', + 'wcf.user.ban.expires.description': '{lang}wcf.user.ban.expires.description{/lang}', + 'wcf.user.ban.neverExpires': '{lang}wcf.user.ban.neverExpires{/lang}', 'wcf.user.disableAvatar.confirmMessage': '{lang}wcf.user.disableAvatar.confirmMessage{/lang}', + 'wcf.user.disableAvatar.expires': '{lang}wcf.user.disableAvatar.expires{/lang}', + 'wcf.user.disableAvatar.expires.description': '{lang}wcf.user.disableAvatar.expires.description{/lang}', + 'wcf.user.disableAvatar.neverExpires': '{lang}wcf.user.disableAvatar.neverExpires{/lang}', 'wcf.user.disableSignature': '{lang}wcf.user.disableSignature{/lang}', 'wcf.user.disableSignature.confirmMessage': '{lang}wcf.user.disableSignature.confirmMessage{/lang}', + 'wcf.user.disableSignature.expires': '{lang}wcf.user.disableSignature.expires{/lang}', + 'wcf.user.disableSignature.expires.description': '{lang}wcf.user.disableSignature.expires.description{/lang}', + 'wcf.user.disableSignature.neverExpires': '{lang}wcf.user.disableSignature.neverExpires{/lang}', 'wcf.user.edit': '{lang}wcf.user.edit{/lang}', 'wcf.user.enableAvatar': '{lang}wcf.user.enableAvatar{/lang}', 'wcf.user.enableSignature': '{lang}wcf.user.enableSignature{/lang}' diff --git a/wcfsetup/install/files/acp/js/WCF.ACP.js b/wcfsetup/install/files/acp/js/WCF.ACP.js index 549baef027..f0d7ae3949 100644 --- a/wcfsetup/install/files/acp/js/WCF.ACP.js +++ b/wcfsetup/install/files/acp/js/WCF.ACP.js @@ -1988,7 +1988,6 @@ WCF.ACP.User.BanHandler = { * 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) }); @@ -2048,19 +2047,57 @@ WCF.ACP.User.BanHandler = { * @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(); + if (this._dialog === null) { + // create dialog + this._dialog = $('
').hide().appendTo(document.body); + this._dialog.append($('
+ +
+
+
+
+ +
+
+
+ + {lang}wcf.acp.user.disableSignature.expires.description{/lang} +
+
+ + {event name='disableSignatureFields'}
{/if} + + {event name='signatureFieldsets'}
{/if} @@ -359,6 +423,8 @@ {/if} + + {event name='avatarFields'} {if $__wcf->session->getPermission('admin.user.canDisableAvatar')} @@ -378,21 +444,51 @@ + +
+
+
+
+ +
+
+
+ + {lang}wcf.acp.user.disableAvatar.expires.description{/lang} +
+
+ + {event name='disableAvatarFields'} {/if} @@ -415,6 +511,8 @@ }); //]]> + + {event name='avatarFieldsets'}
{/if} diff --git a/wcfsetup/install/files/acp/templates/userList.tpl b/wcfsetup/install/files/acp/templates/userList.tpl index eecc7761e2..c91867ee7f 100644 --- a/wcfsetup/install/files/acp/templates/userList.tpl +++ b/wcfsetup/install/files/acp/templates/userList.tpl @@ -27,6 +27,9 @@ 'wcf.acp.user.banReason': '{lang}wcf.acp.user.banReason{/lang}', 'wcf.acp.user.banReason.description': '{lang}wcf.acp.user.banReason.description{/lang}', 'wcf.acp.user.ban.sure': '{lang}wcf.acp.user.ban.sure{/lang}', + 'wcf.acp.user.ban.expires': '{lang}wcf.acp.user.ban.expires{/lang}', + 'wcf.acp.user.ban.expires.description': '{lang}wcf.acp.user.ban.expires.description{/lang}', + 'wcf.acp.user.ban.neverExpires': '{lang}wcf.acp.user.ban.neverExpires{/lang}', 'wcf.acp.user.sendNewPassword.workerTitle': '{lang}wcf.acp.user.sendNewPassword.workerTitle{/lang}', 'wcf.acp.worker.abort.confirmMessage': '{lang}wcf.acp.worker.abort.confirmMessage{/lang}' }); diff --git a/wcfsetup/install/files/js/WCF.User.js b/wcfsetup/install/files/js/WCF.User.js index 7fa202b20c..d855778447 100644 --- a/wcfsetup/install/files/js/WCF.User.js +++ b/wcfsetup/install/files/js/WCF.User.js @@ -2775,6 +2775,12 @@ WCF.User.ObjectWatch.Subscribe = Class.extend({ * Handles inline editing of users. */ WCF.User.InlineEditor = WCF.InlineEditor.extend({ + /** + * dialog object + * @var jQuery + */ + _dialog: null, + /** * list of permissions * @var object @@ -2851,13 +2857,27 @@ WCF.User.InlineEditor = WCF.InlineEditor.extend({ * @param string reason */ _executeReasonAction: function(userID, optionName, reason) { + var $optionName = this._dialog.data('optionName'); + + this._dialog.find('.innerError').remove(); + + var $banExpires = ''; + if (!$('#' + $optionName + 'NeverExpires').is(':checked')) { + var $banExpires = $('#' + $optionName + 'ExpiresDatePicker').val(); + if (!$banExpires) { + this._dialog.find('#' + $optionName + 'ExpiresSettings > dd > small').prepend($('').text(WCF.Language.get('wcf.global.form.error.empty'))); + return + } + } + var $parameters = { }; - $parameters[optionName + WCF.String.ucfirst('reason')] = reason; + $parameters[$optionName + 'Reason'] = $('#' + $optionName + 'Reason').val(); + $parameters[$optionName + 'Expires'] = $banExpires; this._proxy.setOption('data', { - actionName: optionName, + actionName: $optionName, className: 'wcf\\data\\user\\UserAction', - objectIDs: [ userID ], + objectIDs: [ this._dialog.data('userID') ], parameters: $parameters }); this._proxy.sendRequest(); @@ -2935,14 +2955,26 @@ WCF.User.InlineEditor = WCF.InlineEditor.extend({ * @param string optionName */ _showReasonDialog: function(userID, optionName) { - var $languageItem = 'wcf.user.' + optionName + '.reason.description'; - var $reasonDescription = WCF.Language.get($languageItem); + if (this._dialog) { + this._dialog.remove(); + } - WCF.System.Confirmation.show(WCF.Language.get('wcf.user.' + optionName + '.confirmMessage'), $.proxy(function(action) { - if (action === 'confirm') { - this._executeReasonAction(userID, optionName, $('#wcfSystemConfirmationContent').find('textarea').val()); - } - }, this), { }, $('
' + WCF.Language.get('wcf.global.reason') + '