MDL-68758 core_repository: Allow ability to download files on all views.
[moodle.git] / repository / draftfiles_ajax.php
index 328f2d2..d00d068 100644 (file)
@@ -175,6 +175,13 @@ switch ($action) {
     case 'downloadselected':
         $selected   = required_param('selected', PARAM_RAW);
         $selectedfiles = json_decode($selected);
+        if (!count($selectedfiles)) {
+            $filepath = required_param('filepath', PARAM_PATH);
+            $selectedfiles = [(object)[
+                'filename' => '',
+                'filepath' => $filepath
+            ]];
+        }
         $return = repository_download_selected_files($usercontext, 'user', 'draft', $draftid, $selectedfiles);
         echo (json_encode($return));
         die;