### Eclipse Workspace Patch 1.0
#P mantiscvs
Index: core/user_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/user_api.php,v
retrieving revision 1.111
diff -u -r1.111 user_api.php
--- core/user_api.php 10 Aug 2007 22:17:22 -0000 1.111
+++ core/user_api.php 12 Aug 2007 12:23:18 -0000
@@ -643,6 +643,42 @@
return array( $t_avatar_url, $t_size, $t_size );
}
+
+ # --------------------
+ # return the user avatar image
+ # return value is an array( URL, width, height, file_exist )
+ function user_get_local_avatar( $p_user_id ) {
+ global $g_path;
+ $t_avatar_exist = true;
+ $avatar_dir = config_get('directory_avatar');
+
+ # default imagesize
+ $t_height = config_get('avatar_max_height');
+ $t_width = config_get('avatar_max_width');
+
+ $t_username = user_get_name( $p_user_id );
+ $t_avatar_url = $g_path . '/' . $avatar_dir . '/' . $t_username . '.gif';
+ if (!file_exists(dirname( dirname( __FILE__ ) ).DIRECTORY_SEPARATOR.$avatar_dir.DIRECTORY_SEPARATOR.$t_username .".gif")) {
+ $t_avatar_url = $g_path . '/' . $avatar_dir . '/' . $t_username . '.jpg';
+ if (!file_exists(dirname( dirname( __FILE__ ) ).DIRECTORY_SEPARATOR.$avatar_dir.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 );
+ }
# --------------------
Index: core/print_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/print_api.php,v
retrieving revision 1.177
diff -u -r1.177 print_api.php
--- core/print_api.php 8 Aug 2007 22:28:54 -0000 1.177
+++ core/print_api.php 12 Aug 2007 12:23:18 -0000
@@ -106,16 +106,35 @@
# Print avatar image for the given user ID
- function print_avatar( $p_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_avatar( $p_user_id );
- $t_avatar_url = $t_avatar[0];
- $t_width = $t_avatar[1];
- $t_height = $t_avatar[2];
- echo '' .
- '';
+ $t_use_gravatar = config_get( 'use_gravatar', false, $p_user_id, ALL_PROJECTS );
+
+ if ($t_use_gravatar) {
+ $t_avatar = user_get_avatar( $p_user_id );
+ $t_avatar_url = $t_avatar[0];
+ $t_width = $t_avatar[1];
+ $t_height = $t_avatar[2];
+ $t_avatar_exist = true;
+ echo '' .
+ '
';
+ } else {
+ $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 '
';
+ }
+ }
}
+ return $t_avatar_exist;
}
Index: config_defaults_inc.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/config_defaults_inc.php,v
retrieving revision 1.353
diff -u -r1.353 config_defaults_inc.php
--- config_defaults_inc.php 8 Aug 2007 22:28:53 -0000 1.353
+++ config_defaults_inc.php 12 Aug 2007 12:23:17 -0000
@@ -526,6 +526,19 @@
# 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 (image) in manage_user_list
+ $g_show_avatar_in_manage_user_list = ON;
+
+ # max size of avatar
+ $g_avatar_max_width = 80;
+ $g_avatar_max_height = 80;
+
+ # local directory to store avatar
+ $g_directory_avatar = 'avatar';
+
############################
# Mantis JPGRAPH Addon
############################
Index: manage_user_edit_page.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/manage_user_edit_page.php,v
retrieving revision 1.17
diff -u -r1.17 manage_user_edit_page.php
--- manage_user_edit_page.php 6 Mar 2007 07:05:18 -0000 1.17
+++ manage_user_edit_page.php 12 Aug 2007 12:23:17 -0000
@@ -18,6 +18,8 @@
$t_user = user_get_row( $f_user_id );
+ $t_use_gravatar = config_get( 'use_gravatar', false, $f_user_id, ALL_PROJECTS );
+
html_page_top1();
html_page_top2();
@@ -29,7 +31,7 @@