MDL-23261, fixed deleting folders

This commit is contained in:
Dongsheng Cai 2010-07-14 10:09:19 +00:00
parent b1b769b046
commit 5ad337c86c

View File

@ -80,11 +80,21 @@ switch ($action) {
$return = new stdclass;
if ($stored_file = $fs->get_file($user_context->id, 'user', 'draft', $draftid, $filepath, $filename)) {
$parent_path = $stored_file->get_parent_directory()->get_filepath();
if($result = $stored_file->delete()) {
if ($stored_file->is_directory()) {
$files = $fs->get_directory_files($user_context->id, 'user', 'draft', $draftid, $filepath, true);
foreach ($files as $file) {
$file->delete();
}
$stored_file->delete();
$return->filepath = $parent_path;
echo json_encode($return);
} else {
echo json_encode(false);
if($result = $stored_file->delete()) {
$return->filepath = $parent_path;
echo json_encode($return);
} else {
echo json_encode(false);
}
}
} else {
echo json_encode(false);