MDL-22991, fixed file api calls
[moodle.git] / repository / local / lib.php
index 184d889..96f04ad 100755 (executable)
@@ -56,6 +56,7 @@ class repository_local extends repository {
                 $filename = clean_param($params['filename'], PARAM_FILE);
                 $filearea = clean_param($params['filearea'], PARAM_ALPHAEXT);
                 $filepath = clean_param($params['filepath'], PARAM_PATH);;
+                $component = clean_param($params['component'], PARAM_ALPHAEXT);
                 $context  = get_context_instance_by_id(clean_param($params['contextid'], PARAM_INT));
             }
         } else {
@@ -63,13 +64,13 @@ class repository_local extends repository {
             $filename = null;
             $filearea = null;
             $filepath = null;
+            $component = null;
             $context  = get_system_context();
         }
 
         $browser = get_file_browser();
 
-        if ($fileinfo = $browser->get_file_info($context, $filearea, $itemid, $filepath, $filename)) {
-            echo_fb($fileinfo);
+        if ($fileinfo = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename)) {
             // build path navigation
             $pathnodes = array();
             $encodedpath = base64_encode(serialize($fileinfo->get_params()));
@@ -172,11 +173,12 @@ class repository_local extends repository {
         $filename = clean_param($params['filename'], PARAM_FILE);
         $filepath = clean_param($params['filepath'], PARAM_PATH);;
         $filearea = clean_param($params['filearea'], PARAM_ALPHAEXT);
+        $component = clean_param($params['component'], PARAM_ALPHAEXT);
 
         $context = get_context_instance_by_id($contextid);
 
-        $file_info = $browser->get_file_info($context, $filearea, $fileitemid, $filepath, $filename);
-        $file_info->copy_to_storage($user_context->id, $new_filearea, $new_itemid, $new_filepath, $new_filename);
+        $file_info = $browser->get_file_info($context, $component, $filearea, $fileitemid, $filepath, $filename);
+        $file_info->copy_to_storage($user_context->id, 'user', 'draft', $new_itemid, $new_filepath, $new_filename);
 
         $info['itemid'] = $new_itemid;
         $info['title']  = $new_filename;