MDL-28666, Fixed source field when download a file using filepicker
authorDongsheng Cai <dongsheng@moodle.com>
Thu, 17 May 2012 06:18:13 +0000 (14:18 +0800)
committerMarina Glancy <marina@moodle.com>
Mon, 21 May 2012 03:57:56 +0000 (11:57 +0800)
repository/repository_ajax.php

index 56a482a..55c65eb 100644 (file)
@@ -317,11 +317,18 @@ switch ($action) {
                 }
 
                 // Check if exceed maxbytes.
-                if (($maxbytes!==-1) && (filesize($file['path']) > $maxbytes)) {
+                if (($maxbytes!==-1) && (filesize($downloadedfile['path']) > $maxbytes)) {
                     throw new file_exception('maxbytes');
                 }
 
-                $record->source = !empty($downloadedfile['url']) ? $downloadedfile['url'] : '';
+                // {@link file_restore_source_field_from_draft_file()}
+                $sourcefield = '';
+                if (!empty($downloadedfile['url'])) {
+                    $source = new stdClass;
+                    $source->source = $downloadedfile['url'];
+                    $sourcefield = serialize($source);
+                }
+                $record->source = $sourcefield;
 
                 $info = repository::move_to_filepool($downloadedfile['path'], $record);
                 if (empty($info)) {