Adds user inline editor
authorMatthias Schmidt <gravatronics@live.com>
Mon, 24 Mar 2014 18:20:47 +0000 (19:20 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 24 Mar 2014 18:20:47 +0000 (19:20 +0100)
Also adds separate permissions for disabling avatar and signature.

12 files changed:
com.woltlab.wcf/templates/headInclude.tpl
com.woltlab.wcf/templates/user.tpl
com.woltlab.wcf/userGroupOption.xml
wcfsetup/install/files/acp/templates/header.tpl
wcfsetup/install/files/acp/templates/userAdd.tpl
wcfsetup/install/files/js/WCF.User.js
wcfsetup/install/files/lib/acp/form/UserAddForm.class.php
wcfsetup/install/files/lib/acp/form/UserEditForm.class.php
wcfsetup/install/files/lib/data/user/UserAction.class.php
wcfsetup/install/files/lib/page/UserPage.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 5474143cc730e5d1dc73ee439d6e6a9d66baad08..0432e531a83bd7697fa41d78b03e01a06ecb1da7 100644 (file)
                        'wcf.global.page.next': '{capture assign=pageNext}{lang}wcf.global.page.next{/lang}{/capture}{@$pageNext|encodeJS}',
                        'wcf.global.page.previous': '{capture assign=pagePrevious}{lang}wcf.global.page.previous{/lang}{/capture}{@$pagePrevious|encodeJS}',
                        'wcf.global.pageDirection': '{lang}wcf.global.pageDirection{/lang}',
+                       'wcf.global.reason': '{lang}wcf.global.reason{/lang}',
                        'wcf.global.sidebar.hideLeftSidebar': '{lang}wcf.global.sidebar.hideLeftSidebar{/lang}',
                        'wcf.global.sidebar.hideRightSidebar': '{lang}wcf.global.sidebar.hideRightSidebar{/lang}',
                        'wcf.global.sidebar.showLeftSidebar': '{lang}wcf.global.sidebar.showLeftSidebar{/lang}',
index 2592ad8e94bb879b54f131b113b7b996fb9715b2..a06771db0f0990461913b05b70a5d5d6603736e3 100644 (file)
                                });
                        {/if}
                        
+                       {if $isAccessible}
+                               WCF.Language.addObject({
+                                       'wcf.user.ban': '{lang}wcf.user.ban{/lang}',
+                                       'wcf.user.ban.confirmMessage': '{lang}wcf.user.ban.confirmMessage{/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.disableAvatar.confirmMessage': '{lang}wcf.user.disableAvatar.confirmMessage{/lang}',
+                                       'wcf.user.disableSignature': '{lang}wcf.user.disableSignature{/lang}',
+                                       'wcf.user.disableSignature.confirmMessage': '{lang}wcf.user.disableSignature.confirmMessage{/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}'
+                               });
+                               
+                               var $userInlineEditor = new WCF.User.InlineEditor('.userHeadline');
+                               $userInlineEditor.setPermissions({
+                                       canBanUser: {if $__wcf->session->getPermission('admin.user.canBanUser')}true{else}false{/if},
+                                       canDisableAvatar: {if $__wcf->session->getPermission('admin.user.canDisableAvatar')}true{else}false{/if},
+                                       canDisableSignature: {if $__wcf->session->getPermission('admin.user.canDisableSignature')}true{else}false{/if},
+                                       canEditUser: {if $__wcf->session->getPermission('admin.general.canUseAcp') && $__wcf->session->getPermission('admin.user.canEditUser')}true{else}false{/if}
+                               });
+                       {/if}
+                       
                        {event name='javascriptInit'}
                });
                //]]>
 
 {include file='header' sidebarOrientation='left'}
 
-<header class="boxHeadline userHeadline">
+<header class="boxHeadline userHeadline"
+       {if $isAccessible}
+               data-object-id="{@$user->userID}"
+               {if $__wcf->session->getPermission('admin.user.canBanUser')}
+                       data-banned="{@$user->banned}"
+               {/if}
+               {if $__wcf->session->getPermission('admin.user.canDisableAvatar')}
+                       data-disable-avatar="{@$user->disableAvatar}"
+               {/if}
+               {if $__wcf->session->getPermission('admin.user.canDisableSignature')}
+                       data-disable-signature="{@$user->disableSignature}"
+               {/if}
+       {/if}
+>
        <span class="framed invisible">{@$user->getAvatar()->getImageTag(48)}</span>
        
        <h1>{$user->username}{if MODULE_USER_RANK && $user->getUserTitle()} <span class="badge userTitleBadge{if $user->getRank() && $user->getRank()->cssClassName} {@$user->getRank()->cssClassName}{/if}">{$user->getUserTitle()}</span>{/if}</h1>
                                        </ul>
                                </li>
                        {/hascontent}
