Skip to content

Commit

Permalink
Merge branch 'MDL-57429-master-fix' of https://github.com/snake/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Mar 23, 2017
2 parents 85ead19 + 29631e6 commit 3d85d16
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions badges/backpack_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public function validation($data, $files) {
$request = $bp->curl_request('user');
if (isset($request->status) && $request->status == 'missing') {
$errors['email'] = get_string('error:nosuchuser', 'badges');
} else if (!isset($request->status) || $request->status !== 'okay') {
$errors['email'] = get_string('backpackconnectionunexpectedresult', 'badges');
}
}
return $errors;
Expand Down
11 changes: 10 additions & 1 deletion badges/backpackemailverify.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,20 @@
$data->email = $storedemail;
$bp = new OpenBadgesBackpackHandler($data);

// Make sure we have all the required information before trying to save the connection.
$backpackuser = $bp->curl_request('user');
if (isset($backpackuser->status) && $backpackuser->status === 'okay' && isset($backpackuser->userId)) {
$backpackuid = $backpackuser->userId;
} else {
redirect(new moodle_url($redirect), get_string('backpackconnectionunexpectedresult', 'badges'),
null, \core\output\notification::NOTIFY_ERROR);
}

$obj = new stdClass();
$obj->userid = $USER->id;
$obj->email = $data->email;
$obj->backpackurl = $data->backpackurl;
$obj->backpackuid = $bp->curl_request('user')->userId;
$obj->backpackuid = $backpackuid;
$obj->autosync = 0;
$obj->password = '';
$DB->insert_record('badge_backpack', $obj);
Expand Down
1 change: 1 addition & 0 deletions lang/en/badges.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
$string['backpackconnectioncancelattempt'] = 'Connect using a different email address';
$string['backpackconnectionconnect'] = 'Connect to Backpack';
$string['backpackconnectionresendemail'] = 'Resend verification email';
$string['backpackconnectionunexpectedresult'] = 'There was a problem contacting the Backpack. Please try again.<br><br>If this problem persists, please contact your system administrator.';
$string['backpackdetails'] = 'Backpack settings';
$string['backpackemail'] = 'Email address';
$string['backpackemail_help'] = 'The email address associated with your backpack. While you are connected, any badges earned on this site will be associated with this email address.';
Expand Down

0 comments on commit 3d85d16

Please sign in to comment.