Fix gravatar in main/auth/profile.php - refs #4507

1.10.x
Imanol Losada 11 years ago
parent 65feb9cb73
commit d1950538b9
  1. 13
      main/auth/profile.php
  2. 37
      main/inc/lib/group_portal_manager.lib.php
  3. 8
      main/inc/lib/social.lib.php

@ -692,6 +692,8 @@ if (!empty($msg_is_not_password)){
Display::addFlash(Display :: return_message($warning_msg, 'warning', false));
}
$gravatarEnabled = api_get_configuration_value('gravatar_enabled');
// User picture size is calculated from SYSTEM path
$image_syspath = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'system', false, true);
$image_syspath['dir'].$image_syspath['file'];
@ -701,7 +703,10 @@ $image_path = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'web',
$image_dir = $image_path['dir'];
$image = $image_path['file'];
$image_file = $image_dir.$image;
$img_attributes = 'src="'.$image_file.'?rand='.time().'" '
if (!$gravatarEnabled) {
$image_file .= '?rand='.time();
}
$img_attributes = 'src="'.$image_file.'" '
.'alt="'.api_get_person_name($user_data['firstname'], $user_data['lastname']).'" '
.'style="float:'.($text_dir == 'rtl' ? 'left' : 'right').'; margin-top:0px;padding:5px;" ';
@ -711,8 +716,10 @@ $big_image = $image_dir.'big_'.$image;
$big_image_size = api_getimagesize($big_image);
$big_image_width = $big_image_size['width'];
$big_image_height = $big_image_size['height'];
$url_big_image = $big_image.'?rnd='.time();
$url_big_image = $image_file;
if (!$gravatarEnabled) {
$url_big_image = $big_image.'?rnd='.time();
}
$show_delete_account_button = api_get_setting('platform_unsubscribe_allowed') == 'true' ? true : false;
$tpl = new Template(get_lang('ModifyProfile'));

@ -911,9 +911,11 @@ class GroupPortalManager
default: // Base: empty, the result path below will be relative.
$base = '';
}
$gravatarEnabled = api_get_configuration_value('gravatar_enabled');
$noPicturePath = array('dir' => $base.'img/', 'file' => 'unknown.jpg');
if (empty($id) || empty($type)) {
return $anonymous ? array('dir' => $base.'img/', 'file' => 'unknown.jpg') : array('dir' => '', 'file' => '');
if ((empty($id) || empty($type)) && !$gravatarEnabled) {
return $anonymous ? $noPicturePath : array('dir' => '', 'file' => '');
}
$id = intval($id);
@ -922,8 +924,8 @@ class GroupPortalManager
$sql = "SELECT picture_uri FROM $group_table WHERE id=".$id;
$res = Database::query($sql);
if (!Database::num_rows($res)) {
return $anonymous ? array('dir' => $base.'img/', 'file' => 'unknown.jpg') : array('dir' => '', 'file' => '');
if (!Database::num_rows($res) && !$gravatarEnabled) {
return $anonymous ? $noPicturePath : array('dir' => '', 'file' => '');
}
$user = Database::fetch_array($res);
@ -940,9 +942,26 @@ class GroupPortalManager
} else {
$dir = $base.'upload/users/groups/'.$id.'/';
}
if ($gravatarEnabled) {
$avatarSize = api_getimagesize($noPicturePath['dir'].$noPicturePath['file']);
$avatarSize = $avatarSize['width'] > $avatarSize['height'] ?
$avatarSize['width'] :
$avatarSize['height'];
return array(
'dir' => '',
'file' => self::getGravatar(
$user['email'],
$avatarSize,
api_get_configuration_value('gravatar_type')
)
);
}
if (empty($picture_filename) && $anonymous) {
return array('dir' => $base.'img/', 'file' => 'unknown.jpg');
return $noPicturePath;
}
return array('dir' => $dir, 'file' => $picture_filename);
}
@ -981,12 +1000,15 @@ class GroupPortalManager
*/
public static function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM, $style = '')
{
$gravatarEnabled = api_get_configuration_value('gravatar_enabled');
$patch_profile = 'upload/users/groups/';
$picture = array();
$picture['style'] = $style;
if ($picture_file == 'unknown.jpg') {
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/'.$picture_file;
return $picture;
if (!$gravatarEnabled) {
return $picture;
}
}
switch ($size_picture) {
@ -1026,6 +1048,9 @@ class GroupPortalManager
$picture['file'] = api_get_path(WEB_CODE_PATH).'img/unknown_group.png';
}
}
if ($gravatarEnabled) {
$picture['file'] = $image_array['file'];
}
return $picture;
}

@ -613,8 +613,12 @@ class SocialManager extends UserManager
$img_array = UserManager::get_user_picture_path_by_id($user_id, 'web', true, true);
$big_image = UserManager::get_picture_user($user_id, $img_array['file'], '', USER_IMAGE_SIZE_BIG);
$big_image = $big_image['file'].'?'.uniqid();
$normal_image = $img_array['dir'].$img_array['file'].'?'.uniqid();
$big_image = $big_image['file'];
$normal_image = $img_array['dir'].$img_array['file'];
if (!api_get_configuration_value('gravatar_enabled')) {
$big_image .= '?'.uniqid();
$normal_image .= '?'.uniqid();
}
//--- User image
if ($img_array['file'] != 'unknown.jpg') {

Loading…
Cancel
Save