From 4cb02426ff0ecc4f917ea9812ba96022eaa2feb8 Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Wed, 12 Jan 2011 22:07:48 +0100 Subject: [PATCH] MDL-25936 fixed user upload when manual plugin not first --- admin/uploaduser.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/admin/uploaduser.php b/admin/uploaduser.php index 6da2efb4f7a..605a53dfd77 100755 --- a/admin/uploaduser.php +++ b/admin/uploaduser.php @@ -668,10 +668,16 @@ if ($formdata = $mform->is_cancelled()) { $courseid = $ccache[$shortname]->id; $coursecontext = get_context_instance(CONTEXT_COURSE, $courseid); if (!isset($manualcache[$courseid])) { - if ($instances = enrol_get_instances($courseid, false)) { - $manualcache[$courseid] = reset($instances); - } else { - $manualcache[$courseid] = false; + $manualcache[$courseid] = false; + if ($manual) { + if ($instances = enrol_get_instances($courseid, false)) { + foreach ($instances as $instance) { + if ($instance->enrol === 'manual') { + $manualcache[$courseid] = $instance; + break; + } + } + } } }