MDL-35787 Mnet: If student role is not defined then throw error

This commit is contained in:
Rajesh Taneja 2012-10-09 15:22:03 +08:00
parent 93288f22a9
commit 6f5bc0584e

View File

@ -379,6 +379,7 @@ class auth_plugin_mnet extends auth_plugin_base {
$keys = array_keys($courses);
$studentroles = get_archetype_roles('student');
if (!empty($studentroles)) {
$defaultrole = reset($studentroles);
//$defaultrole = get_default_course_role($ccache[$shortname]); //TODO: rewrite this completely, there is no default course role any more!!!
foreach ($keys AS $id) {
@ -397,6 +398,9 @@ class auth_plugin_mnet extends auth_plugin_base {
// coerce to array
$courses[$id] = (array)$courses[$id];
}
} else {
throw new moodle_exception('unknownrole', 'error', '', 'student');
}
} else {
// if the array is empty, send it anyway
// we may be clearing out stale entries