From f4ddc4ecd308f9c353c9ca1373cefa455f8961de Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Thu, 17 Aug 2017 11:58:58 +0800 Subject: [PATCH] MDL-59823 users: Enrol bulk op course instance The commit message above was my best attempt at meeting the very short restrictions on commit message first lines. What it needed to say was: "Only show bulk enrolment operations for enrolment methods that have an instance in the course" --- enrol/locallib.php | 2 +- user/index.php | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/enrol/locallib.php b/enrol/locallib.php index f8b7ca44a0b..4fc3dcebdad 100644 --- a/enrol/locallib.php +++ b/enrol/locallib.php @@ -554,7 +554,7 @@ class course_enrolment_manager { } /** - * Gets all of the enrolment plugins that are active for this course. + * Gets all of the enrolment plugins that are available for this course. * * @param bool $onlyenabled return only enabled enrol plugins * @return array diff --git a/user/index.php b/user/index.php index e73c3f29e61..d1fc5bd282f 100644 --- a/user/index.php +++ b/user/index.php @@ -254,8 +254,14 @@ if ($bulkoperations) { } if ($context->id != $frontpagectx->id) { - $plugins = $manager->get_enrolment_plugins(); - foreach ($plugins as $plugin) { + $instances = $manager->get_enrolment_instances(); + $plugins = $manager->get_enrolment_plugins(false); + foreach ($instances as $key => $instance) { + if (!isset($plugins[$instance->enrol])) { + // Weird, some broken stuff in plugin. + continue; + } + $plugin = $plugins[$instance->enrol]; $bulkoperations = $plugin->get_bulk_operations($manager); $pluginoptions = [];