Index: bugnote_view_inc.php
===================================================================
--- bugnote_view_inc.php	(revision 376)
+++ bugnote_view_inc.php	(working copy)
@@ -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 );
Index: config_inc.php
===================================================================
--- config_inc.php	(revision 391)
+++ config_inc.php	(working copy)
@@ -122,12 +122,46 @@

+	
+	##############################################################################
+	# Show user avatar
+	# the current implementation is based on http://www.gravatar.com
+	# users will need to register there the same address used in 
+	# this mantis installation to have their avatar shown
+	# Please note: upon registration or avatar change, it takes some time for
+	# the updated gravatar images to show on sites
+	$g_show_avatar = ON;
+	
+	# Only users above this threshold will have their avatar shown
+	$g_show_avatar_threshold = DEVELOPER;	
 
+	# Maximum file size that can be uploaded
+	$g_max_avatar_file_size		= 100000; # 100kB
+
+       # Show avatar in manage_user_list
+       $g_show_avatar_in_manage_user_list = ON;
+  

Index: core/print_api.php
===================================================================
--- core/print_api.php	(revision 390)
+++ core/print_api.php	(working copy)
@@ -103,6 +103,27 @@
 	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_class = "avatar") {
+		$t_avatar_exist = false;
+		
+		if ( access_has_project_level( config_get( 'show_avatar_threshold' ), null, $p_user_id ) ) {
+			$t_avatar = user_get_local_avatar( $p_user_id );
+			$t_avatar_url = $t_avatar[0];
+			$t_width = $t_avatar[1];
+			$t_height = $t_avatar[2];
+			$t_avatar_exist = $t_avatar[3];
+			
+			if ($t_avatar_exist) {
+  			echo '<img class="' . $t_class. '" src="' . $t_avatar_url . '" alt=""' .
+	  			' width="' . $t_width . '" height="' . $t_height . '" />';
+			}
+		}
+		return $t_avatar_exist;
+	}
+	
 	# --------------------
 	# prints the name of the user given the id.  also makes it an email link.
 	function print_user( $p_user_id ) {
Index: core/user_api.php
===================================================================
--- core/user_api.php	(revision 376)
+++ core/user_api.php	(working copy)
@@ -629,6 +629,58 @@
 	}
 
 	# --------------------
+	# 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 avatar image 
+	# return value is an array( URL, width, height )
+	# in this first implementation, only gravatar.com avatars are supported
+	function user_get_local_avatar( $p_user_id ) {
+		global $g_path;
+		$t_avatar_exist = true;
+    
+    # default imagesize
+    $t_height = 80;
+    $t_width = 80;
+
+		$t_username = user_get_name( $p_user_id );
+		$t_avatar_url = $g_path . "/avatar/" . $t_username . ".gif";
+    if (!file_exists(dirname( dirname( __FILE__ ) ).DIRECTORY_SEPARATOR.'avatar'.DIRECTORY_SEPARATOR.$t_username .".gif")) {
+    	$t_avatar_url = $g_path . "/avatar/" . $t_username . ".jpg";
+      if (!file_exists(dirname( dirname( __FILE__ ) ).DIRECTORY_SEPARATOR.'avatar'.DIRECTORY_SEPARATOR.$t_username .".jpg")) {
+        $t_avatar_exist = false;	
+      }
+    }
+
+    if ($t_avatar_exist) {
+      # get image dimensions
+      list($width_orig, $height_orig) = getimagesize($t_avatar_url);
+      $ratio_orig = $width_orig/$height_orig;
+
+      if ($t_width/$t_height > $ratio_orig) {
+        $t_width = $t_height*$ratio_orig;
+      } else {
+        $t_height = $t_width/$ratio_orig;
+      }
+    }      
+    
+		return array( $t_avatar_url, $t_width, $t_height, $t_avatar_exist );
+	}
+
+	# --------------------
 	# return the user's access level
 	#  account for private project and the project user lists
 	function user_get_access_level( $p_user_id, $p_project_id = ALL_PROJECTS ) {
Index: css/default.css
===================================================================
--- css/default.css	(revision 376)
+++ css/default.css	(working copy)
@@ -144,5 +144,17 @@
 	border-bottom: 1px dotted black;
 }
 
+.avatar
+{
+	float: right;
+	border: 0;
+}
+
+.manage_avatar
+{
+	float: left;
+	border: 0;
+}
+
 .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; }
Index: custom_strings_inc.php
===================================================================
--- custom_strings_inc.php	(revision 387)
+++ custom_strings_inc.php	(working copy)
@@ -9,9 +9,14 @@
         
