Fix gravatar in get_user_picture_path_by_id and _api_format_user functions - refs #4507

1.10.x
Imanol Losada 11 years ago
parent 3516acc1a5
commit 6ebcbdf4bc
  1. 38
      main/inc/lib/api.lib.php
  2. 7
      main/inc/lib/usermanager.lib.php

@ -1417,26 +1417,24 @@ function _api_format_user($user, $add_password = false)
}
$image_sys_path = api_get_path(SYS_CODE_PATH).$dir.$picture_filename;
if ($picture_filename) {
if (file_exists($image_sys_path)) {
$result['avatar'] = api_get_path(WEB_CODE_PATH).$dir.$picture_filename;
$result['avatar_small'] = api_get_path(WEB_CODE_PATH).$dir.'small_'.$picture_filename;
$result['avatar_sys_path'] = api_get_path(SYS_CODE_PATH).$dir.$picture_filename;
} else if (api_get_configuration_value('gravatar_enabled')) {
$userEmail = isset($user['email']) ? $user['email'] : '';
$gravatarType = api_get_configuration_value('gravatar_type');
$avatarPaths = array(
'avatar' => $result['avatar'],
'avatar_small' => $result['avatar_small'],
'avatar_sys_path' => $result['avatar_sys_path']
);
foreach ($avatarPaths as $key => $value) {
$avatarSize = api_getimagesize($value);
$avatarSize = $avatarSize['width'] > $avatarSize['height'] ?
$avatarSize['width'] :
$avatarSize['height'];
$result[$key] = UserManager::getGravatar($userEmail, $avatarSize, $gravatarType);
}
if ($picture_filename && file_exists($image_sys_path)) {
$result['avatar'] = api_get_path(WEB_CODE_PATH).$dir.$picture_filename;
$result['avatar_small'] = api_get_path(WEB_CODE_PATH).$dir.'small_'.$picture_filename;
$result['avatar_sys_path'] = api_get_path(SYS_CODE_PATH).$dir.$picture_filename;
} else if (api_get_configuration_value('gravatar_enabled')) {
$userEmail = isset($user['email']) ? $user['email'] : '';
$gravatarType = api_get_configuration_value('gravatar_type');
$avatarPaths = array(
'avatar' => $result['avatar'],
'avatar_small' => $result['avatar_small'],
'avatar_sys_path' => $result['avatar_sys_path']
);
foreach ($avatarPaths as $key => $value) {
$avatarSize = api_getimagesize($value);
$avatarSize = $avatarSize['width'] > $avatarSize['height'] ?
$avatarSize['width'] :
$avatarSize['height'];
$result[$key] = UserManager::getGravatar($userEmail, $avatarSize, $gravatarType);
}
}

@ -1268,10 +1268,6 @@ class UserManager
if (empty($picture_filename) ||
(!empty($picture_filename) && !file_exists($systemImagePath.$picture_filename))
) {
if ($anonymous) {
return $noPicturePath;
}
if (api_get_configuration_value('gravatar_enabled')) {
$avatarSize = api_getimagesize($noPicturePath['dir'].$noPicturePath['file']);
$avatarSize = $avatarSize['width'] > $avatarSize['height'] ?
@ -1286,6 +1282,9 @@ class UserManager
)
);
}
if ($anonymous) {
return $noPicturePath;
}
}
return array('dir' => $dir, 'file' => $picture_filename);

Loading…
Cancel
Save