>
+ |
|
Index: account_update.php
===================================================================
--- account_update.php (revision 5305)
+++ account_update.php (working copy)
@@ -41,6 +41,7 @@
$f_realname = gpc_get_string( 'realname', '' );
$f_password = gpc_get_string( 'password', '' );
$f_password_confirm = gpc_get_string( 'password_confirm', '' );
+ $f_use_gravatar = gpc_get_bool( 'use_gravatar' );
$f_email = email_append_domain( $f_email );
@@ -91,6 +92,34 @@
}
}
+ # avatar
+ $t_username = user_get_field( $t_user_id, 'username' );
+ # store use_avatar in config
+ config_set('use_gravatar', $f_use_gravatar, $t_user_id, ALL_PROJECTS);
+
+ # upload avatar
+ $target_path = config_get('directory_avatar') . '/';
+ $avatar_file_name = $_FILES['avatar_file']['name'];
+ $ext = end(explode('.', $_FILES['avatar_file']['name']));
+ $target_file = $target_path . $t_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 . '/' . $t_username . '.gif';
+ $fh = fopen($avatar_file, 'w') or die("can't open file");
+ fclose($fh);
+
+ unlink($avatar_file);
+
+ $avatar_file = $target_path . '/' . $t_username . '.jpg';
+ $fh = fopen($avatar_file, 'w') or die("can't open file");
+ fclose($fh);
+
+ unlink($avatar_file);
+ }
+
html_page_top1();
html_meta_redirect( $t_redirect );
html_page_top2();
Index: config_defaults_inc.php
===================================================================
--- config_defaults_inc.php (revision 5305)
+++ config_defaults_inc.php (working copy)
@@ -600,6 +600,15 @@
# Default avatar for users without a gravatar account
$g_default_avatar = "%path%images/no_avatar.png";
+ $g_avatar_max_width = 80;
+ $g_avatar_max_height = 80;
+
+ # local directory to store avatar
+ $g_directory_avatar = 'avatar';
+
+ # Show avatar in manage_user_list
+ $g_show_avatar_in_manage_user_list = OFF;
+
# Show release dates on roadmap/changelog
$g_show_changelog_dates = ON;
$g_show_roadmap_dates = ON;
Index: core/print_api.php
===================================================================
--- core/print_api.php (revision 5305)
+++ core/print_api.php (working copy)
@@ -137,22 +137,39 @@
# Print avatar image for the given user ID
- function print_avatar( $p_user_id, $p_size = 80 ) {
+ function print_avatar( $p_user_id, $p_size = 80, $t_class = "avatar") {
+ $t_avatar_exist = false;
+
if ( !user_exists( $p_user_id ) ) {
return;
}
if ( access_has_project_level( config_get( 'show_avatar_threshold' ), null, $p_user_id ) ) {
- $t_avatar = user_get_avatar( $p_user_id, $p_size );
- if ( false !== $t_avatar ) {
+ $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, $p_size );
+ if ( false !== $t_avatar ) {
+ $t_avatar_url = $t_avatar[0];
+ $t_width = $t_avatar[1];
+ $t_height = $t_avatar[2];
+ 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];
- echo '' .
- ' ';
+ $t_avatar_exist = $t_avatar[3];
+
+ if ($t_avatar_exist) {
+ echo ' ';
+ }
}
}
+ return $t_avatar_exist;
}
Index: core/user_api.php
===================================================================
--- core/user_api.php (revision 5305)
+++ core/user_api.php (working copy)
@@ -773,7 +773,43 @@
return $t_result;
}
+ /**
+ * return the local stored user avatar image URL
+ * @return array|bool an array( URL, width, height ) or false when the given user has no avatar
+ */
+ function user_get_local_avatar( $p_user_id ) {
+ $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_field($p_user_id, 'username');
+
+ $t_avatar_url = $avatar_dir . '/' . $t_username . '.gif';
+ if (!file_exists($t_avatar_url)) {
+ $t_avatar_url = $avatar_dir . '/' . $t_username . '.jpg';
+ if (!file_exists($t_avatar_url)) {
+ $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
Index: css/default.css
===================================================================
--- css/default.css (revision 5305)
+++ css/default.css (working copy)
@@ -161,5 +161,11 @@
border: 0;
}
+.manage_avatar
+{
+ float: left;
+ border: 2;
+}
+
.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: lang/strings_english.txt
===================================================================
--- lang/strings_english.txt (revision 5305)
+++ lang/strings_english.txt (working copy)
@@ -1528,4 +1528,9 @@
#account_view_page.php
$s_view_account_title = 'User Information';
+#avatar
+$s_avatar = 'Avatar';
+$s_use_gravatar = 'Use Gravatar for Avatar';
+$s_upload_avatar = 'Upload Avatar';
+$s_delete_avatar = 'Delete Avatar';
?>
Index: lang/strings_german.txt
===================================================================
--- lang/strings_german.txt (revision 5305)
+++ lang/strings_german.txt (working copy)
@@ -1485,4 +1485,10 @@
$s_graph_page = 'Grafische Eintrags-Historie';
$s_graph_bug_page_link = 'Grafik';
+#avatar
+$s_avatar = 'Avatar';
+$s_use_gravatar = 'Gravatar für Avatar benutzen';
+$s_upload_avatar = 'Avatar hochladen';
+$s_delete_avatar = 'Avatar löschen';
+
?>
Index: manage_user_edit_page.php
===================================================================
--- manage_user_edit_page.php (revision 5305)
+++ manage_user_edit_page.php (working copy)
@@ -32,6 +32,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();
@@ -43,7 +45,7 @@
|