Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-34290 repository_filesystem: do not store files in moodle filepoo…

…l unless images
  • Loading branch information...
commit 074455a6f596c9d03c1e0f10df7715046329f59e 1 parent 7fa4cd1
Marina Glancy authored August 28, 2012

Showing 1 changed file with 12 additions and 7 deletions. Show diff stats Hide diff stats

  1. 19  repository/filesystem/lib.php
19  repository/filesystem/lib.php
@@ -273,17 +273,13 @@ public function get_reference_details($reference, $filestatus = 0) {
273 273
 
274 274
     /**
275 275
      * Returns information about file in this repository by reference
276  
-     * {@link repository::get_file_reference()}
277  
-     * {@link repository::get_file()}
278 276
      *
279 277
      * Returns null if file not found or is not readable
280 278
      *
281 279
      * @param stdClass $reference file reference db record
282 280
      * @return stdClass|null contains one of the following:
283  
-     *   - 'contenthash' and 'filesize'
284  
-     *   - 'filepath'
285  
-     *   - 'handle'
286  
-     *   - 'content'
  281
+     *   - 'filesize' if file should not be copied to moodle filepool
  282
+     *   - 'filepath' if file should be copied to moodle filepool
287 283
      */
288 284
     public function get_file_by_reference($reference) {
289 285
         $ref = $reference->reference;
@@ -293,7 +289,16 @@ public function get_file_by_reference($reference) {
293 289
             $filepath = $this->root_path.$ref;
294 290
         }
295 291
         if (file_exists($filepath) && is_readable($filepath)) {
296  
-            return (object)array('filepath' => $filepath);
  292
+            if (file_extension_in_typegroup($filepath, 'web_image')) {
  293
+                // return path to image files so it will be copied into moodle filepool
  294
+                // we need the file in filepool to generate an image thumbnail
  295
+                return (object)array('filepath' => $filepath);
  296
+            } else {
  297
+                // return just the file size so file will NOT be copied into moodle filepool
  298
+                return (object)array(
  299
+                    'filesize' => filesize($filepath)
  300
+                );
  301
+            }
297 302
         } else {
298 303
             return null;
299 304
         }

0 notes on commit 074455a

Please sign in to comment.
Something went wrong with that request. Please try again.