Skip to content
Browse files

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

  • Loading branch information...
1 parent 93288f2 commit 6f5bc0584edc1d5b2c4e571c7228a75efdcae06a @rajeshtaneja rajeshtaneja committed Oct 9, 2012
Showing with 20 additions and 16 deletions.
  1. +20 −16 auth/mnet/auth.php
View
36 auth/mnet/auth.php
@@ -379,23 +379,27 @@ function confirm_mnet_session($token, $remotepeer) {
$keys = array_keys($courses);
$studentroles = get_archetype_roles('student');
- $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) {
- if ($courses[$id]->visible == 0) {
- unset($courses[$id]);
- continue;
+ 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) {
+ if ($courses[$id]->visible == 0) {
+ unset($courses[$id]);
+ continue;
+ }
+ $courses[$id]->cat_id = $courses[$id]->category;
+ $courses[$id]->defaultroleid = $defaultrole->id;
+ unset($courses[$id]->category);
+ unset($courses[$id]->visible);
+
+ $courses[$id]->cat_name = $extra[$id]->cat_name;
+ $courses[$id]->cat_description = $extra[$id]->cat_description;
+ $courses[$id]->defaultrolename = $defaultrole->name;
+ // coerce to array
+ $courses[$id] = (array)$courses[$id];
}
- $courses[$id]->cat_id = $courses[$id]->category;
- $courses[$id]->defaultroleid = $defaultrole->id;
- unset($courses[$id]->category);
- unset($courses[$id]->visible);
-
- $courses[$id]->cat_name = $extra[$id]->cat_name;
- $courses[$id]->cat_description = $extra[$id]->cat_description;
- $courses[$id]->defaultrolename = $defaultrole->name;
- // 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

0 comments on commit 6f5bc05

Please sign in to comment.
Something went wrong with that request. Please try again.