Merge branch 'MDL-64049-master' of git://github.com/andrewnicols/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2018-11-20 00:26:09 +01:00
commit b2cb05a8c7
2 changed files with 10 additions and 13 deletions

View File

@ -2088,7 +2088,11 @@ function get_user_preferences($name = null, $default = null, $user = null) {
} else if (isset($user->id)) {
// Is a valid object.
} else if (is_numeric($user)) {
$user = (object)array('id' => (int)$user);
if ($USER->id == $user) {
$user = $USER;
} else {
$user = (object)array('id' => (int)$user);
}
} else {
throw new coding_exception('Invalid $user parameter in get_user_preferences() call');
}

View File

@ -64,18 +64,11 @@ class repository_flickr_privacy_testcase extends provider_testcase {
$this->assertFalse($writer->has_any_data());
// Test exporting of Flickr repository user preferences *with* OAuth token/secret preference configured.
$preference = (object) [
'userid' => $user->id,
'name' => 'repository_flickr_access_token',
'value' => 'dummy flickr oauth access token'
];
$DB->insert_record('user_preferences', $preference);
$preference = (object) [
'userid' => $user->id,
'name' => 'repository_flickr_access_token_secret',
'value' => 'dummy flickr oauth access token secret'
];
$DB->insert_record('user_preferences', $preference);
set_user_preferences([
'repository_flickr_access_token' => 'dummy flickr oauth access token',
'repository_flickr_access_token_secret' => 'dummy flickr oauth access token secret',
], $user->id);
provider::export_user_preferences($user->id);
$writer = writer::with_context($contextuser);