-                       {if $user->userID != $__wcf->user->userID}{if $user->isAccessible('canViewEmailAddress')}<li><a class="button jsTooltip" href="mailto:{@$user->getEncodedEmail()}" title="{lang}wcf.user.button.mail{/lang}"><span class="icon icon16 icon-envelope-alt"></span> <span class="invisible">{lang}wcf.user.button.mail{/lang}</span></a></li>{elseif $user->isAccessible('canMail') && $__wcf->session->getPermission('user.profile.canMail')}<li><a class="button jsTooltip" href="{link controller='Mail' object=$user}{/link}" title="{lang}wcf.user.button.mail{/lang}"><span class="icon icon16 icon-envelope-alt"></span> <span class="invisible">{lang}wcf.user.button.mail{/lang}</span></a></li>{/if}{/if}
+                       
+                       {if $user->userID != $__wcf->user->userID && $user->isAccessible('canViewEmailAddress')}
+                               <li><a class="button jsTooltip" href="mailto:{@$user->getEncodedEmail()}" title="{lang}wcf.user.button.mail{/lang}"><span class="icon icon16 icon-envelope-alt"></span> <span class="invisible">{lang}wcf.user.button.mail{/lang}</span></a></li>{elseif $user->isAccessible('canMail') && $__wcf->session->getPermission('user.profile.canMail')}<li><a class="button jsTooltip" href="{link controller='Mail' object=$user}{/link}" title="{lang}wcf.user.button.mail{/lang}"><span class="icon icon16 icon-envelope-alt"></span> <span class="invisible">{lang}wcf.user.button.mail{/lang}</span></a></li>
+                       {/if}
+                       
                        {event name='buttons'}
+                       
+                       {if $__wcf->session->getPermission('admin.user.canBanUser') || $__wcf->session->getPermission('admin.user.canDisableAvatar') || $__wcf->session->getPermission('admin.user.canDisableSignature') || ($__wcf->session->getPermission('admin.general.canUseAcp') && $__wcf->session->getPermission('admin.user.canEditUser'))}
+                               <li class="dropdown">
+                                       {* todo: better icon? *}
+                                       <a href="{link controller='UserEdit' object=$user isACP=true}{/link}" class="button jsTooltip jsUserInlineEditor" title="{lang}wcf.user.moderate{/lang}"><span class="icon icon16 icon-lock"></span> <span class="invisible">{lang}{lang}wcf.acp.user.edit{/lang}{/lang}</span></a>
+                                       <ul class="dropdownMenu"></ul>
+                               </li>
+                       {/if}
                </ul>
        </nav>
 </header>
index 6f3cd2c05ec01e96e4048fd896ba9b9b0c1fd26b..e8867ec71d4f97b04fc382df03df0a29d0e8f6f0 100644 (file)
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
                        </option>
+                       <option name="admin.user.canDisableAvatar">
+                               <categoryname>admin.user.user</categoryname>
+                               <optiontype>boolean</optiontype>
+                               <defaultvalue>0</defaultvalue>
+                               <admindefaultvalue>1</admindefaultvalue>
+                       </option>
+                       <option name="admin.user.canDisableSignature">
+                               <categoryname>admin.user.user</categoryname>
+                               <optiontype>boolean</optiontype>
+                               <defaultvalue>0</defaultvalue>
+                               <admindefaultvalue>1</admindefaultvalue>
+                       </option>
                        <option name="admin.user.canMailUser">
                                <categoryname>admin.user.user</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
                        </option>
+                       
                        <option name="admin.user.canAddGroup">
                                <categoryname>admin.user.group</categoryname>
                                <optiontype>boolean</optiontype>
                                <defaultvalue>0</defaultvalue>
                                <admindefaultvalue>1</admindefaultvalue>
                        </option>
+                       
                        <option name="admin.user.canManageUserOption">
                                <categoryname>admin.user.option</categoryname>
                                <optiontype>boolean</optiontype>
index a83873117717383f556b10e1eb4c0bf84b6be9a5..c8746d7167a4135c2a42785d335c50a77b2d55f6 100644 (file)
@@ -93,6 +93,7 @@
                                'wcf.global.page.next': '{capture assign=pageNext}{lang}wcf.global.page.next{/lang}{/capture}{@$pageNext|encodeJS}',
                                'wcf.global.page.previous': '{capture assign=pagePrevious}{lang}wcf.global.page.previous{/lang}{/capture}{@$pagePrevious|encodeJS}',
                                'wcf.global.pageDirection': '{lang}wcf.global.pageDirection{/lang}',
+                               'wcf.global.reason': '{lang}wcf.global.reason{/lang}',
                                'wcf.global.success': '{lang}wcf.global.success{/lang}',
                                'wcf.global.success.add': '{lang}wcf.global.success.add{/lang}',
                                'wcf.global.success.edit': '{lang}wcf.global.success.edit{/lang}',
index 99bd3152b0f57d358b06a5e747d2a59d4603df7f..e507bef3ca7308c7d45542d306cfe6a31ad03da6 100644 (file)
                                        </dl>
                                </fieldset>
                                
