mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-35787 Mnet: If student role is not defined then throw error
This commit is contained in:
parent
93288f22a9
commit
6f5bc0584e
@ -379,23 +379,27 @@ class auth_plugin_mnet extends auth_plugin_base {
|
|||||||
|
|
||||||
$keys = array_keys($courses);
|
$keys = array_keys($courses);
|
||||||
$studentroles = get_archetype_roles('student');
|
$studentroles = get_archetype_roles('student');
|
||||||
$defaultrole = reset($studentroles);
|
if (!empty($studentroles)) {
|
||||||
//$defaultrole = get_default_course_role($ccache[$shortname]); //TODO: rewrite this completely, there is no default course role any more!!!
|
$defaultrole = reset($studentroles);
|
||||||
foreach ($keys AS $id) {
|
//$defaultrole = get_default_course_role($ccache[$shortname]); //TODO: rewrite this completely, there is no default course role any more!!!
|
||||||
if ($courses[$id]->visible == 0) {
|
foreach ($keys AS $id) {
|
||||||
unset($courses[$id]);
|
if ($courses[$id]->visible == 0) {
|
||||||
continue;
|
unset($courses[$id]);
|
||||||
}
|
continue;
|
||||||
$courses[$id]->cat_id = $courses[$id]->category;
|
}
|
||||||
$courses[$id]->defaultroleid = $defaultrole->id;
|
$courses[$id]->cat_id = $courses[$id]->category;
|
||||||
unset($courses[$id]->category);
|
$courses[$id]->defaultroleid = $defaultrole->id;
|
||||||
unset($courses[$id]->visible);
|
unset($courses[$id]->category);
|
||||||
|
unset($courses[$id]->visible);
|
||||||
|
|
||||||
$courses[$id]->cat_name = $extra[$id]->cat_name;
|
$courses[$id]->cat_name = $extra[$id]->cat_name;
|
||||||
$courses[$id]->cat_description = $extra[$id]->cat_description;
|
$courses[$id]->cat_description = $extra[$id]->cat_description;
|
||||||
$courses[$id]->defaultrolename = $defaultrole->name;
|
$courses[$id]->defaultrolename = $defaultrole->name;
|
||||||
// coerce to array
|
// coerce to array
|
||||||
$courses[$id] = (array)$courses[$id];
|
$courses[$id] = (array)$courses[$id];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw new moodle_exception('unknownrole', 'error', '', 'student');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if the array is empty, send it anyway
|
// if the array is empty, send it anyway
|
||||||
|
Loading…
x
Reference in New Issue
Block a user