Merge pull request #7334 from nextcloud/feature/noid/language-depending-skeleton-directory

Allow `{lang}` as a placeholder in the skeleton directory
This commit is contained in:
blizzz 2017-12-08 18:19:01 +01:00 committed by GitHub
commit 83509b0fd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View file

@ -246,6 +246,9 @@ $CONFIG = array(
* The directory where the skeleton files are located. These files will be
* copied to the data directory of new users. Leave empty to not copy any
* skeleton files.
* ``{lang}`` can be used as a placeholder for the language of the user.
* If the directory does not exist, it falls back to non dialect (from ``de_DE``
* to ``de``). If that does not exist either, it falls back to ``default``
*
* Defaults to ``core/skeleton`` in the Nextcloud directory.
*/
@ -878,6 +881,7 @@ $CONFIG = array(
/**
* custom path for LibreOffice/OpenOffice binary
*
*
* Defaults to ``''`` (empty string)
*/
'preview_libreoffice_path' => '/usr/bin/libreoffice',

View file

@ -379,7 +379,23 @@ class OC_Util {
*/
public static function copySkeleton($userId, \OCP\Files\Folder $userDirectory) {
$skeletonDirectory = \OC::$server->getConfig()->getSystemValue('skeletondirectory', \OC::$SERVERROOT . '/core/skeleton');
$plainSkeletonDirectory = \OC::$server->getConfig()->getSystemValue('skeletondirectory', \OC::$SERVERROOT . '/core/skeleton');
$userLang = \OC::$server->getL10NFactory()->findLanguage();
$skeletonDirectory = str_replace('{lang}', $userLang, $plainSkeletonDirectory);
if (!file_exists($skeletonDirectory)) {
$dialectStart = strpos($userLang, '_');
if ($dialectStart !== false) {
$skeletonDirectory = str_replace('{lang}', substr($userLang, 0, $dialectStart), $plainSkeletonDirectory);
}
if ($dialectStart === false || !file_exists($skeletonDirectory)) {
$skeletonDirectory = str_replace('{lang}', 'default', $plainSkeletonDirectory);
}
if (!file_exists($skeletonDirectory)) {
$skeletonDirectory = '';
}
}
$instanceId = \OC::$server->getConfig()->getSystemValue('instanceid', '');
if ($instanceId === null) {