Skip to content

Commit 5f1dba9

Browse files
committedMar 26, 2012
Fix #13992: Use Gravatar generated patterns based on email hash for users wh
- Change gravatar integration to generate patterns based on email hash when - Moved the checking for show_avatar inside the print_avatar() API. - Remove default_avatar config option and delete the image.
1 parent 70cbb8b commit 5f1dba9

File tree

8 files changed

+9
-17
lines changed

8 files changed

+9
-17
lines changed
 

‎bugnote_view_inc.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
?>
158158
<tr class="bugnote <?php echo $t_bugnote_css ?>" id="c<?php echo $t_bugnote->id ?>">
159159
<td class="bugnote-meta">
160-
<?php if ( ON == config_get("show_avatar") ) print_avatar( $t_bugnote->reporter_id ); ?>
160+
<?php print_avatar( $t_bugnote->reporter_id ); ?>
161161
<span class="small bugnote-permalink"><a rel="bookmark" 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 htmlentities( config_get_global( 'bugnote_link_tag' ) ) . $t_bugnote_id_formatted ?></a></span><br />
162162

163163
<span class="bugnote-reporter">

‎config_defaults_inc.php

-6
Original file line numberDiff line numberDiff line change
@@ -1012,12 +1012,6 @@
10121012
*/
10131013
$g_show_avatar_threshold = DEVELOPER;
10141014

1015-
/**
1016-
* Default avatar for users without a gravatar account
1017-
* @global string $g_default_avatar
1018-
*/
1019-
$g_default_avatar = "%path%images/no_avatar.png";
1020-
10211015
/**
10221016
* Show release dates on changelog
10231017
* @global int $g_show_changelog_dates

‎core/config_api.php

-1
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,6 @@ function config_is_private( $p_config_var ) {
639639
case 'global_settings':
640640
case 'system_font_folder':
641641
case 'phpMailer_method':
642-
case 'default_avatar':
643642
case 'file_upload_ftp_server':
644643
case 'file_upload_ftp_user':
645644
case 'file_upload_ftp_pass':

‎core/obsolete.php

+1
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141

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

145146
# changes in 1.3.0dev
146147
config_obsolete( 'bugnote_allow_user_edit_delete', '' );

‎core/print_api.php

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

170170
# Print avatar image for the given user ID
171171
function print_avatar( $p_user_id, $p_size = 80 ) {
172+
if ( OFF == config_get( 'show_avatar' ) ) {
173+
return;
174+
}
175+
172176
if( !user_exists( $p_user_id ) ) {
173177
return;
174178
}

‎core/user_api.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -808,11 +808,10 @@ function user_get_name( $p_user_id ) {
808808
* @return array|bool an array( URL, width, height ) or false when the given user has no avatar
809809
*/
810810
function user_get_avatar( $p_user_id, $p_size = 80 ) {
811-
$t_email = utf8_strtolower( user_get_email( $p_user_id ) );
811+
$t_email = utf8_strtolower( trim( user_get_email( $p_user_id ) ) );
812812
if( is_blank( $t_email ) ) {
813813
$t_result = false;
814814
} else {
815-
$t_default_image = config_get( 'default_avatar' );
816815
$t_size = $p_size;
817816

818817
$t_use_ssl = false;
@@ -826,7 +825,8 @@ function user_get_avatar( $p_user_id, $p_size = 80 ) {
826825
$t_gravatar_domain = 'https://secure.gravatar.com/';
827826
}
828827

829-
$t_avatar_url = $t_gravatar_domain . 'avatar/' . md5( $t_email ) . '?default=' . urlencode( $t_default_image ) . '&size=' . $t_size . '&rating=G';
828+
$t_avatar_url = $t_gravatar_domain . 'avatar/' . md5( $t_email ) . '?d=identicon&r=G&s=' . $t_size;
829+
830830
$t_result = array(
831831
$t_avatar_url,
832832
$t_size,

‎docbook/Admin_Guide/en-US/Configuration.xml

-6
Original file line numberDiff line numberDiff line change
@@ -891,12 +891,6 @@
891891
<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>
892892
</listitem>
893893
</varlistentry>
894-
<varlistentry>
895-
<term>$g_default_avatar</term>
896-
<listitem>
897-
<para>The full URL to the image to be used when a user doesn't have an avatar account.</para>
898-
</listitem>
899-
</varlistentry>
900894
</variablelist>
901895
</section>
902896

‎images/no_avatar.png

-2.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.