diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2016-11-11 14:36:17 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-11-21 11:29:57 +0100 |
commit | 8f33d9d1c07c164b18be9d36e9e9f79b5bdfa8be (patch) | |
tree | 2f6d2e5b58666a2cddc19ff2aed5cf7fa32cf36d /settings | |
parent | 987995ac920a2d1e1251df80a482e3aef97c06f6 (diff) | |
download | nextcloud-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')
-rw-r--r-- | settings/Controller/UsersController.php | 39 | ||||
-rw-r--r-- | settings/js/federationsettingsview.js | 3 | ||||
-rw-r--r-- | settings/personal.php | 35 | ||||
-rw-r--r-- | settings/templates/personal.php | 24 |
4 files changed, 65 insertions, 36 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' => [ diff --git a/settings/js/federationsettingsview.js b/settings/js/federationsettingsview.js index 73b9f857558..6d9c407b2da 100644 --- a/settings/js/federationsettingsview.js +++ b/settings/js/federationsettingsview.js @@ -30,6 +30,7 @@ 'phone', 'email', 'website', + 'twitter', 'address', 'avatar' ]; @@ -159,4 +160,4 @@ OC.Settings = OC.Settings || {}; OC.Settings.FederationSettingsView = FederationSettingsView; -})(_, $, OC);
\ No newline at end of file +})(_, $, OC); diff --git a/settings/personal.php b/settings/personal.php index 9475b674b75..24955c94071 100644 --- a/settings/personal.php +++ b/settings/personal.php @@ -40,7 +40,7 @@ OC_Util::checkLoggedIn(); $defaults = \OC::$server->getThemingDefaults(); $certificateManager = \OC::$server->getCertificateManager(); -$accountManager = new \OC\Accounts\AccountManager(\OC::$server->getDatabaseConnection()); +$accountManager = new \OC\Accounts\AccountManager(\OC::$server->getDatabaseConnection(), \OC::$server->getEventDispatcher()); $config = \OC::$server->getConfig(); $urlGenerator = \OC::$server->getURLGenerator(); @@ -70,7 +70,6 @@ OC::$server->getNavigationManager()->setActiveEntry('personal'); $storageInfo=OC_Helper::getStorageInfo('/'); $user = OC::$server->getUserManager()->get(OC_User::getUser()); -$email = $user->getEMailAddress(); $userLang=$config->getUserValue( OC_User::getUser(), 'core', 'lang', \OC::$server->getL10NFactory()->findLanguage() ); $languageCodes = \OC::$server->getL10NFactory()->findAvailableLanguages(); @@ -156,29 +155,33 @@ if ($storageInfo['quota'] === \OCP\Files\FileInfo::SPACE_UNLIMITED) { } else { $totalSpace = OC_Helper::humanFileSize($storageInfo['total']); } -$userData = $accountManager->getUser($user->getUID()); + +$uid = $user->getUID(); +$userData = $accountManager->getUser($user); $tmpl->assign('total_space', $totalSpace); $tmpl->assign('usage_relative', $storageInfo['relative']); $tmpl->assign('clients', $clients); -$tmpl->assign('email', $email); +$tmpl->assign('email', $userData[\OC\Accounts\AccountManager::PROPERTY_EMAIL]['value']); $tmpl->assign('languages', $languages); $tmpl->assign('commonlanguages', $commonLanguages); $tmpl->assign('activelanguage', $userLang); $tmpl->assign('passwordChangeSupported', OC_User::canUserChangePassword(OC_User::getUser())); $tmpl->assign('displayNameChangeSupported', OC_User::canUserChangeDisplayName(OC_User::getUser())); -$tmpl->assign('displayName', OC_User::getDisplayName()); - -$tmpl->assign('phone', isset($userData['phone'][0]['value']) ? $userData['phone'][0]['value'] : null); -$tmpl->assign('website', isset($userData['website'][0]['value']) ? $userData['website'][0]['value'] : null); -$tmpl->assign('address', isset($userData['address'][0]['value']) ? $userData['address'][0]['value'] : null); - -$tmpl->assign('avatarScope', isset($userData['avatar']['scope']) ? $userData['avatar']['scope'] : 'contacts'); -$tmpl->assign('displayNameScope', isset($userData['displayName']['scope']) ? $userData['displayName']['scope'] : 'contacts'); -$tmpl->assign('phoneScope', isset($userData['phone'][0]['scope']) ? $userData['phone'][0]['scope'] : 'private'); -$tmpl->assign('emailScope', isset($userData['email'][0]['scope']) ? $userData['email'][0]['scope'] : 'private'); -$tmpl->assign('websiteScope', isset($userData['website'][0]['scope']) ? $userData['website'][0]['scope'] : 'private'); -$tmpl->assign('addressScope', isset($userData['address'][0]['scope']) ? $userData['address'][0]['scope'] : 'private'); +$tmpl->assign('displayName', $userData[\OC\Accounts\AccountManager::PROPERTY_DISPLAYNAME]['value']); + +$tmpl->assign('phone', $userData[\OC\Accounts\AccountManager::PROPERTY_PHONE]['value']); +$tmpl->assign('website', $userData[\OC\Accounts\AccountManager::PROPERTY_WEBSITE]['value']); +$tmpl->assign('twitter', $userData[\OC\Accounts\AccountManager::PROPERTY_TWITTER]['value']); +$tmpl->assign('address', $userData[\OC\Accounts\AccountManager::PROPERTY_ADDRESS]['value']); + +$tmpl->assign('avatarScope', $userData[\OC\Accounts\AccountManager::PROPERTY_AVATAR]['scope']); +$tmpl->assign('displayNameScope', $userData[\OC\Accounts\AccountManager::PROPERTY_DISPLAYNAME]['scope']); +$tmpl->assign('phoneScope', $userData[\OC\Accounts\AccountManager::PROPERTY_PHONE]['scope']); +$tmpl->assign('emailScope', $userData[\OC\Accounts\AccountManager::PROPERTY_EMAIL]['scope']); +$tmpl->assign('websiteScope', $userData[\OC\Accounts\AccountManager::PROPERTY_WEBSITE]['scope']); +$tmpl->assign('twitterScope', $userData[\OC\Accounts\AccountManager::PROPERTY_TWITTER]['scope']); +$tmpl->assign('addressScope', $userData[\OC\Accounts\AccountManager::PROPERTY_ADDRESS]['scope']); $tmpl->assign('enableAvatars', $config->getSystemValue('enable_avatars', true) === true); $tmpl->assign('avatarChangeSupported', OC_User::canUserChangeAvatar(OC_User::getUser())); diff --git a/settings/templates/personal.php b/settings/templates/personal.php index 2db0cfa4882..01f114d9e95 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -83,11 +83,12 @@ if($_['displayNameChangeSupported']) { <div class="personal-settings-setting-box"> <form id="phoneform" class="section"> <h2> - <label for="phone"><?php p($l->t('Phone name')); ?></label> + <label for="phone"><?php p($l->t('Phone number')); ?></label> <span class="icon-password"/> </h2> <input type="tel" id="phone" name="phone" value="<?php p($_['phone']) ?>" + placeholder="<?php p($l->t('Your phone number')); ?>" autocomplete="on" autocapitalize="off" autocorrect="off" /> <span class="icon-checkmark hidden"/> <input type="hidden" id="phonescope" value="<?php p($_['phoneScope']) ?>"> @@ -121,6 +122,22 @@ if($_['displayNameChangeSupported']) { <input type="hidden" id="websitescope" value="<?php p($_['websiteScope']) ?>"> </form> </div> + + <div class="personal-settings-setting-box"> + <form id="twitterform" class="section"> + <h2> + <label for="twitter"><?php p($l->t('Twitter')); ?></label> + <span class="icon-password"/> + </h2> + <input type="text" name="twitter" id="twitter" value="<?php p($_['twitter']); ?>" + placeholder="<?php p($l->t('Your Twitter handle')); ?>" + autocomplete="on" autocapitalize="off" autocorrect="off" /> + <span class="icon-checkmark hidden"/> + <input type="hidden" id="twitterscope" value="<?php p($_['twitterScope']) ?>"> + </form> + </div> + + <div class="personal-settings-setting-box"> <form id="addressform" class="section"> <h2> @@ -128,6 +145,7 @@ if($_['displayNameChangeSupported']) { <span class="icon-password"/> </h2> <input type="text" id="address" name="address" + placeholder="<?php p($l->t('Your postal address')); ?>" value="<?php p($_['address']) ?>" autocomplete="on" autocapitalize="off" autocorrect="off" /> <span class="icon-checkmark hidden"/> @@ -184,6 +202,10 @@ if($_['displayNameChangeSupported']) { <h2><?php p($l->t('Website')); ?></h2> <span><?php if(isset($_['website'][0])) { p($_['website']); } else { p($l->t('No website set')); }?></span> </div> + <div id="twitterform" class="section"> + <h2><?php p($l->t('Twitter')); ?></h2> + <span><?php if(isset($_['twitter'][0])) { p($_['twitter']); } else { p($l->t('No twitter handle set')); }?></span> + </div> <div id="addressform" class="section"> <h2><?php p($l->t('Address')); ?></h2> <span><?php if(isset($_['address'][0])) { p($_['address']); } else { p($l->t('No address set')); }?></span> |