Permalink
Browse files

Merge branch 'wip-mdl-35787-m23' of git://github.com/rajeshtaneja/moo…

…dle into MOODLE_23_STABLE
  • Loading branch information...
2 parents a82535f + 18f9ad3 commit df79fff95b3c93a47eb19bb2b4938fe6274ab8f4 @danpoltawski danpoltawski committed Nov 5, 2012
Showing with 22 additions and 17 deletions.
  1. +21 −16 auth/mnet/auth.php
  2. +1 −1 mnet/service/enrol/course.php
View
@@ -378,23 +378,28 @@ function confirm_mnet_session($token, $remotepeer) {
$extra = $DB->get_records_sql($sql);
$keys = array_keys($courses);
- $defaultrole = reset(get_archetype_roles('student'));
- //$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;
+ $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) {
+ 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
@@ -62,7 +62,7 @@
// collapsible course summary
if (!empty($course->summary)) {
- unset($options);
+ $options = new stdClass();
$options->trusted = false;
$options->para = false;
$options->filter = false;

0 comments on commit df79fff

Please sign in to comment.