Remove old `AvatarEditForm`
authorCyperghost <olaf_schmitz_1@t-online.de>
Thu, 7 Nov 2024 11:46:22 +0000 (12:46 +0100)
committerCyperghost <olaf_schmitz_1@t-online.de>
Thu, 7 Nov 2024 11:46:22 +0000 (12:46 +0100)
com.woltlab.wcf/fileDelete.xml
com.woltlab.wcf/templateDelete.xml
com.woltlab.wcf/templates/avatarEdit.tpl [deleted file]
wcfsetup/install/files/lib/form/AvatarEditForm.class.php [deleted file]
wcfsetup/install/files/lib/system/user/command/SetAvatar.class.php

index 37f95956d53496f02e2cd7f8003efb148139cca3..2e2a46e6862d2cc16d851eabf436cf551bed8632 100644 (file)
                <file>lib/data/user/option/IUserOptionOutput.class.php</file>
                <file>lib/data/user/option/UserOptionOutput.class.php</file>
                <file>lib/form/AbstractSecureForm.class.php</file>
+               <file>lib/form/AvatarEditForm.class.php</file>
                <file>lib/form/Form.class.php</file>
                <file>lib/form/MailForm.class.php</file>
                <file>lib/form/MultifactorAuthenticationAbortForm.class.php</file>
index 054f501b384ed9119a66d7fb5ab7784ff5337444..cdc842f64d3471c1b492c5a48df5a16cce8acbaf 100644 (file)
                <template>__multiPageCondition</template>
                <template>__multilineItemListFormField</template>
                <template>email_notification_userRegistration</template>
+               <template>avatarEdit</template>
        </delete>
 </data>
