Fix languages empty array

Signed-off-by: GretaD <gretadoci@gmail.com>
This commit is contained in:
GretaD 2020-04-29 14:42:07 +02:00 committed by Morris Jobke
parent 9012f4f906
commit fce716b905
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
4 changed files with 74 additions and 49 deletions

View File

@ -146,7 +146,7 @@ abstract class AUserData 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');
$data['language'] = $this->config->getSystemValue('force_language', $this->config->getUserValue($targetUserObject->getUID(), 'core', 'lang'));
$data['locale'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'locale');
$backend = $targetUserObject->getBackend();

View File

@ -958,6 +958,11 @@ class UsersControllerTest extends TestCase {
->method('getUserValue')
->with('UID', 'core', 'lang')
->willReturn('de');
$this->config
->expects($this->once())
->method('getSystemValue')
->with('force_language', 'de')
->willReturn('de');
$this->api
->expects($this->once())
->method('fillStorageInfo')
@ -1073,6 +1078,11 @@ class UsersControllerTest extends TestCase {
->method('getUserValue')
->with('UID', 'core', 'enabled', 'true')
->willReturn('true');
$this->config
->expects($this->once())
->method('getSystemValue')
->with('force_language', 'da')
->willReturn('da');
$this->config
->expects($this->at(1))
->method('getUserValue')
@ -1245,6 +1255,11 @@ class UsersControllerTest extends TestCase {
->method('fillStorageInfo')
->with('UID')
->willReturn(['DummyValue']);
$this->config
->expects($this->once())
->method('getSystemValue')
->with('force_language', 'ru')
->willReturn('ru');
$backend = $this->createMock(UserInterface::class);
$backend->expects($this->atLeastOnce())

View File

@ -236,6 +236,7 @@ class UsersController extends Controller {
$serverData['userCount'] = $userCount;
$serverData['languages'] = $languages;
$serverData['defaultLanguage'] = $this->config->getSystemValue('default_language', 'en');
$serverData['forceLanguage'] = $this->config->getSystemValue('force_language', false);
// Settings
$serverData['defaultQuota'] = $defaultQuota;
$serverData['canChangePassword'] = $canChangePassword;

View File

@ -585,7 +585,16 @@ class Factory implements IFactory {
public function getLanguages() {
$forceLanguage = $this->config->getSystemValue('force_language', false);
if ($forceLanguage !== false) {
return [];
$l = $this->get('lib', $forceLanguage);
$potentialName = (string) $l->t('__language_name__');
return [
'commonlanguages' => [[
'code' => $forceLanguage,
'name' => $potentialName,
]],
'languages' => [],
];
}
$languageCodes = $this->findAvailableLanguages();