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

@@@ -195,7 -195,7 +195,7 @@@ switch ($action) 
              // use external link
              $link = $repo->get_link($source);
              $info = array();
-             $info['filename'] = $saveas_filename;
+             $info['file'] = $saveas_filename;
              $info['type'] = 'link';
              $info['url'] = $link;
              echo json_encode($info);
              // 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;
              }
          $newfilepath = required_param('newfilepath', PARAM_PATH);
          $newfilename = required_param('newfilename', PARAM_FILE);
  
-         echo json_encode(repository::overwrite_existing_draftfile($itemid, $filepath, $filename, $newfilepath, $newfilename));
+         $info = repository::overwrite_existing_draftfile($itemid, $filepath, $filename, $newfilepath, $newfilename);
+         echo json_encode($info);
          break;
  
      case 'deletetmpfile':