-                               <fieldset>
-                                       <legend>{lang}wcf.acp.user.disableSignature{/lang}</legend>
-                                       
-                                       <dl>
-                                               <dt></dt>
-                                               <dd>
-                                                       <label><input type="checkbox" id="disableSignature" name="disableSignature" value="1" {if $disableSignature == 1}checked="checked" {/if}/> {lang}wcf.acp.user.disableSignature{/lang}</label>
-                                               </dd>
-                                       </dl>
+                               {if $__wcf->session->getPermission('admin.user.canDisableSignature')}
+                                       <fieldset>
+                                               <legend>{lang}wcf.acp.user.disableSignature{/lang}</legend>
+                                               
+                                               <dl>
+                                                       <dt></dt>
+                                                       <dd>
+                                                               <label><input type="checkbox" id="disableSignature" name="disableSignature" value="1" {if $disableSignature == 1}checked="checked" {/if}/> {lang}wcf.acp.user.disableSignature{/lang}</label>
+                                                       </dd>
+                                               </dl>
+                                               
+                                               <dl>
+                                                       <dt><label for="disableSignatureReason">{lang}wcf.acp.user.disableSignatureReason{/lang}</label></dt>
+                                                       <dd>
+                                                               <textarea name="disableSignatureReason" id="disableSignatureReason" cols="40" rows="10">{$disableSignatureReason}</textarea>
+                                                       </dd>
+                                               </dl>
+                                       </fieldset>
                                        
-                                       <dl>
-                                               <dt><label for="disableSignatureReason">{lang}wcf.acp.user.disableSignatureReason{/lang}</label></dt>
-                                               <dd>
-                                                       <textarea name="disableSignatureReason" id="disableSignatureReason" cols="40" rows="10">{$disableSignatureReason}</textarea>
-                                               </dd>
-                                       </dl>
-                               </fieldset>
-                               
-                               <script data-relocate="true">
-                                       //<![CDATA[
-                                       $('#disableSignature').change(function (event) {
-                                               if ($('#disableSignature').is(':checked')) {
-                                                       $('#disableSignatureReason').attr('readonly', false);
-                                               }
-                                               else {
-                                                       $('#disableSignatureReason').attr('readonly', true);
-                                               }
-                                       });
-                                       $('#disableSignature').change();
-                                       //]]>
-                               </script>
+                                       <script data-relocate="true">
+                                               //<![CDATA[
+                                               $('#disableSignature').change(function (event) {
+                                                       if ($('#disableSignature').is(':checked')) {
+                                                               $('#disableSignatureReason').attr('readonly', false);
+                                                       }
+                                                       else {
+                                                               $('#disableSignatureReason').attr('readonly', true);
+                                                       }
+                                               });
+                                               $('#disableSignature').change();
+                                               //]]>
+                                       </script>
+                               {/if}
                        </div>
                {/if}
                
                                        {/if}
                                </fieldset>
                                
-                               <fieldset>
-                                       <legend>{lang}wcf.acp.user.disableAvatar{/lang}</legend>
-                                       
-                                       <dl>
-                                               <dt></dt>
-                                               <dd>
-                                                       <label><input type="checkbox" id="disableAvatar" name="disableAvatar" value="1" {if $disableAvatar == 1}checked="checked" {/if}/> {lang}wcf.acp.user.disableAvatar{/lang}</label>
-                                               </dd>
-                                       </dl>
+                               {if $__wcf->session->getPermission('admin.user.canDisableAvatar')}
+                                       <fieldset>
+                                               <legend>{lang}wcf.acp.user.disableAvatar{/lang}</legend>
+                                               
+                                               <dl>
+                                                       <dt></dt>
+                                                       <dd>
+                                                               <label><input type="checkbox" id="disableAvatar" name="disableAvatar" value="1" {if $disableAvatar == 1}checked="checked" {/if}/> {lang}wcf.acp.user.disableAvatar{/lang}</label>
+                                                       </dd>
+                                               </dl>
+                                               
+                                               <dl>
+                                                       <dt><label for="disableAvatarReason">{lang}wcf.acp.user.disableAvatarReason{/lang}</label></dt>
+                                                       <dd>
+                                                               <textarea name="disableAvatarReason" id="disableAvatarReason" cols="40" rows="10">{$disableAvatarReason}</textarea>
+                                                       </dd>
+                                               </dl>
+                                       </fieldset>
                                        
