Merge pull request #20878 from nextcloud/backport/20719/stable19

This commit is contained in:
John Molakvoæ 2020-05-11 14:55:16 +02:00 committed by GitHub
commit 4bde23d239
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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_WEBSITE] = $userAccount[AccountManager::PROPERTY_WEBSITE]['value'];
$data[AccountManager::PROPERTY_TWITTER] = $userAccount[AccountManager::PROPERTY_TWITTER]['value']; $data[AccountManager::PROPERTY_TWITTER] = $userAccount[AccountManager::PROPERTY_TWITTER]['value'];
$data['groups'] = $gids; $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'); $data['locale'] = $this->config->getUserValue($targetUserObject->getUID(), 'core', 'locale');
$backend = $targetUserObject->getBackend(); $backend = $targetUserObject->getBackend();

View File

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

View File

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

View File

@ -585,7 +585,16 @@ class Factory implements IFactory {
public function getLanguages() { public function getLanguages() {
$forceLanguage = $this->config->getSystemValue('force_language', false); $forceLanguage = $this->config->getSystemValue('force_language', false);
if ($forceLanguage !== 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(); $languageCodes = $this->findAvailableLanguages();