Skip to content

Commit

Permalink
MDL-31541 Repositories - make sure all repository instances have uniq…
Browse files Browse the repository at this point in the history
…ue 'sortorder' values when retrieved
  • Loading branch information
davosmith authored and Aparup Banerjee committed Feb 14, 2012
1 parent ebeacb7 commit 0c8c296
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion repository/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,9 @@ public static function get_instances($args = array()) {
} 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;
Expand All @@ -826,7 +829,7 @@ public static function get_instances($args = array()) {
$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;

Expand Down

0 comments on commit 0c8c296

Please sign in to comment.