From: Gianluca S. <gi...@us...> - 2007-08-05 21:09:49
|
Update of /cvsroot/mantisbt/mantisbt/core In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv26862/core Modified Files: print_api.php user_api.php Log Message: Fix 8206: Add (gr)avatars for users Index: user_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/user_api.php,v retrieving revision 1.109 retrieving revision 1.110 diff -u -d -r1.109 -r1.110 --- user_api.php 7 May 2007 20:03:05 -0000 1.109 +++ user_api.php 5 Aug 2007 21:09:35 -0000 1.110 @@ -628,6 +628,23 @@ } } + + # 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 ) . + "&default=" . urlencode( $t_default_image ) . + "&size=" . $t_size . + "&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 Index: print_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/print_api.php,v retrieving revision 1.175 retrieving revision 1.176 diff -u -d -r1.175 -r1.176 --- print_api.php 4 Aug 2007 09:05:18 -0000 1.175 +++ print_api.php 5 Aug 2007 21:09:35 -0000 1.176 @@ -103,11 +103,26 @@ 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 ) { |