make it possible to prepopulate a new user gome with a skeleton
This commit is contained in:
parent
de175a4b0f
commit
e40afbebc6
|
@ -0,0 +1,4 @@
|
||||||
|
# Ignore everything in this directory
|
||||||
|
*
|
||||||
|
# Except this file
|
||||||
|
!.gitignore
|
|
@ -68,6 +68,7 @@ class OC_Util {
|
||||||
$userDirectory = $userRoot . '/files';
|
$userDirectory = $userRoot . '/files';
|
||||||
if( !is_dir( $userDirectory )) {
|
if( !is_dir( $userDirectory )) {
|
||||||
mkdir( $userDirectory, 0755, true );
|
mkdir( $userDirectory, 0755, true );
|
||||||
|
OC_Util::copySkeleton($userDirectory);
|
||||||
}
|
}
|
||||||
//jail the user into his "home" directory
|
//jail the user into his "home" directory
|
||||||
\OC\Files\Filesystem::init($user, $userDir);
|
\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
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue