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. 4
      main/inc/lib/api.lib.php
  2. 7
      main/inc/lib/usermanager.lib.php

@ -1417,8 +1417,7 @@ function _api_format_user($user, $add_password = false)
} }
$image_sys_path = api_get_path(SYS_CODE_PATH).$dir.$picture_filename; $image_sys_path = api_get_path(SYS_CODE_PATH).$dir.$picture_filename;
if ($picture_filename) { if ($picture_filename && file_exists($image_sys_path)) {
if (file_exists($image_sys_path)) {
$result['avatar'] = api_get_path(WEB_CODE_PATH).$dir.$picture_filename; $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_small'] = api_get_path(WEB_CODE_PATH).$dir.'small_'.$picture_filename;
$result['avatar_sys_path'] = api_get_path(SYS_CODE_PATH).$dir.$picture_filename; $result['avatar_sys_path'] = api_get_path(SYS_CODE_PATH).$dir.$picture_filename;
@ -1438,7 +1437,6 @@ function _api_format_user($user, $add_password = false)
$result[$key] = UserManager::getGravatar($userEmail, $avatarSize, $gravatarType); $result[$key] = UserManager::getGravatar($userEmail, $avatarSize, $gravatarType);
} }
} }
}
if (isset($user['user_is_online'])) { if (isset($user['user_is_online'])) {
$result['user_is_online'] = $user['user_is_online'] == true ? 1 : 0; $result['user_is_online'] = $user['user_is_online'] == true ? 1 : 0;

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

Loading…
Cancel
Save