mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-23261, fixed deleting folders
This commit is contained in:
parent
b1b769b046
commit
5ad337c86c
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user