diff options
author | Frank Karlitschek <frank@owncloud.org> | 2013-10-03 23:22:11 +0200 |
---|---|---|
committer | Frank Karlitschek <frank@owncloud.org> | 2013-10-03 23:22:11 +0200 |
commit | e40afbebc64547219e88dc0045d6a04cd06e76f8 (patch) | |
tree | 7b821bb1949681e9f54fd2eb7a0838a1412991df /lib/private/util.php | |
parent | de175a4b0f0971c9cbbf912bbc3fd8cbc190b53d (diff) | |
download | nextcloud-server-e40afbebc64547219e88dc0045d6a04cd06e76f8.tar.gz nextcloud-server-e40afbebc64547219e88dc0045d6a04cd06e76f8.zip |
make it possible to prepopulate a new user gome with a skeleton
Diffstat (limited to 'lib/private/util.php')
-rwxr-xr-x | lib/private/util.php | 32 |
1 files changed, 32 insertions, 0 deletions
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); @@ -93,6 +94,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 */ public static function tearDownFS() { |