Merge branch 'MDL-27919' of git://github.com/jamiepratt/moodle
authorSam Hemelryk <sam@moodle.com>
Mon, 31 Oct 2011 04:18:13 +0000 (17:18 +1300)
committerSam Hemelryk <sam@moodle.com>
Mon, 31 Oct 2011 04:18:13 +0000 (17:18 +1300)
1  2 
repository/repository_ajax.php

@@@ -205,16 -205,10 +205,19 @@@ switch ($action) 
              // method, so we use copy_to_area method
              // (local, user, coursefiles, recent)
              if ($repo->has_moodle_files()) {
 +                // check filesize against max allowed size
 +                $filesize = $repo->get_file_size($source);
 +                if (empty($filesize)) {
 +                    $err->error = get_string('filesizenull', 'repository');
 +                    die(json_encode($err));
 +                }
 +                if (($maxbytes !== -1) && ($filesize > $maxbytes)) {
 +                    throw new file_exception('maxbytes');
 +                }
                  $fileinfo = $repo->copy_to_area($source, $itemid, $saveas_path, $saveas_filename);
+                 if (!isset($fileinfo['event'])) {
+                     $fileinfo['file'] = $fileinfo['title'];
+                 }
                  echo json_encode($fileinfo);
                  die;
              }