mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 19:50:14 +01:00
MDL-22779 fixing add instance to show only cohorts from parent contexts
This commit is contained in:
parent
b31f126a2a
commit
d675887bc0
@ -37,9 +37,13 @@ class enrol_cohort_addinstance_form extends moodleform {
|
||||
|
||||
$enrol = enrol_get_plugin('cohort');
|
||||
|
||||
//TODO: add only cohorts from parent contexts of this course
|
||||
$cohorts = array('' => get_string('choosedots'));
|
||||
$rs = $DB->get_recordset('cohort', array(), 'name ASC', 'id, name, contextid');
|
||||
list($sqlparents, $params) = $DB->get_in_or_equal(get_parent_contexts($coursecontext));
|
||||
$sql = "SELECT id, name, contextid
|
||||
FROM {cohort}
|
||||
WHERE contextid $sqlparents
|
||||
ORDER BY name ASC";
|
||||
$rs = $DB->get_recordset_sql($sql, $params);
|
||||
foreach ($rs as $c) {
|
||||
$context = get_context_instance_by_id($c->contextid);
|
||||
if (!has_capability('moodle/cohort:view', $context)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user