mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 02:46:40 +02:00
MDL-77946 access: fix category sort order of capability contexts.
This commit is contained in:
parent
5d320dd7d1
commit
ebcc7e58ce
2 changed files with 17 additions and 14 deletions
|
@ -4266,21 +4266,21 @@ function get_user_capability_contexts(string $capability, bool $getcategories, $
|
|||
$fieldlist = \core\access\get_user_capability_course_helper::map_fieldnames($categoryfieldsexceptid);
|
||||
if ($categoryorderby) {
|
||||
$fields = explode(',', $categoryorderby);
|
||||
$orderby = '';
|
||||
$categoryorderby = '';
|
||||
foreach ($fields as $field) {
|
||||
if ($orderby) {
|
||||
$orderby .= ',';
|
||||
if ($categoryorderby) {
|
||||
$categoryorderby .= ',';
|
||||
}
|
||||
$orderby .= 'c.'.$field;
|
||||
$categoryorderby .= 'c.'.$field;
|
||||
}
|
||||
$orderby = 'ORDER BY '.$orderby;
|
||||
$categoryorderby = 'ORDER BY '.$categoryorderby;
|
||||
}
|
||||
$rs = $DB->get_recordset_sql("
|
||||
SELECT c.id $fieldlist
|
||||
FROM {course_categories} c
|
||||
JOIN {context} x ON c.id = x.instanceid AND x.contextlevel = ?
|
||||
$contextlimitsql
|
||||
$orderby", array_merge([CONTEXT_COURSECAT], $contextlimitparams));
|
||||
$categoryorderby", array_merge([CONTEXT_COURSECAT], $contextlimitparams));
|
||||
$basedlimit = $limit;
|
||||
foreach ($rs as $category) {
|
||||
$categories[] = $category;
|
||||
|
@ -4289,6 +4289,7 @@ function get_user_capability_contexts(string $capability, bool $getcategories, $
|
|||
break;
|
||||
}
|
||||
}
|
||||
$rs->close();
|
||||
}
|
||||
|
||||
$courses = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue