]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use constants from interface rather than class
authorDaniel Calviño Sánchez <danxuliu@gmail.com>
Fri, 29 Jan 2021 19:32:41 +0000 (20:32 +0100)
committerDaniel Calviño Sánchez <danxuliu@gmail.com>
Fri, 23 Apr 2021 14:53:48 +0000 (16:53 +0200)
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
apps/settings/lib/Controller/UsersController.php
apps/settings/tests/Controller/UsersControllerTest.php

index a24a7c3ee2cc015092e022a57e5f262d03837c4e..98baed01ddf3c1e6022c2b0ec3c897adba9905cb 100644 (file)
@@ -46,6 +46,7 @@ use OCA\FederatedFileSharing\FederatedShareProvider;
 use OCA\Settings\BackgroundJobs\VerifyUserData;
 use OCA\Settings\Events\BeforeTemplateRenderedEvent;
 use OCA\User_LDAP\User_Proxy;
+use OCP\Accounts\IAccountManager;
 use OCP\App\IAppManager;
 use OCP\AppFramework\Controller;
 use OCP\AppFramework\Http\DataResponse;
@@ -374,18 +375,18 @@ class UsersController extends Controller {
                }
                $user = $this->userSession->getUser();
                $data = $this->accountManager->getUser($user);
-               $data[AccountManager::PROPERTY_AVATAR] = ['scope' => $avatarScope];
+               $data[IAccountManager::PROPERTY_AVATAR] = ['scope' => $avatarScope];
                if ($this->config->getSystemValue('allow_user_to_change_display_name', true) !== false) {
-                       $data[AccountManager::PROPERTY_DISPLAYNAME] = ['value' => $displayname, 'scope' => $displaynameScope];
-                       $data[AccountManager::PROPERTY_EMAIL] = ['value' => $email, 'scope' => $emailScope];
+                       $data[IAccountManager::PROPERTY_DISPLAYNAME] = ['value' => $displayname, 'scope' => $displaynameScope];
+                       $data[IAccountManager::PROPERTY_EMAIL] = ['value' => $email, 'scope' => $emailScope];
                }
                if ($this->appManager->isEnabledForUser('federatedfilesharing')) {
                        $shareProvider = \OC::$server->query(FederatedShareProvider::class);
                        if ($shareProvider->isLookupServerUploadEnabled()) {
-                               $data[AccountManager::PROPERTY_WEBSITE] = ['value' => $website, 'scope' => $websiteScope];
-                               $data[AccountManager::PROPERTY_ADDRESS] = ['value' => $address, 'scope' => $addressScope];
-                               $data[AccountManager::PROPERTY_PHONE] = ['value' => $phone, 'scope' => $phoneScope];
-                               $data[AccountManager::PROPERTY_TWITTER] = ['value' => $twitter, 'scope' => $twitterScope];
+                               $data[IAccountManager::PROPERTY_WEBSITE] = ['value' => $website, 'scope' => $websiteScope];
+                               $data[IAccountManager::PROPERTY_ADDRESS] = ['value' => $address, 'scope' => $addressScope];
+                               $data[IAccountManager::PROPERTY_PHONE] = ['value' => $phone, 'scope' => $phoneScope];
+                               $data[IAccountManager::PROPERTY_TWITTER] = ['value' => $twitter, 'scope' => $twitterScope];
                        }
                }
                try {
@@ -395,15 +396,15 @@ class UsersController extends Controller {
                                        'status' => 'success',
                                        'data' => [
                                                'userId' => $user->getUID(),
-                                               'avatarScope' => $data[AccountManager::PROPERTY_AVATAR]['scope'],
-                                               'displayname' => $data[AccountManager::PROPERTY_DISPLAYNAME]['value'],
-                                               'displaynameScope' => $data[AccountManager::PROPERTY_DISPLAYNAME]['scope'],
-                                               'email' => $data[AccountManager::PROPERTY_EMAIL]['value'],
-                                               'emailScope' => $data[AccountManager::PROPERTY_EMAIL]['scope'],
-                                               'website' => $data[AccountManager::PROPERTY_WEBSITE]['value'],
-                                               'websiteScope' => $data[AccountManager::PROPERTY_WEBSITE]['scope'],
-                                               'address' => $data[AccountManager::PROPERTY_ADDRESS]['value'],
-                                               'addressScope' => $data[AccountManager::PROPERTY_ADDRESS]['scope'],
+                                               'avatarScope' => $data[IAccountManager::PROPERTY_AVATAR]['scope'],
+                                               'displayname' => $data[IAccountManager::PROPERTY_DISPLAYNAME]['value'],
+                                               'displaynameScope' => $data[IAccountManager::PROPERTY_DISPLAYNAME]['scope'],
+                                               'email' => $data[IAccountManager::PROPERTY_EMAIL]['value'],
+                                               'emailScope' => $data[IAccountManager::PROPERTY_EMAIL]['scope'],
+                                               'website' => $data[IAccountManager::PROPERTY_WEBSITE]['value'],
+                                               'websiteScope' => $data[IAccountManager::PROPERTY_WEBSITE]['scope'],
+                                               'address' => $data[IAccountManager::PROPERTY_ADDRESS]['value'],
+                                               'addressScope' => $data[IAccountManager::PROPERTY_ADDRESS]['scope'],
                                                'message' => $this->l10n->t('Settings saved')
                                        ]
                                ],
index 4679fd8f7ba0f664183c2aad1e65bd09e9df87dc..ace07740901c9ad7ed418c86510d6ee8ad75b271 100644 (file)
@@ -31,6 +31,7 @@ use OC\Accounts\AccountManager;
 use OC\Encryption\Exceptions\ModuleDoesNotExistsException;
 use OC\Group\Manager;
 use OCA\Settings\Controller\UsersController;
+use OCP\Accounts\IAccountManager;
 use OCP\App\IAppManager;
 use OCP\AppFramework\Http;
 use OCP\BackgroundJob\IJobList;
@@ -196,45 +197,45 @@ class UsersControllerTest extends \Test\TestCase {
                                ->method('getUser')
                                ->with($user)
                                ->willReturn([
-                                       AccountManager::PROPERTY_DISPLAYNAME =>
+                                       IAccountManager::PROPERTY_DISPLAYNAME =>
                                                [
                                                        'value' => 'Display name',
-                                                       'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY,
-                                                       'verified' => AccountManager::NOT_VERIFIED,
+                                                       'scope' => IAccountManager::VISIBILITY_CONTACTS_ONLY,
+                                                       'verified' => IAccountManager::NOT_VERIFIED,
                                                ],
-                                       AccountManager::PROPERTY_ADDRESS =>
+                                       IAccountManager::PROPERTY_ADDRESS =>
                                                [
                                                        'value' => '',
-                                                       'scope' => AccountManager::VISIBILITY_PRIVATE,
-                                                       'verified' => AccountManager::NOT_VERIFIED,
+                                                       'scope' => IAccountManager::VISIBILITY_PRIVATE,
+                                                       'verified' => IAccountManager::NOT_VERIFIED,
                                                ],
-                                       AccountManager::PROPERTY_WEBSITE =>
+                                       IAccountManager::PROPERTY_WEBSITE =>
                                                [
                                                        'value' => '',
-                                                       'scope' => AccountManager::VISIBILITY_PRIVATE,
-                                                       'verified' => AccountManager::NOT_VERIFIED,
+                                                       'scope' => IAccountManager::VISIBILITY_PRIVATE,
+                                                       'verified' => IAccountManager::NOT_VERIFIED,
                                                ],
-                                       AccountManager::PROPERTY_EMAIL =>
+                                       IAccountManager::PROPERTY_EMAIL =>
                                                [
                                                        'value' => '',
-                                                       'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY,
-                                                       'verified' => AccountManager::NOT_VERIFIED,
+                                                       'scope' => IAccountManager::VISIBILITY_CONTACTS_ONLY,
+                                                       'verified' => IAccountManager::NOT_VERIFIED,
                                                ],
-                                       AccountManager::PROPERTY_AVATAR =>
+                                       IAccountManager::PROPERTY_AVATAR =>
                                                [
-                                                       'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY
+                                                       'scope' => IAccountManager::VISIBILITY_CONTACTS_ONLY
                                                ],
-                                       AccountManager::PROPERTY_PHONE =>
+                                       IAccountManager::PROPERTY_PHONE =>
                                                [
                                                        'value' => '',
-                                                       'scope' => AccountManager::VISIBILITY_PRIVATE,
-                                                       'verified' => AccountManager::NOT_VERIFIED,
+                                                       'scope' => IAccountManager::VISIBILITY_PRIVATE,
+                                                       'verified' => IAccountManager::NOT_VERIFIED,
                                                ],
-                                       AccountManager::PROPERTY_TWITTER =>
+                                       IAccountManager::PROPERTY_TWITTER =>
                                                [
                                                        'value' => '',
-                                                       'scope' => AccountManager::VISIBILITY_PRIVATE,
-                                                       'verified' => AccountManager::NOT_VERIFIED,
+                                                       'scope' => IAccountManager::VISIBILITY_PRIVATE,
+                                                       'verified' => IAccountManager::NOT_VERIFIED,
                                                ],
                                ]);