create default index-file also in subfolders if newly created (and enabled), needs testing, fixes #68

This commit is contained in:
Michael Kaufmann (d00p)
2010-03-17 12:20:14 +00:00
parent c1de55f3d5
commit 55aab4004c
11 changed files with 102 additions and 28 deletions

View File

@@ -26,13 +26,15 @@
* @param string The dir which should be created
* @param int The uid of the user
* @param int The gid of the user
* @param bool Place standard-index.html into the new folder
*
* @return bool true if everything went okay, false if something went wrong
*
* @author Florian Lippert <flo@syscp.org>
* @author Martin Burchert <martin.burchert@syscp.org>
*/
function mkDirWithCorrectOwnership($homeDir, $dirToCreate, $uid, $gid)
function mkDirWithCorrectOwnership($homeDir, $dirToCreate, $uid, $gid, $placeindex = false)
{
$returncode = true;
@@ -73,6 +75,17 @@ function mkDirWithCorrectOwnership($homeDir, $dirToCreate, $uid, $gid)
{
$sdir = makeCorrectDir($sdir);
safe_exec('mkdir -p ' . escapeshellarg($sdir));
/**
* #68
*/
if ($placeindex) {
$loginname = getLoginNameByUid($uid);
if ($loginname !== false) {
storeDefaultIndex($loginname, $sdir, null);
}
}
safe_exec('chown -R ' . (int)$uid . ':' . (int)$gid . ' ' . escapeshellarg($sdir));
}
}