Move register state constants to User object
authorjoshuaruesweg <ruesweg@woltlab.com>
Fri, 22 May 2020 13:55:40 +0000 (15:55 +0200)
committerjoshuaruesweg <ruesweg@woltlab.com>
Fri, 22 May 2020 13:55:40 +0000 (15:55 +0200)
wcfsetup/install/files/lib/acp/page/IndexPage.class.php
wcfsetup/install/files/lib/data/user/User.class.php
wcfsetup/install/files/lib/data/user/UserAction.class.php
wcfsetup/install/files/lib/data/user/UserProfile.class.php
wcfsetup/install/files/lib/form/AccountManagementForm.class.php
wcfsetup/install/files/lib/form/RegisterActivationForm.class.php
wcfsetup/install/files/lib/form/RegisterForm.class.php
wcfsetup/install/files/lib/form/RegisterNewActivationCodeForm.class.php
wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php

index 86ae7005c2b51c00f8b65f8dd9d1538a5d498f00..176ea6aef82980990e7e6fe7577c22868b3b06b7 100755 (executable)
@@ -1,6 +1,6 @@
 <?php
 namespace wcf\acp\page;
-use wcf\data\user\UserProfile;
+use wcf\data\user\User;
 use wcf\page\AbstractPage;
 use wcf\system\application\ApplicationHandler;
 use wcf\system\cache\builder\OptionCacheBuilder;
@@ -8,7 +8,6 @@ use wcf\system\io\RemoteFile;
 use wcf\system\package\PackageInstallationDispatcher;
 use wcf\system\request\LinkHandler;
 use wcf\system\WCF;
-use wcf\util\StringUtil;
 
 /**
  * Shows the welcome page in admin control panel.
@@ -58,7 +57,7 @@ class IndexPage extends AbstractPage {
                parent::assignVariables();
                
                $usersAwaitingApproval = 0;
-               if (REGISTER_ACTIVATION_METHOD & UserProfile::REGISTER_ACTIVATION_ADMIN) {
+               if (REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_ADMIN) {
                        $sql = "SELECT  COUNT(*)
                                FROM    wcf".WCF_N."_user
                                WHERE   activationCode <> 0";
index ff91f24c7febd575cbc843e4d85936b7f0bf65bc..d9329523b768e7413044e1247c837a5cc2674f1d 100644 (file)
@@ -105,6 +105,11 @@ final class User extends DatabaseObject implements IRouteController, IUserConten
         */
        protected static $userOptions;
        
+       const REGISTER_ACTIVATION_NONE = 0;
+       const REGISTER_ACTIVATION_USER = 1;
+       const REGISTER_ACTIVATION_ADMIN = 2;
+       const REGISTER_ACTIVATION_USER_AND_ADMIN = 3; // self::REGISTER_ACTIVATION_USER + self::REGISTER_ACTIVATION_ADMIN
+       
        /** @noinspection PhpMissingParentConstructorInspection */
        /**
         * @inheritDoc
index e280e51f8739915689dca43e30d4eb6c24b4b23e..b3fb6346dbba8b1bf707601196d5466ab8617dfc 100644 (file)
@@ -22,7 +22,6 @@ use wcf\system\language\LanguageFactory;
 use wcf\system\request\RequestHandler;
 use wcf\system\user\group\assignment\UserGroupAssignmentHandler;
 use wcf\system\WCF;
-use wcf\util\CryptoUtil;
 use wcf\util\UserRegistrationUtil;
 
 /**
@@ -626,7 +625,7 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio
        public function confirmEmail() {
                if (empty($this->objects)) $this->readObjects();
                
-               if (REGISTER_ACTIVATION_METHOD & UserProfile::REGISTER_ACTIVATION_ADMIN) {
+               if (REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_ADMIN) {
                        $action = new UserAction($this->objects, 'update', [
                                'data' => [
                                        'emailConfirmed' => null
@@ -1029,7 +1028,7 @@ class UserAction extends AbstractDatabaseObjectAction implements IClipboardActio
                        throw new PermissionDeniedException();
                }
                
-               if (!(REGISTER_ACTIVATION_METHOD & UserProfile::REGISTER_ACTIVATION_USER)) {
+               if (!(REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER)) {
                        throw new IllegalLinkException();
                }  
                
index d4c0a9c7742a3bdff1ed862c4f2451a9232b65da..bf2d3e47444aa9b07e208834f68461f5f17cd12b 100644 (file)
@@ -111,11 +111,6 @@ class UserProfile extends DatabaseObjectDecorator implements ITitledLinkObject {
        const ACCESS_FOLLOWING = 2;
        const ACCESS_NOBODY = 3;
        
-       const REGISTER_ACTIVATION_NONE = 0;
-       const REGISTER_ACTIVATION_USER = 1;
-       const REGISTER_ACTIVATION_ADMIN = 2;
-       const REGISTER_ACTIVATION_USER_AND_ADMIN = 3; // self::REGISTER_ACTIVATION_USER + self::REGISTER_ACTIVATION_ADMIN
-       
        /**
         * @inheritDoc
         */
