MDL-25936 fixed user upload when manual plugin not first
authorPetr Skoda <commits@skodak.org>
Wed, 12 Jan 2011 21:07:48 +0000 (22:07 +0100)
committerPetr Skoda <commits@skodak.org>
Wed, 12 Jan 2011 21:07:48 +0000 (22:07 +0100)
admin/uploaduser.php

index 6da2efb..605a53d 100755 (executable)
@@ -668,10 +668,16 @@ if ($formdata = $mform->is_cancelled()) {
             $courseid      = $ccache[$shortname]->id;
             $coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
             if (!isset($manualcache[$courseid])) {
             $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;
+                            }
+                        }
+                    }
                 }
             }
 
                 }
             }