-                                       <dl>
-                                               <dt><label for="disableAvatarReason">{lang}wcf.acp.user.disableAvatarReason{/lang}</label></dt>
-                                               <dd>
-                                                       <textarea name="disableAvatarReason" id="disableAvatarReason" cols="40" rows="10">{$disableAvatarReason}</textarea>
-                                               </dd>
-                                       </dl>
-                               </fieldset>
-                               
-                               <script data-relocate="true" src="{@$__wcf->getPath()}js/WCF.Message{if !ENABLE_DEBUG_MODE}.min{/if}.js?v={@$__wcfVersion}"></script>
-                               <script data-relocate="true" src="{@$__wcf->getPath()}js/WCF.User{if !ENABLE_DEBUG_MODE}.min{/if}.js?v={@$__wcfVersion}"></script>
-                               <script data-relocate="true">
+                                       <script data-relocate="true">
                                        //<![CDATA[
                                        $(function() {
                                                $('#disableAvatar').change(function (event) {
                                                        }
                                                });
                                                $('#disableAvatar').change();
-                                               
+                                       //]]>
+                                       </script>
+                               {/if}
+                               
+                               <script data-relocate="true" src="{@$__wcf->getPath()}js/WCF.Message{if !ENABLE_DEBUG_MODE}.min{/if}.js?v={@$__wcfVersion}"></script>
+                               <script data-relocate="true" src="{@$__wcf->getPath()}js/WCF.User{if !ENABLE_DEBUG_MODE}.min{/if}.js?v={@$__wcfVersion}"></script>
+                               <script data-relocate="true">
+                                       //<![CDATA[
+                                       $(function() {
                                                WCF.Language.addObject({
                                                        'wcf.user.avatar.upload.error.invalidExtension': '{lang}wcf.user.avatar.upload.error.invalidExtension{/lang}',
                                                        'wcf.user.avatar.upload.error.tooSmall': '{lang}wcf.user.avatar.upload.error.tooSmall{/lang}',
index 4e8f0dddf010a50d8046e5a4282b3f8435363e69..7ee0313c337aa8715a5107292c69462cac73959c 100644 (file)
@@ -2523,3 +2523,272 @@ WCF.User.ObjectWatch.Subscribe = Class.extend({
                this._proxy.sendRequest();
        }
 });
+
+/**
+ * Handles inline editing of users.
+ */
+WCF.User.InlineEditor = WCF.InlineEditor.extend({
+       /**
+        * list of permissions
+        * @var object
+        */
+       _permissions: { },
+       
+       /**
+        * @see WCF.InlineEditor._execute()
+        */
+       _execute: function(elementID, optionName) {
+               if (!this._validate(elementID, optionName)) {
+                       return false;
+               }
+               
+               var $data = { };
+               var $element = $('#' + elementID);
+               switch (optionName) {
+                       case 'unban':
+                       case 'enableAvatar':
+                       case 'enableSignature':
+                               switch (optionName) {
+                                       case 'unban':
+                                               $data.banned = 0;
+                                       break;
+                                       
+                                       case 'enableAvatar':
+                                               $data.disableAvatar = 0;
+                                       break;
+                                       
+                                       case 'enableSignature':
+                                               $data.disableSignature = 0;
+                                       break;
+                               }
+                               
+                               this._proxy.setOption('data', {
+                                       actionName: optionName,
+                                       className: 'wcf\\data\\user\\UserAction',
+                                       objectIDs: [ $element.data('objectID') ]
+                               });
+                               this._proxy.sendRequest();
+                       break;
+                       
+                       case 'ban':
+                       case 'disableAvatar':
+                       case 'disableSignature':
+                               if (optionName == 'unban') {
+                                       $data.banned = 1;
+                               }
+                               else {
+                                       $data[optionName] = 1;
+                               }
+                               
+                               this._showReasonDialog($element.data('objectID'), optionName);
+                       break;
+                       
+                       case 'advanced':
+                               window.location = this._getTriggerElement($element).attr('href');
+                       break;
+               }
+               
+               if ($.getLength($data)) {
+                       this._updateData.push({
+                               data: $data,
+                               elementID: elementID,
+                       });
+               }
+       },
+       
+       /**
+        * Executes an action with a reason.
+        * 
+        * @param       integer         userID
+        * @param       string          optionName
+        * @param       string          reason
+        */
+       _executeReasonAction: function(userID, optionName, reason) {
+               var $parameters = { };
+               $parameters[optionName + WCF.String.ucfirst('reason')] = reason;
+               
+               this._proxy.setOption('data', {
+                       actionName: optionName,
+                       className: 'wcf\\data\\user\\UserAction',
+                       objectIDs: [ userID ],
+                       parameters: $parameters
+               });
+               this._proxy.sendRequest();
+       },
+       
+       /**
+        * Returns a specific permission.
+        * 
+        * @param       string          permission
+        * @return      integer
+        */
+       _getPermission: function(permission) {
+               if (this._permissions[permission]) {
+                       return this._permissions[permission];
+               }
+               
+               return 0;
+       },
+       
+       /**
+        * @see WCF.InlineEditor._getTriggerElement()
+        */
+       _getTriggerElement: function(element) {
+               return element.find('.jsUserInlineEditor');
+       },
+       
+       /**
+        * @see WCF.InlineEditor._setOptions()
+        */
+       _setOptions: function() {
+               this._options = [
+                       // banning
+                       { label: WCF.Language.get('wcf.user.ban'), optionName: 'ban' },
+                       { label: WCF.Language.get('wcf.user.unban'), optionName: 'unban' },
+                       
+                       // disabling avatar
+                       { label: WCF.Language.get('wcf.user.disableAvatar'), optionName: 'disableAvatar' },
+                       { label: WCF.Language.get('wcf.user.enableAvatar'), optionName: 'enableAvatar' },
+                       
+                       // disabling signature
+                       { label: WCF.Language.get('wcf.user.disableSignature'), optionName: 'disableSignature' },
+                       { label: WCF.Language.get('wcf.user.enableSignature'), optionName: 'enableSignature' },
+                       
+                       // divider
+                       { optionName: 'divider' },
+                       
+                       // overlay
+                       { label: WCF.Language.get('wcf.user.edit'), optionName: 'advanced' }
+               ];
+       },
+       
+       /**
+        * @see WCF.InlineEditor._show()
+        */
+       _show: function(event) {
+               var $element = $(event.currentTarget);
+               var $elementID = $element.data('elementID');
+               
+               if (!this._dropdowns[$elementID]) {
+                       var $dropdownMenu = $element.next('.dropdownMenu');
+                       
+                       if ($dropdownMenu) {
+                               this._dropdowns[$elementID] = $dropdownMenu;
+                               WCF.Dropdown.initDropdown(this._getTriggerElement(this._elements[$elementID]), true);
+                       }
+               }
+               
+               return this._super(event);
+       },
+       
+       /**
+        * Shows the dialog to enter a reason for executing the option with the
+        * given name.
+        * 
+        * @param       string          optionName
+        */
+       _showReasonDialog: function(userID, optionName) {
+               var $languageItem = 'wcf.user.' + optionName + '.reason.description';
+               var $reasonDescription = WCF.Language.get($languageItem);
+               
+               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), { }, $('<fieldset><dl><dt>' + WCF.Language.get('wcf.global.reason') + '</dt><dd><textarea cols="40" rows="4" />' + ($reasonDescription != $languageID ? '<small>' + $reasonDescription + '</small>' : '') + '</dd></dl></fieldset>'));
+       },
+       
+       /**
+        * @see WCF.InlineEditor._updateState()
+        */
+       _updateState: function(data) {
+               this._notification.show();
+               
+               for (var $index in this._updateData) {
+                       var $data = this._updateData[$index];
+                       var $element = $('#' + $data.elementID);
+                       
+                       for (var $property in $data.data) {
+                               $element.data($property, $data.data[$property]);
+                       }
+               }
+       },
+       
+       /**
+        * @see WCF.InlineEditor._validate()
+        */
+       _validate: function(elementID, optionName) {
+               var $user = $('#' + elementID);
+               
+               switch (optionName) {
+                       case 'ban':
+                       case 'unban':
+                               if (!this._getPermission('canBanUser')) {
+                                       return false;
+                               }
+                               
+                               if (optionName == 'ban') {
+                                       return !$user.data('banned');
+                               }
+                               else {
+                                       return $user.data('banned');
+                               }
+                       break;
+                       
+                       case 'disableAvatar':
+                       case 'enableAvatar':
+                               if (!this._getPermission('canDisableAvatar')) {
+                                       return false;
+                               }
+                               
+                               if (optionName == 'disableAvatar') {
+                                       return !$user.data('disableAvatar');
+                               }
+                               else {
+                                       return $user.data('disableAvatar');
+                               }
+                       break;
+                       
+                       case 'disableSignature':
+                       case 'enableSignature':
+                               if (!this._getPermission('canDisableSignature')) {
+                                       return false;
+                               }
+                               
+                               if (optionName == 'disableSignature') {
+                                       return !$user.data('disableSignature');
+                               }
+                               else {
+                                       return $user.data('disableSignature');
+                               }
+                       break;
+                       
+                       case 'advanced':
+                               return this._getPermission('canEditUser');
+                       break;
+               }
+               
+               return false;
+       },
+       
+       /**
+        * Sets a permission.
+        * 
+        * @param       string          permission
+        * @param       integer         value
+        */
+       setPermission: function(permission, value) {
+               this._permissions[permission] = value;
+       },
+       
+       /**
+        * Sets permissions.
+        * 
+        * @param       object          permissions
+        */
+       setPermissions: function(permissions) {
+               for (var $permission in permissions) {
+                       this.setPermission($permission, permissions[$permission]);
+               }
+       }
+});
index 51fe926aac910167ca1c26a487d6c9ecdcd97575..0d51c99c56e201d4a15b7a804c11049dede783bd 100644 (file)
@@ -141,13 +141,16 @@ class UserAddForm extends UserOptionListForm {
                if (isset($_POST['userTitle'])) $this->userTitle = $_POST['userTitle'];
                
                if (isset($_POST['signature'])) $this->signature = StringUtil::trim($_POST['signature']);
-               if (isset($_POST['disableSignatureReason'])) $this->disableSignatureReason = StringUtil::trim($_POST['disableSignatureReason']);
                
                $this->signatureEnableBBCodes = $this->signatureEnableSmilies = 0;
                if (!empty($_POST['signatureEnableBBCodes'])) $this->signatureEnableBBCodes = 1;
                if (!empty($_POST['signatureEnableSmilies'])) $this->signatureEnableSmilies = 1;
                if (!empty($_POST['signatureEnableHtml'])) $this->signatureEnableHtml = 1;
-               if (!empty($_POST['disableSignature'])) $this->disableSignature = 1;
+               
+               if (WCF::getSession()->getPermission('admin.user.canDisableSignature')) {
+                       if (isset($_POST['disableSignatureReason'])) $this->disableSignatureReason = StringUtil::trim($_POST['disableSignatureReason']);
+                       if (!empty($_POST['disableSignature'])) $this->disableSignature = 1;
+               }
        }
        
        /**
@@ -248,14 +251,18 @@ class UserAddForm extends UserOptionListForm {
                                'signature' => $this->signature,
                                'signatureEnableBBCodes' => $this->signatureEnableBBCodes,
                                'signatureEnableSmilies' => $this->signatureEnableSmilies,
-                               'signatureEnableHtml' => $this->signatureEnableHtml,
-                               'disableSignature' => $this->disableSignature,
-                               'disableSignatureReason' => $this->disableSignatureReason
+                               'signatureEnableHtml' => $this->signatureEnableHtml
                        )),
                        'groups' => $this->groupIDs,
                        'languages' => $this->visibleLanguages,
                        'options' => $saveOptions
                );
+               
+               if (WCF::getSession()->getPermission('admin.user.canDisableSignature')) {
+                       $data['data']['disableSignature'] = $this->disableSignature;
+                       $data['data']['disableSignatureReason'] = $this->disableSignatureReason;
+               }
+               
                $this->objectAction = new UserAction(array(), 'create', $data);
                $this->objectAction->executeAction();
                $this->saved();
index d51cb15b38a1fa468d49aad5375cc9f81dda07c3..05704a1593d54beb9f073cd5e6d374f940e0f3a7 100755 (executable)
@@ -122,8 +122,11 @@ class UserEditForm extends UserAddForm {
                if (!empty($_POST['banned'])) $this->banned = 1;
                if (isset($_POST['banReason'])) $this->banReason = StringUtil::trim($_POST['banReason']);
                if (isset($_POST['avatarType'])) $this->avatarType = $_POST['avatarType'];
-               if (!empty($_POST['disableAvatar'])) $this->disableAvatar = 1;
-               if (isset($_POST['disableAvatarReason'])) $this->disableAvatarReason = StringUtil::trim($_POST['disableAvatarReason']);
+               
+               if (WCF::getSession()->getPermission('admin.user.canDisableAvatar')) {
+                       if (!empty($_POST['disableAvatar'])) $this->disableAvatar = 1;
+                       if (isset($_POST['disableAvatarReason'])) $this->disableAvatarReason = StringUtil::trim($_POST['disableAvatarReason']);
+               }
        }
        
        /**
@@ -173,7 +176,7 @@ class UserEditForm extends UserAddForm {
                $this->disableSignatureReason = $this->user->disableSignatureReason;
                $this->disableAvatar = $this->user->disableAvatar;
                $this->disableAvatarReason = $this->user->disableAvatarReason;
-                       
+               
                if ($this->user->avatarID) $this->avatarType = 'custom';
                else if (MODULE_GRAVATAR && $this->user->enableGravatar) $this->avatarType = 'gravatar';
        }
@@ -234,8 +237,12 @@ class UserEditForm extends UserAddForm {
                                );
                        break;
                }
-               $avatarData['disableAvatar'] = $this->disableAvatar;
-               $avatarData['disableAvatarReason'] = $this->disableAvatarReason;
+               
+               if (WCF::getSession()->getPermission('admin.user.canDisableAvatar')) {
+                       $avatarData['disableAvatar'] = $this->disableAvatar;
+                       $avatarData['disableAvatarReason'] = $this->disableAvatarReason;
+               }
+               
                $this->additionalFields = array_merge($this->additionalFields, $avatarData);
                
                // add default groups
@@ -266,14 +273,18 @@ class UserEditForm extends UserAddForm {
                                'signature' => $this->signature,
                                'signatureEnableBBCodes' => $this->signatureEnableBBCodes,
                                'signatureEnableSmilies' => $this->signatureEnableSmilies,
-                               'signatureEnableHtml' => $this->signatureEnableHtml,
-                               'disableSignature' => $this->disableSignature,
-                               'disableSignatureReason' => $this->disableSignatureReason
+                               'signatureEnableHtml' => $this->signatureEnableHtml
                        )),
                        'groups' => $this->groupIDs,
                        'languages' => $this->visibleLanguages,
                        'options' => $saveOptions
                );
+               
+               if (WCF::getSession()->getPermission('admin.user.canDisableSignature')) {
+                       $data['data']['disableSignature'] = $this->disableSignature;
+                       $data['data']['disableSignatureReason'] = $this->disableSignatureReason;
+               }
+               
                $this->objectAction = new UserAction(array($this->userID), 'update', $data);
                $this->objectAction->executeAction();
                
index dc2e959c22df77032f147faa39c9d5429dd95ae9..902733afcde1fa211b6a339da7f041749cd49516 100644 (file)
@@ -54,7 +54,7 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio
        /**
         * @see \wcf\data\AbstractDatabaseObjectAction::$requireACP
         */
-       protected $requireACP = array('create', 'ban', 'delete', 'disable', 'enable', 'unban');
+       protected $requireACP = array('create', 'delete', 'disable', 'enable');
        
        /**
         * Validates permissions and parameters.
@@ -211,7 +211,7 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio
                        ".$conditionBuilder;
                $statement = WCF::getDB()->prepareStatement($sql);
                $statement->execute(
-                       array_merge(array(1, $this->parameters['banReason']), $conditionBuilder->getParameters())               
+                       array_merge(array(1, $this->parameters['banReason']), $conditionBuilder->getParameters())
                );
                
                $this->unmarkItems();
@@ -520,10 +520,10 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio
                if (empty($this->objectIDs)) {
                        return;
                }
-       
+               
                // get base class
                $baseClass = call_user_func(array($this->className, 'getBaseClass'));
-       
+               
                // get objects
                $sql = "SELECT          user_option_value.*, user_table.*
                        FROM            wcf".WCF_N."_user user_table
@@ -536,4 +536,138 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio
                        $this->objects[] = new $this->className($object);
                }
        }
+       
+       /**
+        * Validates the 'disableSignature' action.
+        */
+       public function validateDisableSignature() {
+               WCF::getSession()->checkPermissions(array('admin.user.canDisableSignature'));
+               
+               $this->__validateAccessibleGroups();
+               
+               if (empty($this->objects)) {
+                       $this->readObjects();
+                       
+                       if (empty($this->objects)) {
+                               throw new UserInputException('objectIDs');
+                       }
+               }
+               
+               $this->readString('disableSignatureReason', true);
+       }
+       
+       /**
+        * Disables the signature of the handled users.
+        */
+       public function disableSignature() {
+               if (empty($this->objects)) {
+                       $this->readObjects();
+               }
+               
+               foreach ($this->objects as $userEditor) {
+                       $userEditor->update(array(
+                               'disableSignature' => 1,
+                               'disableSignatureReason' => $this->parameters['disableSignatureReason']
+                       ));
+               }
+       }
+       
+       /**
+        * Validates the 'enableSignature' action.
+        */
+       public function validateEnableSignature() {
+               WCF::getSession()->checkPermissions(array('admin.user.canDisableSignature'));
+               
+               $this->__validateAccessibleGroups();
+               
+               if (empty($this->objects)) {
+                       $this->readObjects();
+                       
+                       if (empty($this->objects)) {
+                               throw new UserInputException('objectIDs');
+                       }
+               }
+       }
+       
+       /**
+        * Enables the signature of the handled users.
+        */
+       public function enableSignature() {
+               if (empty($this->objects)) {
+                       $this->readObjects();
+               }
+               
+               foreach ($this->objects as $userEditor) {
+                       $userEditor->update(array(
+                               'disableSignature' => 0
+                       ));
+               }
+       }
+       
+       /**
+        * Validates the 'disableAvatar' action.
+        */
+       public function validateDisableAvatar() {
+               WCF::getSession()->checkPermissions(array('admin.user.canDisableAvatar'));
+               
+               $this->__validateAccessibleGroups();
+               
+               if (empty($this->objects)) {
+                       $this->readObjects();
+                       
+                       if (empty($this->objects)) {
+                               throw new UserInputException('objectIDs');
+                       }
+               }
+               
+               $this->readString('disableAvatarReason', true);
+       }
+       
+       /**
+        * Disables the avatar of the handled users.
+        */
+       public function disableAvatar() {
+               if (empty($this->objects)) {
+                       $this->readObjects();
+               }
+               
+               foreach ($this->objects as $userEditor) {
+                       $userEditor->update(array(
+                               'disableAvatar' => 1,
+                               'disableAvatarReason' => $this->parameters['disableAvatarReason']
+                       ));
+               }
+       }
+       
+       /**
+        * Validates the 'enableAvatar' action.
+        */
+       public function validateEnableAvatar() {
+               WCF::getSession()->checkPermissions(array('admin.user.canDisableAvatar'));
+               
+               $this->__validateAccessibleGroups();
+               
+               if (empty($this->objects)) {
+                       $this->readObjects();
+                       
+                       if (empty($this->objects)) {
+                               throw new UserInputException('objectIDs');
+                       }
+               }
+       }
+       
+       /**
+        * Enables the avatar of the handled users.
+        */
+       public function enableAvatar() {
+               if (empty($this->objects)) {
+                       $this->readObjects();
+               }
+               
+               foreach ($this->objects as $userEditor) {
+                       $userEditor->update(array(
+                               'disableAvatar' => 0
+                       ));
+               }
+       }
 }
index 716592bc064d6bad4c73c9aea73687a12dc49de9..c079dce1e268199a93c0cd8a6f70bb6cad78846c 100644 (file)
@@ -3,6 +3,7 @@ namespace wcf\page;
 use wcf\data\object\type\ObjectTypeCache;
 use wcf\data\user\follow\UserFollowerList;
 use wcf\data\user\follow\UserFollowingList;
+use wcf\data\user\group\UserGroup;
 use wcf\data\user\profile\visitor\UserProfileVisitor;
 use wcf\data\user\profile\visitor\UserProfileVisitorEditor;
 use wcf\data\user\profile\visitor\UserProfileVisitorList;
@@ -174,7 +175,8 @@ class UserPage extends AbstractPage {
                        'followingCount' => $this->followingList->countObjects(),
                        'visitors' => ($this->visitorList !== null ? $this->visitorList->getObjects() : array()),
                        'visitorCount' => ($this->visitorList !== null ? $this->visitorList->countObjects() : 0),
-                       'allowSpidersToIndexThisPage' => true
+                       'allowSpidersToIndexThisPage' => true,
+                       'isAccessible' => UserGroup::isAccessibleGroup($this->user->getGroupIDs())
                ));
        }
        
