Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7d072d5

Browse files
committedMar 3, 2012
Fix #13992: Use Gravatar generated patterns based on email hash for users 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.
1 parent 38e23e3 commit 7d072d5

8 files changed

+9
-17
lines changed
 

‎bugnote_view_inc.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
?>
112112
<tr class="bugnote" id="c<?php echo $t_bugnote->id ?>">
113113
<td class="<?php echo $t_bugnote_css ?>">
114-
<?php if ( ON == config_get("show_avatar") ) print_avatar( $t_bugnote->reporter_id ); ?>
114+
<?php print_avatar( $t_bugnote->reporter_id ); ?>
115115
<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 />
116116
<?php
117117
echo print_user( $t_bugnote->reporter_id );

‎config_defaults_inc.php

-6
Original file line numberDiff line numberDiff line change
@@ -948,12 +948,6 @@
948948
*/
949949
$g_show_avatar_threshold = DEVELOPER;
950950

951-
/**
952-
* Default avatar for users without a gravatar account
953-
* @global string $g_default_avatar
954-
*/
955-
$g_default_avatar = "%path%images/no_avatar.png";
956-
957951
/**
958952
* Show release dates on changelog
959953
* @global int $g_show_changelog_dates

‎core/config_api.php

-1
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,6 @@ function config_is_private( $p_config_var ) {
627627
case 'global_settings':
628628
case 'system_font_folder':
629629
case 'phpMailer_method':
630-
case 'default_avatar':
631630
case 'file_upload_ftp_server':
632631
case 'file_upload_ftp_user':
633632
case 'file_upload_ftp_pass':

‎core/obsolete.php

+1
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,4 @@
141141

142142
# changes in 1.2.8
143143
config_obsolete( 'show_attachment_indicator' );
144+
config_obsolete( 'default_avatar', '' );

‎core/print_api.php

+4
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ function print_successful_redirect( $p_redirect_to ) {
144144

145145
# Print avatar image for the given user ID
146146
function print_avatar( $p_user_id, $p_size = 80 ) {
147+
if ( OFF == config_get( 'show_avatar' ) ) {
148+
return;
149+
}
150+
147151
if( !user_exists( $p_user_id ) ) {
148152
return;
149153
}

‎core/user_api.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -797,11 +797,10 @@ function user_get_name( $p_user_id ) {
797797
* @return array|bool an array( URL, width, height ) or false when the given user has no avatar
798798
*/
799799
function user_get_avatar( $p_user_id, $p_size = 80 ) {
800-
$t_email = utf8_strtolower( user_get_email( $p_user_id ) );
800+
$t_email = utf8_strtolower( trim( user_get_email( $p_user_id ) ) );
801801
if( is_blank( $t_email ) ) {
802802
$t_result = false;
803803
} else {
804-
$t_default_image = config_get( 'default_avatar' );
805804
$t_size = $p_size;
806805

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

818-
$t_avatar_url = $t_gravatar_domain . 'avatar/' . md5( $t_email ) . '?default=' . urlencode( $t_default_image ) . '&size=' . $t_size . '&rating=G';
817+
$t_avatar_url = $t_gravatar_domain . 'avatar/' . md5( $t_email ) . '?d=identicon&r=G&s=' . $t_size;
818+
819819
$t_result = array(
820820
$t_avatar_url,
821821
$t_size,

‎docbook/adminguide/en/configuration.sgml

-6
Original file line numberDiff line numberDiff line change
@@ -834,12 +834,6 @@
834834
<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>
835835
</listitem>
836836
</varlistentry>
837-
<varlistentry>
838-
<term>$g_default_avatar</term>
839-
<listitem>
840-
<para>The full URL to the image to be used when a user doesn't have an avatar account.</para>
841-
</listitem>
842-
</varlistentry>
843837
</variablelist>
844838
</section>
845839

‎images/no_avatar.png

-2.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.