diff --git a/com.woltlab.wcf/templates/avatarEdit.tpl b/com.woltlab.wcf/templates/avatarEdit.tpl
deleted file mode 100644 (file)
index 45fc6bd..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-{include file='userMenuSidebar'}
-
-{include file='header' __disableAds=true __sidebarLeftHasMenu=true}
-
-{if $__wcf->user->disableAvatar}
-       <woltlab-core-notice type="error">{lang}wcf.user.avatar.error.disabled{/lang}</woltlab-core-notice>
-{/if}
-
-{include file='shared_formError'}
-
-{if $success|isset}
-       <woltlab-core-notice type="success">{lang}wcf.global.success.edit{/lang}</woltlab-core-notice>
-{/if}
-
-<form method="post" action="{link controller='AvatarEdit'}{/link}" id="avatarForm">
-       <div role="group" aria-label="{lang}wcf.user.avatar{/lang}" class="section avatarEdit">
-               <dl class="avatarType">
-                       <dt></dt>
-                       <dd>
-                               <label><input type="radio" name="avatarType" value="none" {if $avatarType == 'none'}checked {/if}> {lang}wcf.user.avatar.type.none{/lang}</label>
-                               <small>{lang}wcf.user.avatar.type.none.description{/lang}</small>
-                       </dd>
-               </dl>
-               
-               {if $__wcf->getSession()->getPermission('user.profile.avatar.canUploadAvatar')}
-                       <dl class="avatarType jsOnly{if $errorField == 'custom'} formError{/if}" id="avatarUpload">
-                               <dt>
-                                       {if $avatarType == 'custom'}
-                                               {@$__wcf->getUserProfileHandler()->getAvatar()->getImageTag(96)}
-                                       {else}
-                                               <img src="{@$__wcf->getPath()}images/avatars/avatar-default.svg" alt="" class="userAvatarImage" style="width: 96px; height: 96px">
-                                       {/if}
-                               </dt>
-                               <dd>
-                                       <label><input type="radio" name="avatarType" value="custom"{if $avatarType == 'custom'} checked{/if}> {lang}wcf.user.avatar.type.custom{/lang}</label>
-                                       <small>{lang}wcf.user.avatar.type.custom.description{/lang}</small>
-                                       
-                                       {* placeholder for upload button: *}
-                                       <div class="avatarUploadButtonContainer"></div>
-                                       
-                                       {if $errorField == 'custom'}
-                                               <small class="innerError">
-                                                       {if $errorType == 'empty'}{lang}wcf.global.form.error.empty{/lang}{/if}
-                                               </small>
-                                       {/if}
-                               </dd>
-                       </dl>
-               {/if}
-               
-               {event name='avatarFields'}
-       </div>
-               
-       {event name='sections'}
-       
-       {if !$__wcf->user->disableAvatar}
-               <div class="formSubmit">
-                       <input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s">
-                       {csrfToken}
-               </div>
-       {/if}
-</form>
-
-{if $__wcf->getSession()->getPermission('user.profile.avatar.canUploadAvatar')}
-       <script data-relocate="true">
-               $(function() {
-                       WCF.Language.addObject({
-                               'wcf.user.avatar.upload.error.invalidExtension': '{jslang}wcf.user.avatar.upload.error.invalidExtension{/jslang}',
-                               'wcf.user.avatar.upload.error.tooSmall': '{jslang}wcf.user.avatar.upload.error.tooSmall{/jslang}',
-                               'wcf.user.avatar.upload.error.tooLarge': '{jslang}wcf.user.avatar.upload.error.tooLarge{/jslang}',
-                               'wcf.user.avatar.upload.error.uploadFailed': '{jslang}wcf.user.avatar.upload.error.uploadFailed{/jslang}',
-                               'wcf.user.avatar.upload.error.badImage': '{jslang}wcf.user.avatar.upload.error.badImage{/jslang}',
-                               'wcf.user.avatar.upload.success': '{jslang}wcf.user.avatar.upload.success{/jslang}'
-                       });
-                       
-                       {if !$__wcf->user->disableAvatar}
-                               new WCF.User.Avatar.Upload();
-                       {/if}
-               });
-       </script>
-{/if}
-
-{include file='footer'}
diff --git a/wcfsetup/install/files/lib/form/AvatarEditForm.class.php b/wcfsetup/install/files/lib/form/AvatarEditForm.class.php
deleted file mode 100644 (file)
index c458b6e..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-<?php
-
-namespace wcf\form;
-
-use wcf\data\user\avatar\UserAvatarAction;
-use wcf\data\user\UserAction;
-use wcf\system\exception\PermissionDeniedException;
-use wcf\system\exception\UserInputException;
-use wcf\system\menu\user\UserMenu;
-use wcf\system\user\group\assignment\UserGroupAssignmentHandler;
-use wcf\system\user\UserProfileHandler;
-use wcf\system\WCF;
-
-/**
- * Shows the avatar edit form.
- *
- * @author  Marcel Werk
- * @copyright   2001-2019 WoltLab GmbH
- * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- */
-class AvatarEditForm extends AbstractForm
-{
-    /**
-     * @inheritDoc
-     */
-    public $loginRequired = true;
-
-    /**
-     * @inheritDoc
-     */
-    public $templateName = 'avatarEdit';
-
-    /**
-     * avatar type
-     * @var string
-     */
-    public $avatarType = 'none';
-
-    /**
-     * @inheritDoc
-     */
-    public function readFormParameters()
-    {
-        parent::readFormParameters();
-
-        if (isset($_POST['avatarType'])) {
-            $this->avatarType = $_POST['avatarType'];
-        }
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function validate()
-    {
-        parent::validate();
-
-        if (WCF::getUser()->disableAvatar) {
-            throw new PermissionDeniedException();
-        }
-
-        if ($this->avatarType != 'custom') {
-            $this->avatarType = 'none';
-        }
-
-        switch ($this->avatarType) {
-            case 'custom':
-                if (!WCF::getUser()->avatarID) {
-                    throw new UserInputException('custom');
-                }
-                break;
-        }
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function save()
-    {
-        parent::save();
-
-        if ($this->avatarType != 'custom') {
-            // delete custom avatar
-            if (WCF::getUser()->avatarID) {
-                $action = new UserAvatarAction([WCF::getUser()->avatarID], 'delete');
-                $action->executeAction();
-            }
-        }
-
-        // update user
-        $data = [];
-        if ($this->avatarType === 'none') {
-            $data = [
-                'avatarID' => null,
-            ];
-        }
-        $this->objectAction = new UserAction([WCF::getUser()], 'update', [
-            'data' => \array_merge($this->additionalFields, $data),
-        ]);
-        $this->objectAction->executeAction();
-
-        // check if the user will be automatically added to new user groups
-        // because of the changed avatar
-        UserGroupAssignmentHandler::getInstance()->checkUsers([WCF::getUser()->userID]);
-
-        UserProfileHandler::getInstance()->reloadUserProfile();
-
-        $this->saved();
-        WCF::getTPL()->assign('success', true);
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function readData()
-    {
-        parent::readData();
-
-        if (empty($_POST)) {
-            if (WCF::getUser()->avatarID) {
-                $this->avatarType = 'custom';
-            }
-        }
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function assignVariables()
-    {
-        parent::assignVariables();
-
-        WCF::getTPL()->assign([
-            'avatarType' => $this->avatarType,
-        ]);
-    }
-
-    /**
-     * @inheritDoc
-     */
-    public function show()
-    {
-        // set active tab
-        UserMenu::getInstance()->setActiveMenuItem('wcf.user.menu.profile.avatar');
-
-        parent::show();
-    }
-}
index f1b4ae5e8a8beeff21925abb2dfae2cd0b7572c0..04801ad8ff1f7136cb17858cbe5d966fb7d714a6 100644 (file)
@@ -7,7 +7,10 @@ use wcf\data\file\FileAction;
 use wcf\data\user\avatar\UserAvatarAction;
 use wcf\data\user\User;
 use wcf\data\user\UserEditor;
+use wcf\system\user\group\assignment\UserGroupAssignmentHandler;
 use wcf\system\user\storage\UserStorageHandler;
+use wcf\system\user\UserProfileHandler;
+use wcf\system\WCF;
 
 final class SetAvatar
 {
@@ -34,5 +37,13 @@ final class SetAvatar
         ]);
 
         UserStorageHandler::getInstance()->reset([$this->user->userID], 'avatar');
+
+        // check if the user will be automatically added to new user groups
+        // because of the changed avatar
+        UserGroupAssignmentHandler::getInstance()->checkUsers([$this->user->userID]);
+
+        if ($this->user->userID === WCF::getUser()->userID) {
+            UserProfileHandler::getInstance()->reloadUserProfile();
+        }
     }
 }