summaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api
diff options
context:
space:
mode:
Diffstat (limited to 'apps/provisioning_api')
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php13
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php34
2 files changed, 39 insertions, 8 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);
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index 61205b45900..03c9809009b 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -699,6 +699,11 @@ class UsersControllerTest extends TestCase {
->method('getUserValue')
->with('UID', 'core', 'enabled', 'true')
->will($this->returnValue('true'));
+ $this->config
+ ->expects($this->at(1))
+ ->method('getUserValue')
+ ->with('UID', 'core', 'lang')
+ ->will($this->returnValue('de'));
$this->api
->expects($this->once())
->method('fillStorageInfo')
@@ -709,7 +714,7 @@ class UsersControllerTest extends TestCase {
->method('getDisplayName')
->will($this->returnValue('Demo User'));
$targetUser
- ->expects($this->exactly(3))
+ ->expects($this->exactly(4))
->method('getUID')
->will($this->returnValue('UID'));
@@ -723,7 +728,8 @@ class UsersControllerTest extends TestCase {
'address' => 'address',
'website' => 'website',
'twitter' => 'twitter',
- 'groups' => ['group0', 'group1', 'group2']
+ 'groups' => ['group0', 'group1', 'group2'],
+ 'language' => 'de',
];
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['UserToGet']));
}
@@ -778,6 +784,11 @@ class UsersControllerTest extends TestCase {
->method('getUserValue')
->with('UID', 'core', 'enabled', 'true')
->will($this->returnValue('true'));
+ $this->config
+ ->expects($this->at(1))
+ ->method('getUserValue')
+ ->with('UID', 'core', 'lang')
+ ->will($this->returnValue('da'));
$this->api
->expects($this->once())
->method('fillStorageInfo')
@@ -788,7 +799,7 @@ class UsersControllerTest extends TestCase {
->method('getDisplayName')
->will($this->returnValue('Demo User'));
$targetUser
- ->expects($this->exactly(3))
+ ->expects($this->exactly(4))
->method('getUID')
->will($this->returnValue('UID'));
$this->accountManager->expects($this->any())->method('getUser')
@@ -812,7 +823,8 @@ class UsersControllerTest extends TestCase {
'address' => 'address',
'website' => 'website',
'twitter' => 'twitter',
- 'groups' => []
+ 'groups' => [],
+ 'language' => 'da',
];
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['UserToGet']));
}
@@ -918,9 +930,14 @@ class UsersControllerTest extends TestCase {
->method('getEMailAddress')
->will($this->returnValue('subadmin@owncloud.org'));
$targetUser
- ->expects($this->exactly(3))
+ ->expects($this->exactly(4))
->method('getUID')
->will($this->returnValue('UID'));
+ $this->config
+ ->expects($this->at(0))
+ ->method('getUserValue')
+ ->with('UID', 'core', 'lang')
+ ->will($this->returnValue('ru'));
$this->accountManager->expects($this->any())->method('getUser')
->with($targetUser)
->willReturn(
@@ -941,7 +958,8 @@ class UsersControllerTest extends TestCase {
'address' => 'address',
'website' => 'website',
'twitter' => 'twitter',
- 'groups' => []
+ 'groups' => [],
+ 'language' => 'ru',
];
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['subadmin']));
}
@@ -1128,7 +1146,7 @@ class UsersControllerTest extends TestCase {
->with('UserToEdit')
->will($this->returnValue($targetUser));
$this->groupManager
- ->expects($this->once())
+ ->expects($this->exactly(2))
->method('isAdmin')
->with('UID')
->will($this->returnValue(true));
@@ -1163,7 +1181,7 @@ class UsersControllerTest extends TestCase {
->with('UserToEdit')
->will($this->returnValue($targetUser));
$this->groupManager
- ->expects($this->once())
+ ->expects($this->exactly(2))
->method('isAdmin')
->with('UID')
->will($this->returnValue(true));