mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 00:32:29 -04:00
Merge pull request #5107 from owncloud/user_skeleton
make it possible to prepopulate a new user home with a skeleton
This commit is contained in:
commit
514d7a884a
2 changed files with 35 additions and 0 deletions
5
core/skeleton/welcome.txt
Normal file
5
core/skeleton/welcome.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
Welcome to your ownCloud account!
|
||||
|
||||
This is just an example file for developers and git users.
|
||||
The packaged and released versions will come with better examples.
|
||||
|
||||
|
|
@ -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,35 @@ class OC_Util {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief copies the user skeleton files into the fresh user home files
|
||||
* @param string $userDirectory
|
||||
*/
|
||||
public static function copySkeleton($userDirectory) {
|
||||
OC_Util::copyr(\OC::$SERVERROOT.'/core/skeleton' , $userDirectory);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief copies a directory recursively
|
||||
* @param string $source
|
||||
* @param string $target
|
||||
* @return void
|
||||
*/
|
||||
public static function copyr($source,$target) {
|
||||
$dir = opendir($source);
|
||||
@mkdir($target);
|
||||
while(false !== ( $file = readdir($dir)) ) {
|
||||
if ( !\OC\Files\Filesystem::isIgnoredDir($file) ) {
|
||||
if ( is_dir($source . '/' . $file) ) {
|
||||
OC_Util::copyr($source . '/' . $file , $target . '/' . $file);
|
||||
} else {
|
||||
copy($source . '/' . $file,$target . '/' . $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue