summaryrefslogtreecommitdiffstats
path: root/settings/Controller
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2016-11-11 14:36:17 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2016-11-21 11:29:57 +0100
commit8f33d9d1c07c164b18be9d36e9e9f79b5bdfa8be (patch)
tree2f6d2e5b58666a2cddc19ff2aed5cf7fa32cf36d /settings/Controller
parent987995ac920a2d1e1251df80a482e3aef97c06f6 (diff)
downloadnextcloud-server-8f33d9d1c07c164b18be9d36e9e9f79b5bdfa8be.tar.gz
nextcloud-server-8f33d9d1c07c164b18be9d36e9e9f79b5bdfa8be.zip
update system address book if the user change the personal settings
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'settings/Controller')
-rw-r--r--settings/Controller/UsersController.php39
1 files changed, 21 insertions, 18 deletions
diff --git a/settings/Controller/UsersController.php b/settings/Controller/UsersController.php
index 6bbf8786520..08d97a0f581 100644
--- a/settings/Controller/UsersController.php
+++ b/settings/Controller/UsersController.php
@@ -519,6 +519,8 @@ class UsersController extends Controller {
* @param string $websiteScope
* @param string $address
* @param string $addressScope
+ * @param string $twitter
+ * @param string $twitterScope
* @return DataResponse
*/
public function setUserSettings($avatarScope,
@@ -526,7 +528,8 @@ class UsersController extends Controller {
$phone, $phoneScope,
$email, $emailScope,
$website, $websiteScope,
- $address, $addressScope
+ $address, $addressScope,
+ $twitter, $twitterScope
) {
@@ -542,26 +545,27 @@ class UsersController extends Controller {
);
}
- $userId = $this->userSession->getUser()->getUID();
+ $user = $this->userSession->getUser();
$data = [
- 'avatar' => ['scope' => $avatarScope],
- 'displayName' => ['value' => $displayname, 'scope' => $displaynameScope],
- 'email' => [['value' => $email, 'scope' => $emailScope]],
- 'website' => [['value' => $website, 'scope' => $websiteScope]],
- 'address' => [['value' => $address, 'scope' => $addressScope]],
- 'phone' => [['value' => $phone, 'scope' => $phoneScope]]
+ 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]
];
- $this->accountManager->updateUser($userId, $data);
+ $this->accountManager->updateUser($user, $data);
try {
- $this->saveUserSettings($userId, $data);
+ $this->saveUserSettings($user, $data);
return new DataResponse(
array(
'status' => 'success',
'data' => array(
- 'userId' => $userId,
+ 'userId' => $user->getUID(),
'avatarScope' => $avatarScope,
'displayname' => $displayname,
'displaynameScope' => $displaynameScope,
@@ -591,12 +595,11 @@ class UsersController extends Controller {
/**
* update account manager with new user data
*
- * @param string $userId
+ * @param IUser $user
* @param array $data
* @throws ForbiddenException
*/
- private function saveUserSettings($userId, $data) {
- $user = $this->userManager->get($userId);
+ private function saveUserSettings(IUser $user, $data) {
// keep the user back-end up-to-date with the latest display name and email
// address
@@ -614,7 +617,7 @@ class UsersController extends Controller {
}
}
- $this->accountManager->updateUser($userId, $data);
+ $this->accountManager->updateUser($user, $data);
}
/**
@@ -688,12 +691,12 @@ class UsersController extends Controller {
]);
}
- $userData = $this->accountManager->getUser($user->getUID());
- $userData['displayName']['value'] = $displayName;
+ $userData = $this->accountManager->getUser($user);
+ $userData[AccountManager::PROPERTY_DISPLAYNAME]['value'] = $displayName;
try {
- $this->saveUserSettings($username, $userData);
+ $this->saveUserSettings($user, $userData);
return new DataResponse([
'status' => 'success',
'data' => [