index 0bfdbe8e20c36bd7ed91fc375317fa4059eb9b38..dadecac8676b70f7c40a32035c72bf1b53282825 100644 (file)
                <item name="wcf.acp.group.description"><![CDATA[Beschreibung der Benutzergruppe]]></item>
                <item name="wcf.acp.group.button.choose"><![CDATA[Benutzergruppe wählen]]></item>
                <item name="wcf.acp.group.option.error.validationFailed"><![CDATA[Sie haben einen ungültigen Inhalt eingegeben.]]></item>
+               <item name="wcf.acp.group.option.admin.user.canDisableAvatar"><![CDATA[Kann Avatar sperren]]></item>
+               <item name="wcf.acp.group.option.admin.user.canDisableSignature"><![CDATA[Kann Signatur sperren]]></item>
        </category>
        
        <category name="wcf.acp.index">
@@ -1776,6 +1778,7 @@ Fehler sind beispielsweise:
                <item name="wcf.global.filter"><![CDATA[Filter]]></item>
                <item name="wcf.global.noItems"><![CDATA[Es wurden keine Einträge gefunden.]]></item>
                <item name="wcf.global.button.showAll"><![CDATA[Alle anzeigen]]></item>
+               <item name="wcf.global.reason"><![CDATA[Begründung]]></item>
        </category>
        
        <category name="wcf.global.form">
