Skip to content

Commit

Permalink
Fix 8206: Add (gr)avatars for users
Browse files Browse the repository at this point in the history
git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@4532 f5dc347c-c33d-0410-90a0-b07cc1902cb9
  • Loading branch information
giallu committed Aug 5, 2007
1 parent cf07f3b commit df7758c
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 4 deletions.
3 changes: 2 additions & 1 deletion bugnote_view_inc.php
Expand Up @@ -6,7 +6,7 @@
# See the files README and LICENSE for details

# --------------------------------------------------------
# $Id: bugnote_view_inc.php,v 1.43 2007-07-28 21:36:50 giallu Exp $
# $Id: bugnote_view_inc.php,v 1.44 2007-08-05 21:09:35 giallu Exp $
# --------------------------------------------------------
?>
<?php
Expand Down Expand Up @@ -124,6 +124,7 @@
?>
<tr class="bugnote" id="c<?php echo $v3_id ?>">
<td class="<?php echo $t_bugnote_css ?>">
<?php if ( ON == config_get("show_avatar") ) print_avatar( $v3_reporter_id ); ?>
<span class="small">(<?php echo $t_bugnote_id_formatted ?>)</span><br />
<?php
echo print_user( $v3_reporter_id );
Expand Down
8 changes: 7 additions & 1 deletion config_defaults_inc.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: config_defaults_inc.php,v 1.350 2007-08-04 03:39:10 vboctor Exp $
# $Id: config_defaults_inc.php,v 1.351 2007-08-05 21:09:35 giallu Exp $
# --------------------------------------------------------


Expand Down Expand Up @@ -512,6 +512,12 @@
$g_show_realname = OFF;
$g_differentiate_duplicates = OFF; # leave off for now

# Show user avatar
# the current implementation is based on http://www.gravatar.com
# users will beed to register there the same address used in
# this mantis installation to have their avatar shown
$g_show_avatar = OFF;

# -- sorting for names in dropdown lists. If turned on, "Jane Doe" will be sorted with the "D"s
$g_sort_by_last_name = OFF;

Expand Down
17 changes: 16 additions & 1 deletion core/print_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: print_api.php,v 1.175 2007-08-04 09:05:18 giallu Exp $
# $Id: print_api.php,v 1.176 2007-08-05 21:09:35 giallu Exp $
# --------------------------------------------------------

$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -103,11 +103,26 @@ function print_header_redirect_update( $p_bug_id ) {
function print_header_redirect_report() {
print_header_redirect( string_get_bug_report_url() );
}


# Print avatar image for the given user ID
function print_avatar( $p_user_id ) {
$t_avatar = user_get_avatar( $p_user_id );
$t_avatar_url = $t_avatar[0];
$t_width = $t_avatar[1];
$t_height = $t_avatar[2];
echo '<img class="avatar" src="' . $t_avatar_url . '" alt="Gravatar image"' .
' width="' . $t_width . '" height="' . $t_height . '" />';
}


# --------------------
# prints the name of the user given the id. also makes it an email link.
function print_user( $p_user_id ) {
echo prepare_user_name( $p_user_id );
}


# --------------------
# same as print_user() but fills in the subject with the bug summary
function print_user_with_subject( $p_user_id, $p_bug_id ) {
Expand Down
19 changes: 18 additions & 1 deletion core/user_api.php
Expand Up @@ -6,7 +6,7 @@
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: user_api.php,v 1.109 2007-05-07 20:03:05 prichards Exp $
# $Id: user_api.php,v 1.110 2007-08-05 21:09:35 giallu Exp $
# --------------------------------------------------------

$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -628,6 +628,23 @@ function user_get_name( $p_user_id ) {
}
}


# return the user avatar image
# return value is an array( URL, width, height )
# in this first implementation, only gravatar.com avatars are supported
function user_get_avatar( $p_user_id ) {
$t_email = user_get_email( $p_user_id );
$t_default_image = "/images/gravatar_logo.gif";
$t_size = 80;
$t_avatar_url = "http://www.gravatar.com/avatar.php?gravatar_id=" . md5( $t_email ) .
"&amp;default=" . urlencode( $t_default_image ) .
"&amp;size=" . $t_size .
"&amp;rating=G";

return array( $t_avatar_url, $t_size, $t_size );
}


# --------------------
# return the user's access level
# account for private project and the project user lists
Expand Down
5 changes: 5 additions & 0 deletions css/default.css
Expand Up @@ -144,5 +144,10 @@ div.quick-summary-right { width: 49%; padding: 2px; text-align: right; float: ri
border-bottom: 1px dotted black;
}

.avatar
{
float: right;
}

.progress400 { position: relative; width: 400px; border: 1px solid #d7d7d7; margin-top: 1em; margin-bottom: 1em; padding: 1px; }
.progress400 .bar { display: block; position: relative; background: #6bba70; text-align: center; font-weight: normal; color: #333; height: 2em; line-height: 2em; }
Binary file added images/gravatar_logo.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit df7758c

Please sign in to comment.