summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-10-04 02:57:17 -0700
committerThomas Müller <thomas.mueller@tmit.eu>2013-10-04 02:57:17 -0700
commit514d7a884a5211fe246487421ea8103202d004d7 (patch)
tree5050a83337bf6dbfa842c526eb7e3e39487dfacc
parentc38638fdf4ccaa04dc33b2975b5e4832ef04b703 (diff)
parent566d826a9e6f47d893c3afd724974c72b6a3758c (diff)
downloadnextcloud-server-514d7a884a5211fe246487421ea8103202d004d7.tar.gz
nextcloud-server-514d7a884a5211fe246487421ea8103202d004d7.zip
Merge pull request #5107 from owncloud/user_skeleton
make it possible to prepopulate a new user home with a skeleton
-rw-r--r--core/skeleton/welcome.txt5
-rwxr-xr-xlib/private/util.php30
2 files changed, 35 insertions, 0 deletions
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.
+
diff --git a/lib/private/util.php b/lib/private/util.php
index 1cbb19eaec4..a4e9d07147e 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,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
*/
public static function tearDownFS() {