MDL-31541 Repositories - make sure all repository instances have unique 'sortorder' values when retrieved

This commit is contained in:
Davo Smith
2012-02-08 09:35:39 +00:00
parent baa5cd8240
commit fdb0322d72
+4 -1
View File
@@ -818,6 +818,9 @@ abstract class repository {
} else {
$accepted_types = '*';
}
// Sortorder should be unique, which is not true if we use $record->sortorder
// and there are multiple instances of any repository type
$sortorder = 1;
foreach ($records as $record) {
if (!file_exists($CFG->dirroot . '/repository/'. $record->repositorytype.'/lib.php')) {
continue;
@@ -826,7 +829,7 @@ abstract class repository {
$options['visible'] = $record->visible;
$options['type'] = $record->repositorytype;
$options['typeid'] = $record->typeid;
$options['sortorder'] = $record->sortorder;
$options['sortorder'] = $sortorder++;
// tell instance what file types will be accepted by file picker
$classname = 'repository_' . $record->repositorytype;