Commit 77b25893 authored by Alan McNatty's avatar Alan McNatty
Browse files

Auto create folder if it doesn't exist

parent 5f289f26
......@@ -72,17 +72,19 @@ try {
$folder = param_variable('foldername');
$folder = trim($folder);
if ( $folder == 'Home' ) {
$data->parent = null;
} else {
// TODO: create if doesn't exist - note assumes it is a base folder (hence null parent)
$artefact = ArtefactTypeFolder::get_folder_by_name($folder, null, $data->owner); // id of folder you're putting the file into
if ( $artefact ) {
$data->parent = $artefact->id;
if ( $data->parent == 0 ) $data->parent = null;
} else {
header($protocol." 500 Upload folder '$folder' does not exit");
exit;
}
$fd = (object) array( 'owner' => $data->owner,
'title' => $folder,
'parent' => null,
);
$f = new ArtefactTypeFolder(0, $fd);
$f->commit();
$data->parent = $f->get('id');
}
}
catch (ParameterException $e) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment