diff options
author | Joas Schilling <coding@schilljs.com> | 2017-11-29 09:50:40 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-11-29 10:04:53 +0100 |
commit | 8e684f76e5d599917b52ddfd0ea1d58e31222487 (patch) | |
tree | 4525d5c9f471f00f3abf623aea00a416cbba32c4 | |
parent | a0ce2c1204861e64219f6375f6ff8d13e63cfe32 (diff) | |
download | nextcloud-server-8e684f76e5d599917b52ddfd0ea1d58e31222487.tar.gz nextcloud-server-8e684f76e5d599917b52ddfd0ea1d58e31222487.zip |
Allow `{lang}` as a placeholder in the skeleton directory
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | config/config.sample.php | 3 | ||||
-rw-r--r-- | lib/private/legacy/util.php | 15 |
2 files changed, 17 insertions, 1 deletions
diff --git a/config/config.sample.php b/config/config.sample.php index 022b807a881..59fb1d13610 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -242,6 +242,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 ``en`` * * Defaults to ``core/skeleton`` in the Nextcloud directory. */ diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index 3ce11746672..b9a7706eaf7 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -379,7 +379,20 @@ 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}', 'en', $plainSkeletonDirectory); + } + } + $instanceId = \OC::$server->getConfig()->getSystemValue('instanceid', ''); if ($instanceId === null) { |