diff options
author | Joas Schilling <coding@schilljs.com> | 2017-06-21 11:22:05 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-06-21 11:34:52 +0200 |
commit | 7816c5462531bfb20ab977b430081ab5ccf04755 (patch) | |
tree | 9161d24af014df15b2393646cc44fdb7922e181e /apps/provisioning_api/lib | |
parent | 146c699eb49e05c499bf6673f85a948aecceec97 (diff) | |
download | nextcloud-server-7816c5462531bfb20ab977b430081ab5ccf04755.tar.gz nextcloud-server-7816c5462531bfb20ab977b430081ab5ccf04755.zip |
Allow to force a language and set it via the ocs api
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/provisioning_api/lib')
-rw-r--r-- | apps/provisioning_api/lib/Controller/UsersController.php | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index 132727eecbd..25cc13d1c32 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -286,6 +286,7 @@ class UsersController extends OCSController { $data[AccountManager::PROPERTY_WEBSITE] = $userAccount[AccountManager::PROPERTY_WEBSITE]['value']; $data[AccountManager::PROPERTY_TWITTER] = $userAccount[AccountManager::PROPERTY_TWITTER]['value']; $data['groups'] = $gids; + $data['language'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'lang'); return $data; } @@ -322,6 +323,10 @@ class UsersController extends OCSController { } $permittedFields[] = 'password'; + if ($this->config->getSystemValue('force_language', false) === false || + $this->groupManager->isAdmin($currentLoggedInUser->getUID())) { + $permittedFields[] = 'language'; + } if ($this->appManager->isEnabledForUser('federatedfilesharing')) { $federatedFileSharing = new \OCA\FederatedFileSharing\AppInfo\Application(); @@ -348,6 +353,7 @@ class UsersController extends OCSController { $permittedFields[] = AccountManager::PROPERTY_DISPLAYNAME; $permittedFields[] = AccountManager::PROPERTY_EMAIL; $permittedFields[] = 'password'; + $permittedFields[] = 'language'; $permittedFields[] = AccountManager::PROPERTY_PHONE; $permittedFields[] = AccountManager::PROPERTY_ADDRESS; $permittedFields[] = AccountManager::PROPERTY_WEBSITE; @@ -392,6 +398,13 @@ class UsersController extends OCSController { case 'password': $targetUser->setPassword($value); break; + case 'language': + $languagesCodes = $this->l10nFactory->findAvailableLanguages(); + if (!in_array($value, $languagesCodes, true) && $value !== 'en') { + throw new OCSException('Invalid language', 102); + } + $this->config->setUserValue($targetUser->getUID(), 'core', 'lang', $value); + break; case AccountManager::PROPERTY_EMAIL: if(filter_var($value, FILTER_VALIDATE_EMAIL)) { $targetUser->setEMailAddress($value); |