@@ -2207,6 +2210,18 @@ Wenn Sie Probleme mit der Aktivierung haben, wenden Sie sich bitte an den Admini
                <item name="wcf.user.register.honeyPot.description"><![CDATA[Falls Sie dies sehen können, füllen Sie bitte die nächsten zwei Eingabefelder <strong>NICHT</strong> aus!]]></item>
                <item name="wcf.user.searchUserContent"><![CDATA[Inhalte von „{$user->username}“ suchen]]></item>
                <item name="wcf.user.author"><![CDATA[Autor]]></item>
+               <item name="wcf.user.moderate"><![CDATA[Benutzer moderieren]]></item>
+               <item name="wcf.user.ban"><![CDATA[Benutzer sperren]]></item>
+               <item name="wcf.user.ban.confirmMessage"><![CDATA[Wollen Sie den Benutzer wirklich sperren?]]></item>
+               <item name="wcf.user.ban.reason.description"><![CDATA[Die Begründung wird dem gesperrten Benutzer beim Aufruf der Seite angezeigt.]]></item>
+               <item name="wcf.user.unban"><![CDATA[Benutzer entsperren]]></item>
+               <item name="wcf.user.disableAvatar"><![CDATA[Avatar sperren]]></item>
+               <item name="wcf.user.disableAvatar.confirmMessage"><![CDATA[Wollen Sie den Avatar des Benutzers wirklich sperren?]]></item>
+               <item name="wcf.user.enableAvatar"><![CDATA[Avatar entsperren]]></item>
+               <item name="wcf.user.disableSignature"><![CDATA[Signatur sperren]]></item>
+               <item name="wcf.user.disableSignature.confirmMessage"><![CDATA[Wollen Sie die Signatur des Benutzers wirklich sperren?]]></item>
+               <item name="wcf.user.enableSignature"><![CDATA[Signatur entsperren]]></item>
+               <item name="wcf.user.edit"><![CDATA[Benutzer bearbeiten]]></item>
        </category>
        
        <category name="wcf.user.menu">
