Merge branch 'MDL-68049' of https://github.com/spvickers/moodle
authorEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 30 Mar 2020 11:26:21 +0000 (13:26 +0200)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Mon, 30 Mar 2020 11:26:21 +0000 (13:26 +0200)
mod/lti/service/memberships/classes/local/resources/linkmemberships.php
mod/lti/service/memberships/classes/local/service/memberships.php

index 619efb7..7caf5d0 100644 (file)
@@ -79,10 +79,6 @@ class linkmemberships extends resource_base {
             $limitfrom = 0;
         }
 
-        if (!$this->check_tool(null, $response->get_request_data(), memberships::SCOPE_MEMBERSHIPS_READ)) {
-            $response->set_code(403);
-            return;
-        }
         if (empty($linkid)) {
             $response->set_code(404);
             return;
@@ -91,6 +87,10 @@ class linkmemberships extends resource_base {
             $response->set_code(404);
             return;
         }
+        if (!$this->check_tool($lti->typeid, $response->get_request_data(), array(memberships::SCOPE_MEMBERSHIPS_READ))) {
+            $response->set_code(403);
+            return;
+        }
         if (!($course = $DB->get_record('course', array('id' => $lti->course), 'id', IGNORE_MISSING))) {
             $response->set_code(404);
             return;
@@ -106,7 +106,7 @@ class linkmemberships extends resource_base {
         if ($info->is_available_for_all()) {
             $info = null;
         }
-        $json = $this->get_service()->get_members_json($this, $context, $lti->course, $role,
+        $json = $this->get_service()->get_members_json($this, $context, $course, $role,
                                                        $limitfrom, $limitnum, $lti, $info, $response);
 
         $response->set_content_type($this->formats[0]);
index 6b9a9f5..1205205 100644 (file)
@@ -267,14 +267,17 @@ class memberships extends \mod_lti\local\ltiservice\service_base {
                                             'member.field' => 'name',
                                             'source.value' => format_string("{$user->firstname} {$user->lastname}")],
                 'Person.name.given'    => ['type' => 'name',
-                                            'member.field' => 'giveName',
+                                            'member.field' => 'givenName',
                                             'source.value' => format_string($user->firstname)],
                 'Person.name.family'   => ['type' => 'name',
                                             'member.field' => 'familyName',
                                             'source.value' => format_string($user->lastname)],
                 'Person.email.primary' => ['type' => 'email',
                                             'member.field' => 'email',
-                                            'source.value' => format_string($user->email)]
+                                            'source.value' => format_string($user->email)],
+                'User.username'        => ['type' => 'name',
+                                           'member.field' => 'ext_user_username',
+                                           'source.value' => format_string($user->username)]
             ];
 
             if (!is_null($lti)) {