@@ -12,9 +12,9 @@ URL to be log in to Moodle without typing username and password.
1212
1313# Versions and branches
1414
15- | Moodle Version | Branch |
15+ | Moodle Version | Branch |
1616| ------------------| -------------------|
17- | Moodle 4.5+ | MOODLE_405_STABLE |
17+ | Moodle 4.5+ | MOODLE_405_STABLE |
1818| Moodle 3.3 - 4.1 | MOODLE_33PLUS |
1919
2020Using
@@ -64,6 +64,14 @@ For example XML-RPC (PHP structure) description for different mapping field sett
6464 [idnumber] => string
6565 )
6666
67+ *** Database Id***
68+
69+ [user] =>
70+ Array
71+ (
72+ [id] => int
73+ )
74+
6775*** Web service will return following structure or standard Moodle webservice error message.***
6876
6977 Array
@@ -104,21 +112,21 @@ E.g. http://yourmoodle.com/login/index.php?enrolkey_skipsso=1
104112
105113** Logout URL**
106114
107- If you need to logout users after they logged out from the external application, you can redirect them
108- to logout script with required parameter "return".
115+ If you need to logout users after they logged out from the external application, you can redirect them
116+ to logout script with required parameter "return".
109117
110- E.g. http://yourmoodle.com/auth/userkey/logout.php?return=www.google.com
118+ E.g. http://yourmoodle.com/auth/userkey/logout.php?return=www.google.com
111119
112120
113- Users will be logged out from Moodle and then redirected to the provided URL.
114- In case when a user session is already expired, the user will be still redirected.
115-
121+ Users will be logged out from Moodle and then redirected to the provided URL.
122+ In case when a user session is already expired, the user will be still redirected.
123+
116124
117125** Example client**
118126
119127** Note:** the code below is not for production use. It's just a quick and dirty way to test the functionality.
120128
121- The code below defines a function that can be used to obtain a login url.
129+ The code below defines a function that can be used to obtain a login url.
122130You will need to add/remove parameters depending on whether you have update/create user enabled and which mapping field you are using.
123131
124132The required library curl can be obtained from https://github.com/moodlehq/sample-ws-clients
@@ -136,7 +144,7 @@ The required library curl can be obtained from https://github.com/moodlehq/sampl
136144 */
137145function getloginurl($useremail, $firstname, $lastname, $username, $courseid = null, $modname = null, $activityid = null) {
138146 require_once('curl.php');
139-
147+
140148 $token = 'YOUR_TOKEN';
141149 $domainname = 'http://MOODLE_WWW_ROOT';
142150 $functionname = 'auth_userkey_request_login_url';
@@ -145,19 +153,19 @@ function getloginurl($useremail, $firstname, $lastname, $username, $courseid = n
145153 'user' => [
146154 'firstname' => $firstname, // You will not need this parameter, if you are not creating/updating users
147155 'lastname' => $lastname, // You will not need this parameter, if you are not creating/updating users
148- 'username' => $username,
156+ 'username' => $username,
149157 'email' => $useremail,
150158 ]
151159 ];
152160
153161 $serverurl = $domainname . '/webservice/rest/server.php' . '?wstoken=' . $token . '&wsfunction=' . $functionname . '&moodlewsrestformat=json';
154- $curl = new curl; // The required library curl can be obtained from https://github.com/moodlehq/sample-ws-clients
162+ $curl = new curl; // The required library curl can be obtained from https://github.com/moodlehq/sample-ws-clients
155163
156164 try {
157165 $resp = $curl->post($serverurl, $param);
158166 $resp = json_decode($resp);
159167 if ($resp && !empty($resp->loginurl)) {
160- $loginurl = $resp->loginurl;
168+ $loginurl = $resp->loginurl;
161169 }
162170 } catch (Exception $ex) {
163171 return false;
@@ -192,7 +200,7 @@ https://www.catalyst-au.net/
192200
193201# Contributing and Support
194202
195- Issues, and pull requests using github are welcome and encouraged!
203+ Issues, and pull requests using github are welcome and encouraged!
196204
197205https://github.com/catalyst/moodle-auth_userkey/issues
198206
0 commit comments