+    #avatar
+    $s_avatar = 'Avatar';        
+    $s_upload_avatar = 'Avatar hochladen';
+    $s_delete_avatar = 'Avatar löschen';
+    
   } else {
+    
+    #avatar
+    $s_avatar = 'Avatar';
+    $s_upload_avatar = 'Upload Avatar';
+    $s_delete_avatar = 'Delete Avatar';
   }
 
 	if ( file_exists( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR . 'pluginmanager' . DIRECTORY_SEPARATOR . 'lang_inc.php' ) ) {
Index: manage_user_edit_page.php
===================================================================
--- manage_user_edit_page.php	(revision 376)
+++ manage_user_edit_page.php	(working copy)
@@ -9,7 +9,10 @@
 	# $Id: manage_user_edit_page.php,v 1.17 2007/03/06 07:05:18 vboctor Exp $
 	# --------------------------------------------------------
 ?>
 <?php
 	access_ensure_global_level( config_get( 'manage_user_threshold' ) );
 
@@ -29,7 +32,7 @@
 
 <!-- USER INFO -->
 <div align="center">
-<form method="post" action="manage_user_update.php">
+<form method="post" action="manage_user_update.php" enctype="multipart/form-data">
 <table class="width75" cellspacing="1">
 <!-- Title -->
 <tr>
@@ -101,6 +104,33 @@
 	</td>
 </tr>
 
+<!-- Avatar -->
+<tr <?php echo helper_alternate_class() ?>>
+	<td class="category">
+		<?php echo lang_get( 'avatar' ) ?>:
+	</td>
+	<td>
+		<?php $t_avatar_exist = print_avatar( $t_user['id'], "manage_avatar" ); ?>&nbsp;
+		<?php if ($t_avatar_exist) { ?>
+		  <input class="button-small" type="submit" name="delete_avatar" value="<?php echo lang_get( 'delete_avatar' ) ?>" />
+	  <?php } ?>
+	</td>
+</tr>
+<?php 
+	$t_max_file_size = (int) config_get( 'max_avatar_file_size' );
+?>
+<tr <?php echo helper_alternate_class() ?>>
+	<td class="category">
+		<?php echo lang_get( 'upload_avatar' ) ?>
+		<?php echo '<span class="small">(' . lang_get( 'max_file_size' ) . ': ' . number_format( $t_max_file_size/1000 ) . 'k)</span>'?>
+	</td>
+	<td>
+		<input type="hidden" name="max_file_size" value="<?php echo $t_max_file_size ?>" />
+		<input <?php echo helper_get_tab_index() ?> name="avatar_file" type="file" size="60" />
+	</td>
+</tr>
+
+
 <!-- Submit Button -->
 <tr>
 	<td colspan="2" class="center">
Index: manage_user_page.php
===================================================================
--- manage_user_page.php	(revision 376)
+++ manage_user_page.php	(working copy)
@@ -251,6 +251,10 @@
 		<?php print_manage_user_sort_link(  'manage_user_page.php', lang_get( 'last_visit' ), 'last_visit', $c_dir, $c_sort, $c_hide ) ?>
 		<?php print_sort_icon( $c_dir, $c_sort, 'last_visit' ) ?>
 	</td>
+	<td>
+		<?php print_manage_user_sort_link(  'manage_user_page.php', lang_get( 'avatar' ), 'avatar', $c_dir, $c_sort, $c_hide ) ?>
+		<?php print_sort_icon( $c_dir, $c_sort, 'avatar' ) ?>
+	</td>
 </tr>
 <?php
 	for ($i=0;$i<$user_count;$i++) {
@@ -260,6 +264,9 @@
 
 		$u_date_created  = date( config_get( 'normal_date_format' ), db_unixtimestamp( $u_date_created ) );
 		$u_last_visit    = date( config_get( 'normal_date_format' ), db_unixtimestamp( $u_last_visit ) );
+		# has avatar
+		$t_avatar = user_get_local_avatar( $u_id );
+		$has_avatar = $t_avatar[3];
 ?>
 <tr <?php echo helper_alternate_class( $i ) ?>>
 	<td>
@@ -280,6 +287,14 @@
         </td>
 	<td><?php echo $u_date_created ?></td>
 	<td><?php echo $u_last_visit ?></td>
+	<td><?php 
+	          if (config_get("show_avatar_in_manage_user_list")) {
+	            print_avatar( $u_id , $t_class = "manage_avatar");
+	          } else {
+	            echo trans_bool( $has_avatar ); 
+	          }
+	    ?>
+	</td>
 </tr>
 <?php
 	}  # end for
Index: manage_user_update.php
===================================================================
--- manage_user_update.php	(revision 376)
+++ manage_user_update.php	(working copy)
@@ -88,6 +88,29 @@
 	}
 
 	$result = db_query( $query );
+	
+	#upload avatar
+	$target_path = "avatar/";
+	$ext = end(explode('.', $_FILES['avatar_file']['name'])); 
+  $target_file = $target_path . $c_username . '.' . $ext; 
+  move_uploaded_file($_FILES['avatar_file']['tmp_name'], $target_file);
+	
+	# delete avatar
+	$f_delete_avatar	= gpc_get_string( 'delete_avatar', '' );
+	if ($f_delete_avatar != '') {
+		$avatar_file = $target_path . '/' . $c_username . '.gif';
+    $fh = fopen($avatar_file, 'w') or die("can't open file");
+    fclose($fh);
+		
+		unlink($avatar_file);
+
+		$avatar_file = $target_path . '/' . $c_username . '.jpg';
+    $fh = fopen($avatar_file, 'w') or die("can't open file");
+    fclose($fh);
+		
+		unlink($avatar_file);
+	}
+	
 	$t_redirect_url = 'manage_user_edit_page.php?user_id=' . $c_user_id;
 ?>
 <?php html_page_top1() ?>