index 497928ead6fc23fb258aa3b9600cda30b6d579e6..8dd5711fae956f30640d914e6520089788a435d3 100644 (file)
@@ -370,6 +370,8 @@ Examples for medium ID detection:
                <item name="wcf.acp.group.description"><![CDATA[Description]]></item>
                <item name="wcf.acp.group.button.choose"><![CDATA[Choose User Group]]></item>
                <item name="wcf.acp.group.option.error.validationFailed"><![CDATA[You have entered an invalid value.]]></item>
+               <item name="wcf.acp.group.option.admin.user.canDisableAvatar"><![CDATA[Can block avatar]]></item>
+               <item name="wcf.acp.group.option.admin.user.canDisableSignature"><![CDATA[Can block signature]]></item>
        </category>
        
        <category name="wcf.acp.index">
@@ -1775,6 +1777,7 @@ Errors are:
                <item name="wcf.global.filter"><![CDATA[Filter]]></item>
                <item name="wcf.global.noItems"><![CDATA[There are no items.]]></item>
                <item name="wcf.global.button.showAll"><![CDATA[Show All]]></item>
+               <item name="wcf.global.reason"><![CDATA[Reason]]></item>
        </category>
        
        <category name="wcf.global.form">
@@ -2203,6 +2206,18 @@ If you cannot activate your email address or have any troubles following the ins
                <item name="wcf.user.register.honeyPot.description"><![CDATA[Heads up! If you can see this, you are strongly encouraged <strong>NOT</strong> to fill in the next two input fields!]]></item>
                <item name="wcf.user.searchUserContent"><![CDATA[Search for content by “{$user->username}”]]></item>
                <item name="wcf.user.author"><![CDATA[Author]]></item>
+               <item name="wcf.user.moderate"><![CDATA[Moderate User]]></item>
+               <item name="wcf.user.ban"><![CDATA[Ban User]]></item>
+               <item name="wcf.user.ban.confirmMessage"><![CDATA[Do you really want to ban this user?]]></item>
+               <item name="wcf.user.ban.reason.description"><![CDATA[The reason will be displayed for the user when visiting the site.]]></item>
+               <item name="wcf.user.unban"><![CDATA[Unban User]]></item>
+               <item name="wcf.user.disableAvatar"><![CDATA[Block Avatar]]></item>
+               <item name="wcf.user.disableAvatar.confirmMessage"><![CDATA[Do you really want to block the avatar of this user?]]></item>
+               <item name="wcf.user.enableAvatar"><![CDATA[Unblock Avatar]]></item>
+               <item name="wcf.user.disableSignature"><![CDATA[Block Signature]]></item>
+               <item name="wcf.user.disableSignature.confirmMessage"><![CDATA[Do you really want to block the signature of this user?]]></item>
+               <item name="wcf.user.enableSignature"><![CDATA[Unblock Signature]]></item>
+               <item name="wcf.user.edit"><![CDATA[Edit User]]></item>
        </category>
        
        <category name="wcf.user.menu">