aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-06-02 12:31:37 +0200
committerJoas Schilling <coding@schilljs.com>2017-06-02 12:31:37 +0200
commit19041ed1a8a7a60570ae726445dd7535a304c322 (patch)
treec5b4d9500d4ce829d672eed39999b79275c6c655
parent0e26ba4c2adec21de3b5239a646bb4dbde44b2f4 (diff)
downloadnextcloud-server-19041ed1a8a7a60570ae726445dd7535a304c322.tar.gz
nextcloud-server-19041ed1a8a7a60570ae726445dd7535a304c322.zip
Also cover the settings endpoint
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--settings/Controller/UsersController.php50
1 files changed, 31 insertions, 19 deletions
diff --git a/settings/Controller/UsersController.php b/settings/Controller/UsersController.php
index d4a5de93a36..e217e189463 100644
--- a/settings/Controller/UsersController.php
+++ b/settings/Controller/UsersController.php
@@ -78,6 +78,8 @@ class UsersController extends Controller {
private $isEncryptionAppEnabled;
/** @var bool contains the state of the admin recovery setting */
private $isRestoreEnabled = false;
+ /** @var IAppManager */
+ private $appManager;
/** @var IAvatarManager */
private $avatarManager;
/** @var AccountManager */
@@ -146,6 +148,7 @@ class UsersController extends Controller {
$this->l10n = $l10n;
$this->log = $log;
$this->mailer = $mailer;
+ $this->appManager = $appManager;
$this->avatarManager = $avatarManager;
$this->accountManager = $accountManager;
$this->secureRandom = $secureRandom;
@@ -718,18 +721,27 @@ class UsersController extends Controller {
);
}
- $data = [
- AccountManager::PROPERTY_AVATAR => ['scope' => $avatarScope],
- AccountManager::PROPERTY_DISPLAYNAME => ['value' => $displayname, 'scope' => $displaynameScope],
- AccountManager::PROPERTY_EMAIL=> ['value' => $email, 'scope' => $emailScope],
- AccountManager::PROPERTY_WEBSITE => ['value' => $website, 'scope' => $websiteScope],
- AccountManager::PROPERTY_ADDRESS => ['value' => $address, 'scope' => $addressScope],
- AccountManager::PROPERTY_PHONE => ['value' => $phone, 'scope' => $phoneScope],
- AccountManager::PROPERTY_TWITTER => ['value' => $twitter, 'scope' => $twitterScope]
- ];
-
$user = $this->userSession->getUser();
+ $data = $this->accountManager->getUser($user);
+
+ $data[AccountManager::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];
+ }
+
+ if ($this->appManager->isEnabledForUser('federatedfilesharing')) {
+ $federatedFileSharing = new \OCA\FederatedFileSharing\AppInfo\Application();
+ $shareProvider = $federatedFileSharing->getFederatedShareProvider();
+ 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];
+ }
+ }
+
try {
$this->saveUserSettings($user, $data);
return new DataResponse(
@@ -737,15 +749,15 @@ class UsersController extends Controller {
'status' => 'success',
'data' => [
'userId' => $user->getUID(),
- 'avatarScope' => $avatarScope,
- 'displayname' => $displayname,
- 'displaynameScope' => $displaynameScope,
- 'email' => $email,
- 'emailScope' => $emailScope,
- 'website' => $website,
- 'websiteScope' => $websiteScope,
- 'address' => $address,
- 'addressScope' => $addressScope,
+ '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'],
'message' => (string) $this->l10n->t('Settings saved')
]
],