Browse files

MDL-41907 Repositories: Maintain the sortorder of a file when overwri…

…ting it.
  • Loading branch information...
1 parent e81fce9 commit 4b8ed14f544b4716cc5f46209e1cdd0b8346feb1 @merrill-oakland merrill-oakland committed Sep 19, 2013
Showing with 3 additions and 0 deletions.
  1. +3 −0 repository/lib.php
View
3 repository/lib.php
@@ -2436,6 +2436,8 @@ public static function overwrite_existing_draftfile($itemid, $filepath, $filenam
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)) {
@@ -2454,6 +2456,7 @@ public static function overwrite_existing_draftfile($itemid, $filepath, $filenam
$newfilesource->original = $source->original;
$newfile->set_source(serialize($newfilesource));
}
+ $newfile->set_sortorder($sortorder);
// remove temp file
$tempfile->delete();
return true;

0 comments on commit 4b8ed14

Please sign in to comment.