1
0
mirror of https://github.com/moodle/moodle.git synced 2025-04-24 09:55:33 +02:00

MDL-48525 webservices: Fixed profile user image is not always returned

This commit is contained in:
Juan Leyva 2015-01-28 17:20:02 +01:00
parent 4c27f52d91
commit a86f23cd53

@ -444,12 +444,11 @@ class core_message_external extends external_api {
'unread' => $contact->messagecount
);
// Try to get the user picture, but sometimes this method can return null.
$userdetails = user_get_user_details($contact, null, array('profileimageurl', 'profileimageurlsmall'));
if (!empty($userdetails)) {
$newcontact['profileimageurl'] = $userdetails['profileimageurl'];
$newcontact['profileimageurlsmall'] = $userdetails['profileimageurlsmall'];
}
$usercontextid = context_user::instance($contact->id)->id;
$newcontact['profileimageurl'] = moodle_url::make_webservice_pluginfile_url(
$usercontextid, 'user', 'icon', null, '/', 'f1')->out(false);
$newcontact['profileimageurlsmall'] = moodle_url::make_webservice_pluginfile_url(
$usercontextid, 'user', 'icon', null, '/', 'f2')->out(false);
$allcontacts[$mode][$key] = $newcontact;
}
@ -576,12 +575,11 @@ class core_message_external extends external_api {
$user->phone1 = null;
$user->phone2 = null;
// Try to get the user picture, but sometimes this method can return null.
$userdetails = user_get_user_details($user, null, array('profileimageurl', 'profileimageurlsmall'));
if (!empty($userdetails)) {
$newuser['profileimageurl'] = $userdetails['profileimageurl'];
$newuser['profileimageurlsmall'] = $userdetails['profileimageurlsmall'];
}
$usercontextid = context_user::instance($user->id)->id;
$newuser['profileimageurl'] = moodle_url::make_webservice_pluginfile_url(
$usercontextid, 'user', 'icon', null, '/', 'f1')->out(false);
$newuser['profileimageurlsmall'] = moodle_url::make_webservice_pluginfile_url(
$usercontextid, 'user', 'icon', null, '/', 'f2')->out(false);
$user = $newuser;
}