Add function copyDirectory so when creating a document from a template copy the document_template folder to documents folder and update links

This commit is contained in:
johnnyq
2025-11-23 15:26:29 -05:00
parent a99b19a1b5
commit 4153c91f84
2 changed files with 106 additions and 0 deletions

View File

@@ -63,6 +63,32 @@ function removeDirectory($path) {
rmdir($path);
}
function copyDirectory($src, $dst) {
if (!is_dir($src)) {
return;
}
if (!is_dir($dst)) {
mkdir($dst, 0775, true);
}
$items = scandir($src);
foreach ($items as $item) {
if ($item === '.' || $item === '..') {
continue;
}
$srcPath = $src . '/' . $item;
$dstPath = $dst . '/' . $item;
if (is_dir($srcPath)) {
copyDirectory($srcPath, $dstPath);
} else {
copy($srcPath, $dstPath);
}
}
}
function getUserAgent() {
return $_SERVER['HTTP_USER_AGENT'];
}