From e40afbebc64547219e88dc0045d6a04cd06e76f8 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Thu, 3 Oct 2013 23:22:11 +0200 Subject: [PATCH 1/6] make it possible to prepopulate a new user gome with a skeleton --- core/skeleton/.gitignore | 4 ++++ lib/private/util.php | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 core/skeleton/.gitignore 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 */ From 6d954366950c57a8d999a652a7c1b22b95659ee3 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Fri, 4 Oct 2013 09:24:07 +0200 Subject: [PATCH 2/6] add public static --- lib/private/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/util.php b/lib/private/util.php index 004e82d7d26..d5c44795e10 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -109,7 +109,7 @@ class OC_Util { * @param string $target * @return void */ - function copyr($source,$target) { + public static function copyr($source,$target) { $dir = opendir($source); @mkdir($target); while(false !== ( $file = readdir($dir)) ) { From f0a98cc92374f62a1fdd884c206424242427c8c5 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Fri, 4 Oct 2013 09:25:54 +0200 Subject: [PATCH 3/6] fix typo --- lib/private/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/util.php b/lib/private/util.php index d5c44795e10..d0b0fbfc807 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -94,7 +94,7 @@ class OC_Util { } /** - * @brief copies the user skeleton files into the fresh userr home files + * @brief copies the user skeleton files into the fresh user home files * @param string $userDirectory * @return void */ From e49ee47e7b9cd6bc03851281d270885b9fd2d70c Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Fri, 4 Oct 2013 09:28:46 +0200 Subject: [PATCH 4/6] use Filesystem::isIgnoredDir --- lib/private/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/private/util.php b/lib/private/util.php index d0b0fbfc807..cb33e3597a2 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -113,7 +113,7 @@ class OC_Util { $dir = opendir($source); @mkdir($target); while(false !== ( $file = readdir($dir)) ) { - if (( $file != '.' ) && ( $file != '..' )) { + if ( !\OC\Files\Filesystem::isIgnoredDir($file) ) { if ( is_dir($source . '/' . $file) ) { OC_Util::copyr($source . '/' . $file , $target . '/' . $file); } else { From 47666796a73e28097be03d9de8a333907c69e5cc Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Fri, 4 Oct 2013 09:42:38 +0200 Subject: [PATCH 5/6] ups. remove debug --- lib/private/util.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/private/util.php b/lib/private/util.php index cb33e3597a2..a4e9d07147e 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -96,10 +96,8 @@ class OC_Util { /** * @brief copies the user skeleton files into the fresh user 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); } From 566d826a9e6f47d893c3afd724974c72b6a3758c Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Fri, 4 Oct 2013 10:21:33 +0200 Subject: [PATCH 6/6] add a real examplefile instead of an .gitignore which is a bit stupid here --- core/skeleton/.gitignore | 4 ---- core/skeleton/welcome.txt | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) delete mode 100644 core/skeleton/.gitignore create mode 100644 core/skeleton/welcome.txt diff --git a/core/skeleton/.gitignore b/core/skeleton/.gitignore deleted file mode 100644 index 5e7d2734cfc..00000000000 --- a/core/skeleton/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Ignore everything in this directory -* -# Except this file -!.gitignore diff --git a/core/skeleton/welcome.txt b/core/skeleton/welcome.txt new file mode 100644 index 00000000000..c86eaf91bbe --- /dev/null +++ b/core/skeleton/welcome.txt @@ -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. +