From: Frank Karlitschek Date: Thu, 3 Oct 2013 21:22:11 +0000 (+0200) Subject: make it possible to prepopulate a new user gome with a skeleton X-Git-Tag: v6.0.0alpha2~102^2~5 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e40afbebc64547219e88dc0045d6a04cd06e76f8;p=nextcloud-server.git make it possible to prepopulate a new user gome with a skeleton --- diff --git a/core/skeleton/.gitignore b/core/skeleton/.gitignore new file mode 100644 index 00000000000..5e7d2734cfc --- /dev/null +++ b/core/skeleton/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/lib/private/util.php b/lib/private/util.php index 1cbb19eaec4..004e82d7d26 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -68,6 +68,7 @@ class OC_Util { $userDirectory = $userRoot . '/files'; if( !is_dir( $userDirectory )) { mkdir( $userDirectory, 0755, true ); + OC_Util::copySkeleton($userDirectory); } //jail the user into his "home" directory \OC\Files\Filesystem::init($user, $userDir); @@ -92,6 +93,37 @@ class OC_Util { } } + /** + * @brief copies the user skeleton files into the fresh userr home files + * @param string $userDirectory + * @return void + */ + public static function copySkeleton($userDirectory) { + error_log('skeleton init '.$userDirectory); + OC_Util::copyr(\OC::$SERVERROOT.'/core/skeleton' , $userDirectory); + } + + /** + * @brief copies a directory recursively + * @param string $source + * @param string $target + * @return void + */ + function copyr($source,$target) { + $dir = opendir($source); + @mkdir($target); + while(false !== ( $file = readdir($dir)) ) { + if (( $file != '.' ) && ( $file != '..' )) { + if ( is_dir($source . '/' . $file) ) { + OC_Util::copyr($source . '/' . $file , $target . '/' . $file); + } else { + copy($source . '/' . $file,$target . '/' . $file); + } + } + } + closedir($dir); + } + /** * @return void */