Merge branch 'MDL-41907' of https://github.com/merrill-oakland/moodle
authorSam Hemelryk <sam@moodle.com>
Tue, 24 Sep 2013 22:18:30 +0000 (10:18 +1200)
committerSam Hemelryk <sam@moodle.com>
Tue, 24 Sep 2013 22:18:30 +0000 (10:18 +1200)
1  2 
repository/lib.php

diff --combined repository/lib.php
@@@ -743,7 -743,7 +743,7 @@@ abstract class repository implements ca
          $repocontext = context::instance_by_id($this->instance->contextid);
  
          // Prevent access to private repositories when logged in as.
 -        if ($can && session_is_loggedinas()) {
 +        if ($can && \core\session\manager::is_loggedinas()) {
              if ($this->contains_private_data() || $repocontext->contextlevel == CONTEXT_USER) {
                  $can = false;
              }
              if ($tempfile = $fs->get_file($user_context->id, 'user', 'draft', $itemid, $newfilepath, $newfilename)) {
                  // Remember original file source field.
                  $source = @unserialize($file->get_source());
+                 // Remember the original sortorder.
+                 $sortorder = $file->get_sortorder();
                  if ($tempfile->is_external_file()) {
                      // New file is a reference. Check that existing file does not have any other files referencing to it
                      if (isset($source->original) && $fs->search_references_count($source->original)) {
                      $newfilesource->original = $source->original;
                      $newfile->set_source(serialize($newfilesource));
                  }
+                 $newfile->set_sortorder($sortorder);
                  // remove temp file
                  $tempfile->delete();
                  return true;
          $classname = $data['class'];
          return new $classname($data['id'], $data['ctxid'], $data['options'], $data['readonly']);
      }
 +
 +    /**
 +     * Gets a file relative to this file in the repository and sends it to the browser.
 +     * Used to allow relative file linking within a repository without creating file records
 +     * for linked files
 +     *
 +     * Repositories that overwrite this must be very careful - see filesystem repository for example.
 +     *
 +     * @param stored_file $mainfile The main file we are trying to access relative files for.
 +     * @param string $relativepath the relative path to the file we are trying to access.
 +     *
 +     */
 +    public function send_relative_file(stored_file $mainfile, $relativepath) {
 +        // This repository hasn't implemented this so send_file_not_found.
 +        send_file_not_found();
 +    }
 +
 +    /**
 +     * helper function to check if the repository supports send_relative_file.
 +     *
 +     * @return true|false
 +     */
 +    public function supports_relative_file() {
 +        return false;
 +    }
  }
  
  /**