Use constants from interface rather than class

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2021-01-29 20:32:41 +01:00
parent 739504bd10
commit eaedf5fcd9
2 changed files with 38 additions and 36 deletions

View File

@ -38,6 +38,7 @@ use OC\ForbiddenException;
use OC\Security\IdentityProof\Manager; use OC\Security\IdentityProof\Manager;
use OCA\Settings\BackgroundJobs\VerifyUserData; use OCA\Settings\BackgroundJobs\VerifyUserData;
use OCA\User_LDAP\User_Proxy; use OCA\User_LDAP\User_Proxy;
use OCP\Accounts\IAccountManager;
use OCP\App\IAppManager; use OCP\App\IAppManager;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataResponse;
@ -357,19 +358,19 @@ class UsersController extends Controller {
} }
$user = $this->userSession->getUser(); $user = $this->userSession->getUser();
$data = $this->accountManager->getUser($user); $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) { if ($this->config->getSystemValue('allow_user_to_change_display_name', true) !== false) {
$data[AccountManager::PROPERTY_DISPLAYNAME] = ['value' => $displayname, 'scope' => $displaynameScope]; $data[IAccountManager::PROPERTY_DISPLAYNAME] = ['value' => $displayname, 'scope' => $displaynameScope];
$data[AccountManager::PROPERTY_EMAIL] = ['value' => $email, 'scope' => $emailScope]; $data[IAccountManager::PROPERTY_EMAIL] = ['value' => $email, 'scope' => $emailScope];
} }
if ($this->appManager->isEnabledForUser('federatedfilesharing')) { if ($this->appManager->isEnabledForUser('federatedfilesharing')) {
$federatedFileSharing = new \OCA\FederatedFileSharing\AppInfo\Application(); $federatedFileSharing = new \OCA\FederatedFileSharing\AppInfo\Application();
$shareProvider = $federatedFileSharing->getFederatedShareProvider(); $shareProvider = $federatedFileSharing->getFederatedShareProvider();
if ($shareProvider->isLookupServerUploadEnabled()) { if ($shareProvider->isLookupServerUploadEnabled()) {
$data[AccountManager::PROPERTY_WEBSITE] = ['value' => $website, 'scope' => $websiteScope]; $data[IAccountManager::PROPERTY_WEBSITE] = ['value' => $website, 'scope' => $websiteScope];
$data[AccountManager::PROPERTY_ADDRESS] = ['value' => $address, 'scope' => $addressScope]; $data[IAccountManager::PROPERTY_ADDRESS] = ['value' => $address, 'scope' => $addressScope];
$data[AccountManager::PROPERTY_PHONE] = ['value' => $phone, 'scope' => $phoneScope]; $data[IAccountManager::PROPERTY_PHONE] = ['value' => $phone, 'scope' => $phoneScope];
$data[AccountManager::PROPERTY_TWITTER] = ['value' => $twitter, 'scope' => $twitterScope]; $data[IAccountManager::PROPERTY_TWITTER] = ['value' => $twitter, 'scope' => $twitterScope];
} }
} }
try { try {
@ -379,15 +380,15 @@ class UsersController extends Controller {
'status' => 'success', 'status' => 'success',
'data' => [ 'data' => [
'userId' => $user->getUID(), 'userId' => $user->getUID(),
'avatarScope' => $data[AccountManager::PROPERTY_AVATAR]['scope'], 'avatarScope' => $data[IAccountManager::PROPERTY_AVATAR]['scope'],
'displayname' => $data[AccountManager::PROPERTY_DISPLAYNAME]['value'], 'displayname' => $data[IAccountManager::PROPERTY_DISPLAYNAME]['value'],
'displaynameScope' => $data[AccountManager::PROPERTY_DISPLAYNAME]['scope'], 'displaynameScope' => $data[IAccountManager::PROPERTY_DISPLAYNAME]['scope'],
'email' => $data[AccountManager::PROPERTY_EMAIL]['value'], 'email' => $data[IAccountManager::PROPERTY_EMAIL]['value'],
'emailScope' => $data[AccountManager::PROPERTY_EMAIL]['scope'], 'emailScope' => $data[IAccountManager::PROPERTY_EMAIL]['scope'],
'website' => $data[AccountManager::PROPERTY_WEBSITE]['value'], 'website' => $data[IAccountManager::PROPERTY_WEBSITE]['value'],
'websiteScope' => $data[AccountManager::PROPERTY_WEBSITE]['scope'], 'websiteScope' => $data[IAccountManager::PROPERTY_WEBSITE]['scope'],
'address' => $data[AccountManager::PROPERTY_ADDRESS]['value'], 'address' => $data[IAccountManager::PROPERTY_ADDRESS]['value'],
'addressScope' => $data[AccountManager::PROPERTY_ADDRESS]['scope'], 'addressScope' => $data[IAccountManager::PROPERTY_ADDRESS]['scope'],
'message' => $this->l10n->t('Settings saved') 'message' => $this->l10n->t('Settings saved')
] ]
], ],

View File

@ -30,6 +30,7 @@ use OC\Accounts\AccountManager;
use OC\Encryption\Exceptions\ModuleDoesNotExistsException; use OC\Encryption\Exceptions\ModuleDoesNotExistsException;
use OC\Group\Manager; use OC\Group\Manager;
use OCA\Settings\Controller\UsersController; use OCA\Settings\Controller\UsersController;
use OCP\Accounts\IAccountManager;
use OCP\App\IAppManager; use OCP\App\IAppManager;
use OCP\AppFramework\Http; use OCP\AppFramework\Http;
use OCP\BackgroundJob\IJobList; use OCP\BackgroundJob\IJobList;
@ -190,45 +191,45 @@ class UsersControllerTest extends \Test\TestCase {
->method('getUser') ->method('getUser')
->with($user) ->with($user)
->willReturn([ ->willReturn([
AccountManager::PROPERTY_DISPLAYNAME => IAccountManager::PROPERTY_DISPLAYNAME =>
[ [
'value' => 'Display name', 'value' => 'Display name',
'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY, 'scope' => IAccountManager::VISIBILITY_CONTACTS_ONLY,
'verified' => AccountManager::NOT_VERIFIED, 'verified' => IAccountManager::NOT_VERIFIED,
], ],
AccountManager::PROPERTY_ADDRESS => IAccountManager::PROPERTY_ADDRESS =>
[ [
'value' => '', 'value' => '',
'scope' => AccountManager::VISIBILITY_PRIVATE, 'scope' => IAccountManager::VISIBILITY_PRIVATE,
'verified' => AccountManager::NOT_VERIFIED, 'verified' => IAccountManager::NOT_VERIFIED,
], ],
AccountManager::PROPERTY_WEBSITE => IAccountManager::PROPERTY_WEBSITE =>
[ [
'value' => '', 'value' => '',
'scope' => AccountManager::VISIBILITY_PRIVATE, 'scope' => IAccountManager::VISIBILITY_PRIVATE,
'verified' => AccountManager::NOT_VERIFIED, 'verified' => IAccountManager::NOT_VERIFIED,
], ],
AccountManager::PROPERTY_EMAIL => IAccountManager::PROPERTY_EMAIL =>
[ [
'value' => '', 'value' => '',
'scope' => AccountManager::VISIBILITY_CONTACTS_ONLY, 'scope' => IAccountManager::VISIBILITY_CONTACTS_ONLY,
'verified' => AccountManager::NOT_VERIFIED, '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' => '', 'value' => '',
'scope' => AccountManager::VISIBILITY_PRIVATE, 'scope' => IAccountManager::VISIBILITY_PRIVATE,
'verified' => AccountManager::NOT_VERIFIED, 'verified' => IAccountManager::NOT_VERIFIED,
], ],
AccountManager::PROPERTY_TWITTER => IAccountManager::PROPERTY_TWITTER =>
[ [
'value' => '', 'value' => '',
'scope' => AccountManager::VISIBILITY_PRIVATE, 'scope' => IAccountManager::VISIBILITY_PRIVATE,
'verified' => AccountManager::NOT_VERIFIED, 'verified' => IAccountManager::NOT_VERIFIED,
], ],
]); ]);