diff --git a/auth/saml/config.php b/auth/saml/config.php index 0b2f511..07a20b8 100755 --- a/auth/saml/config.php +++ b/auth/saml/config.php @@ -285,8 +285,8 @@ : diff --git a/auth/saml/course_mapping.php b/auth/saml/course_mapping.php index 9c6f556..84d1611 100644 --- a/auth/saml/course_mapping.php +++ b/auth/saml/course_mapping.php @@ -19,28 +19,20 @@ foreach($saml_courses as $key => $course) { if(preg_match('/urn:mace:terena.org:schac:userStatus:(.+):(.+):(.+):(.+):(.+):(.+)/', $course, $regs)) { list($match, $country, $domain, $course_id, $period, $role, $status) = $regs; - if(isset($role_mapping[$role]) && isset($course_mapping[$course_id][$period])) { - $mapped_role = $role_mapping[$role]; - $mapped_course_id = $course_mapping[$course_id][$period]; - $mapped_courses[$mapped_role][$status][$mapped_course_id] = array( 'country' => $country, - 'domain' => $domain, - 'course_id' => $mapped_course_id, - 'period' => $period, - 'role' => $mapped_role, - 'status' => $status, - ); - if(!$any_course_active && $status == 'active') { - $any_course_active = true; - } - } - else { - $str_obj = new stdClass(); - $str_obj->course = '('.$course_id.' -- '.$period.')'; - $str_obj->user = $saml_user_identify; - $err['course_enrollment'][] = get_string('auth_saml_course_not_found' , 'auth_saml', $str_obj); + $mapped_role = !empty($role_mapping[$role]) ? $role_mapping[$role] : $role; + $mapped_course_id = ($config->moodlecoursefieldid == 'idnumber') ? $course_id : $course_mapping[$course_id][$period]; + $mapped_courses[$mapped_role][$status][$mapped_course_id] = array( + 'country' => $country, + 'domain' => $domain, + 'course_id' => $mapped_course_id, + 'period' => $period, + 'role' => $mapped_role, + 'status' => $status, + ); + if(!$any_course_active && $status == 'active') { + $any_course_active = true; } } } unset($saml_courses); - unset($saml_user_identify); diff --git a/enrol/saml/README.txt b/enrol/saml/README.txt index f4df347..04bdace 100644 --- a/enrol/saml/README.txt +++ b/enrol/saml/README.txt @@ -23,6 +23,8 @@ Important for enrollment!! ========================== This plugin suppose that the IdP send the courses data of the user in a attribute that -can be configured but the pattern of the expected data is always: -::: +can be configured but the pattern of the expected data is always defined per the RFC: +https://tools.ietf.org/html/rfc6338 +e.g., +urn:mace:terena.org:schac:userStatus:(.+):(.+):(.+):(.+):(.+):(.+) You can change this pattern editing the file auth/saml/course_mapping.php