index 5677859d544f83c7c647030e5664d363e7d06263..9882aa5b0b29e6240a66d8af6c2ae877efb99600 100644 (file)
@@ -3,7 +3,6 @@ namespace wcf\form;
 use wcf\data\user\User;
 use wcf\data\user\UserAction;
 use wcf\data\user\UserList;
-use wcf\data\user\UserProfile;
 use wcf\system\email\mime\MimePartFacade;
 use wcf\system\email\mime\RecipientAwareTextMimePart;
 use wcf\system\email\Email;
@@ -339,12 +338,12 @@ class AccountManagementForm extends AbstractForm {
                
                // email
                if (WCF::getSession()->getPermission('user.profile.canChangeEmail') && $this->email != WCF::getUser()->email && $this->email != WCF::getUser()->newEmail) {
-                       if (!(REGISTER_ACTIVATION_METHOD & UserProfile::REGISTER_ACTIVATION_USER) && mb_strtolower($this->email) == mb_strtolower(WCF::getUser()->email)) {
+                       if (!(REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER) && mb_strtolower($this->email) == mb_strtolower(WCF::getUser()->email)) {
                                // update email
                                $updateParameters['email'] = $this->email;
                                $success[] = 'wcf.user.changeEmail.success';
                        }
-                       else if (REGISTER_ACTIVATION_METHOD & UserProfile::REGISTER_ACTIVATION_USER) {
+                       else if (REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER) {
                                // get reactivation code
                                $activationCode = UserRegistrationUtil::getActivationCode();
                                
index c96645c3d4f0afb93345317ba41b251fbcd5aafb..be803ec619b5f315afa29bfd21061b85abb84468 100644 (file)
@@ -2,7 +2,6 @@
 namespace wcf\form;
 use wcf\data\user\User;
 use wcf\data\user\UserAction;
-use wcf\data\user\UserProfile;
 use wcf\system\event\EventHandler;
 use wcf\system\exception\IllegalLinkException;
 use wcf\system\exception\NamedUserException;
@@ -10,7 +9,6 @@ use wcf\system\exception\PermissionDeniedException;
 use wcf\system\exception\UserInputException;
 use wcf\system\request\LinkHandler;
 use wcf\system\WCF;
-use wcf\util\CryptoUtil;
 use wcf\util\HeaderUtil;
 use wcf\util\StringUtil;
 
@@ -106,7 +104,7 @@ class RegisterActivationForm extends AbstractForm {
                $this->saved();
                
                // forward to index page
-               if (REGISTER_ACTIVATION_METHOD & UserProfile::REGISTER_ACTIVATION_ADMIN && !$this->user->isActivated()) {
+               if (REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_ADMIN && !$this->user->isActivated()) {
                        $redirectText = WCF::getLanguage()->getDynamicVariable('wcf.user.registerActivation.success.awaitAdminActivation');
                }
                else {
@@ -133,7 +131,7 @@ class RegisterActivationForm extends AbstractForm {
         * @inheritDoc
         */
        public function show() {
-               if (!(REGISTER_ACTIVATION_METHOD & UserProfile::REGISTER_ACTIVATION_USER)) {
+               if (!(REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER)) {
                        throw new IllegalLinkException();
                }
                
index 19901a2279eca16c0b93d6a5307da67b17475289..ded41b4346b8cfc448acfa74fff7b835edb718bd 100644 (file)
@@ -429,7 +429,7 @@ class RegisterForm extends UserAddForm {
                
                // generate activation code
                $addDefaultGroups = true;
-               if (!empty($this->blacklistMatches) || (REGISTER_ACTIVATION_METHOD & UserProfile::REGISTER_ACTIVATION_USER && !$registerVia3rdParty) || REGISTER_ACTIVATION_METHOD & UserProfile::REGISTER_ACTIVATION_ADMIN) {
+               if (!empty($this->blacklistMatches) || (REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER && !$registerVia3rdParty) || REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_ADMIN) {
                        $activationCode = UserRegistrationUtil::getActivationCode();
                        $emailConfirmCode = bin2hex(\random_bytes(20));
                        $this->additionalFields['activationCode'] = $activationCode;
@@ -476,12 +476,12 @@ class RegisterForm extends UserAddForm {
                }
                
                // activation management
-               if (REGISTER_ACTIVATION_METHOD == UserProfile::REGISTER_ACTIVATION_NONE && empty($this->blacklistMatches)) {
+               if (REGISTER_ACTIVATION_METHOD == User::REGISTER_ACTIVATION_NONE && empty($this->blacklistMatches)) {
                        $this->message = 'wcf.user.register.success';
                        
                        UserGroupAssignmentHandler::getInstance()->checkUsers([$user->userID]);
                }
-               else if (REGISTER_ACTIVATION_METHOD & UserProfile::REGISTER_ACTIVATION_USER && empty($this->blacklistMatches)) {
+               else if (REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER && empty($this->blacklistMatches)) {
                        // registering via 3rdParty leads to instant activation
                        if ($registerVia3rdParty) {
                                $this->message = 'wcf.user.register.success';
@@ -498,7 +498,7 @@ class RegisterForm extends UserAddForm {
                                $this->message = 'wcf.user.register.success.needActivation';
                        }
                }
-               else if (REGISTER_ACTIVATION_METHOD & UserProfile::REGISTER_ACTIVATION_ADMIN || !empty($this->blacklistMatches)) {
+               else if (REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_ADMIN || !empty($this->blacklistMatches)) {
                        $this->message = 'wcf.user.register.success.awaitActivation';
                }
                
index f6ea6db588946bb6bd82e938a2a000426dfaef73..84dd0affe73bb08ff8db9ed79e6162bb3ba22350 100644 (file)
@@ -2,7 +2,6 @@
 namespace wcf\form;
 use wcf\data\user\User;
 use wcf\data\user\UserAction;
-use wcf\data\user\UserProfile;
 use wcf\system\email\mime\MimePartFacade;
 use wcf\system\email\mime\RecipientAwareTextMimePart;
 use wcf\system\email\Email;
@@ -199,7 +198,7 @@ class RegisterNewActivationCodeForm extends AbstractForm {
         * @inheritDoc
         */
        public function show() {
-               if (!(REGISTER_ACTIVATION_METHOD & UserProfile::REGISTER_ACTIVATION_USER)) {
+               if (!(REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER)) {
                        throw new IllegalLinkException();
                }
                
index ceba0e4266fb1e987c33db5eb508570d8faf6284..d5d2920f12e3d896fc141795904b55e15dd32f4d 100644 (file)
@@ -4,7 +4,6 @@ use wcf\data\clipboard\action\ClipboardAction;
 use wcf\data\user\group\UserGroup;
 use wcf\data\user\User;
 use wcf\data\user\UserAction;
-use wcf\data\user\UserProfile;
 use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\request\LinkHandler;
 use wcf\system\WCF;
@@ -229,7 +228,7 @@ class UserClipboardAction extends AbstractClipboardAction {
         */
        protected function validateResendActivationMail() {
                // check permissions
-               if (!WCF::getSession()->getPermission('admin.user.canEnableUser') || !(REGISTER_ACTIVATION_METHOD & UserProfile::REGISTER_ACTIVATION_USER)) {
+               if (!WCF::getSession()->getPermission('admin.user.canEnableUser') || !(REGISTER_ACTIVATION_METHOD & User::REGISTER_ACTIVATION_USER)) {
                        return [];
                }