Skip to content

Commit

Permalink
Fix #13992: Use Gravatar generated patterns based on email hash for u…
Browse files Browse the repository at this point in the history
…sers who don't have avatar

- Change gravatar integration to generate patterns based on email hash when user doesn't have an avatar.
- Moved the checking for show_avatar inside the print_avatar() API.
- Remove default_avatar config option and delete the image.
  • Loading branch information
vboctor committed Mar 3, 2012
1 parent 38e23e3 commit 7d072d5
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion bugnote_view_inc.php
Expand Up @@ -111,7 +111,7 @@
?>
<tr class="bugnote" id="c<?php echo $t_bugnote->id ?>">
<td class="<?php echo $t_bugnote_css ?>">
<?php if ( ON == config_get("show_avatar") ) print_avatar( $t_bugnote->reporter_id ); ?>
<?php print_avatar( $t_bugnote->reporter_id ); ?>
<span class="small">(<a href="<?php echo string_get_bugnote_view_url($t_bugnote->bug_id, $t_bugnote->id) ?>" title="<?php echo lang_get( 'bugnote_link_title' ) ?>"><?php echo $t_bugnote_id_formatted ?>)</a></span><br />
<?php
echo print_user( $t_bugnote->reporter_id );
Expand Down
6 changes: 0 additions & 6 deletions config_defaults_inc.php
Expand Up @@ -948,12 +948,6 @@
*/
$g_show_avatar_threshold = DEVELOPER;

/**
* Default avatar for users without a gravatar account
* @global string $g_default_avatar
*/
$g_default_avatar = "%path%images/no_avatar.png";

/**
* Show release dates on changelog
* @global int $g_show_changelog_dates
Expand Down
1 change: 0 additions & 1 deletion core/config_api.php
Expand Up @@ -627,7 +627,6 @@ function config_is_private( $p_config_var ) {
case 'global_settings':
case 'system_font_folder':
case 'phpMailer_method':
case 'default_avatar':
case 'file_upload_ftp_server':
case 'file_upload_ftp_user':
case 'file_upload_ftp_pass':
Expand Down
1 change: 1 addition & 0 deletions core/obsolete.php
Expand Up @@ -141,3 +141,4 @@

# changes in 1.2.8
config_obsolete( 'show_attachment_indicator' );
config_obsolete( 'default_avatar', '' );
4 changes: 4 additions & 0 deletions core/print_api.php
Expand Up @@ -144,6 +144,10 @@ function print_successful_redirect( $p_redirect_to ) {

# Print avatar image for the given user ID
function print_avatar( $p_user_id, $p_size = 80 ) {
if ( OFF == config_get( 'show_avatar' ) ) {
return;
}

if( !user_exists( $p_user_id ) ) {
return;
}
Expand Down
6 changes: 3 additions & 3 deletions core/user_api.php
Expand Up @@ -797,11 +797,10 @@ function user_get_name( $p_user_id ) {
* @return array|bool an array( URL, width, height ) or false when the given user has no avatar
*/
function user_get_avatar( $p_user_id, $p_size = 80 ) {
$t_email = utf8_strtolower( user_get_email( $p_user_id ) );
$t_email = utf8_strtolower( trim( user_get_email( $p_user_id ) ) );
if( is_blank( $t_email ) ) {
$t_result = false;
} else {
$t_default_image = config_get( 'default_avatar' );
$t_size = $p_size;

$t_use_ssl = false;
Expand All @@ -815,7 +814,8 @@ function user_get_avatar( $p_user_id, $p_size = 80 ) {
$t_gravatar_domain = 'https://secure.gravatar.com/';
}

$t_avatar_url = $t_gravatar_domain . 'avatar/' . md5( $t_email ) . '?default=' . urlencode( $t_default_image ) . '&size=' . $t_size . '&rating=G';
$t_avatar_url = $t_gravatar_domain . 'avatar/' . md5( $t_email ) . '?d=identicon&r=G&s=' . $t_size;

$t_result = array(
$t_avatar_url,
$t_size,
Expand Down
6 changes: 0 additions & 6 deletions docbook/adminguide/en/configuration.sgml
Expand Up @@ -834,12 +834,6 @@
<para>The threshold of users for which MantisBT should attempt to show the avatar (default DEVELOPER). Note that the threshold is related to the user for whom the avatar is being shown, rather than the user who is currently logged in.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>$g_default_avatar</term>
<listitem>
<para>The full URL to the image to be used when a user doesn't have an avatar account.</para>
</listitem>
</varlistentry>
</variablelist>
</section>

Expand Down
Binary file removed images/no_avatar.png
Binary file not shown.

0 comments on commit 7d072d5

Please sign in to comment.