[Xfce4-commits] <forum:master> Enable Gravatars in the forum.

Nick Schermer noreply at xfce.org
Fri Nov 12 22:38:01 CET 2010


Updating branch refs/heads/master
         to 23b612869b46563470d0002e7d72a40cf408b215 (commit)
       from 22d26020eded86ac36687f06aae3f10afd8a4cf7 (commit)

commit 23b612869b46563470d0002e7d72a40cf408b215
Author: Nick Schermer <nick at xfce.org>
Date:   Fri Nov 12 22:25:22 2010 +0100

    Enable Gravatars in the forum.

 include/functions.php |   23 +++++++++++++++++++++++
 profile.php           |   14 +++++++++++---
 viewtopic.php         |    2 +-
 3 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/include/functions.php b/include/functions.php
index fb7f281..e28bca1 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -495,6 +495,29 @@ function generate_profile_menu($page = '')
 
 
 //
+// Outputs markup to display a user's gravatar
+//
+function generate_gravatar_markup($user_email, $size_override = -1)
+{
+	global $pun_config;
+
+	if ($size_override == -1)
+		$s = $pun_config['o_avatars_width'];
+	else
+		$s = $size_override;
+
+	$d = 'mm'; /* mysteryman */
+
+	if (!empty($user_email))
+		$h = md5 (strtolower (trim ($user_email)));
+	else
+		$h = '';
+
+	return '<img src="http://www.gravatar.com/avatar/'.$h.'?s='.$s.'&d='.$d.'&r=g" width="'.$s.'" height="'.$s.'" alt="" />';
+}
+
+
+//
 // Outputs markup to display a user's avatar
 //
 function generate_avatar_markup($user_id)
diff --git a/profile.php b/profile.php
index 53110d9..2aa5dae 100644
--- a/profile.php
+++ b/profile.php
@@ -296,7 +296,7 @@ else if ($action == 'change_email')
 
 else if ($action == 'upload_avatar' || $action == 'upload_avatar2')
 {
-	if ($pun_config['o_avatars'] == '0')
+	if ($pun_config['o_avatars'] == '0' || $pun_config['o_avatars_size'] == '0')
 		message($lang_profile['Avatars disabled']);
 
 	if ($pun_user['id'] != $id && !$pun_user['is_admmod'])
@@ -1010,7 +1010,7 @@ if ($pun_user['id'] != $id &&
 
 	if ($pun_config['o_avatars'] == '1')
 	{
-		$avatar_field = generate_avatar_markup($id);
+		$avatar_field = generate_gravatar_markup($user['email'], 80);
 		if ($avatar_field != '')
 		{
 			$user_personality[] = '<dt>'.$lang_profile['Avatar'].'</dt>';
@@ -1385,6 +1385,13 @@ else
 		if ($pun_config['o_avatars'] == '0' && $pun_config['o_signatures'] == '0')
 			message($lang_common['Bad request']);
 
+		$user_avatar = generate_gravatar_markup($user['email'], 80);
+		$avatar_field = '<span><a href="http://gravatar.com">Change Gravatar</a></span>';
+		$lang_profile['Avatar info'] = 'A Gravatar is globally recognized avatar that is connected '.
+			'to your e-mail address and in this forum displayed with all your posts. You can '.
+			'change your Gravatar by clicking the link below.';
+
+                /*
 		$avatar_field = '<span><a href="profile.php?action=upload_avatar&id='.$id.'">'.$lang_profile['Change avatar'].'</a></span>';
 
 		$user_avatar = generate_avatar_markup($id);
@@ -1392,6 +1399,7 @@ else
 			$avatar_field .= ' <span><a href="profile.php?action=delete_avatar&id='.$id.'">'.$lang_profile['Delete avatar'].'</a></span>';
 		else
 			$avatar_field = '<span><a href="profile.php?action=upload_avatar&id='.$id.'">'.$lang_profile['Upload avatar'].'</a></span>';
+		*/
 
 		if ($user['signature'] != '')
 			$signature_preview = '<p>'.$lang_profile['Sig preview'].'</p>'."\n\t\t\t\t\t\t\t".'<div class="postsignature postmsg">'."\n\t\t\t\t\t\t\t\t".'<hr />'."\n\t\t\t\t\t\t\t\t".$parsed_signature."\n\t\t\t\t\t\t\t".'</div>'."\n";
@@ -1715,4 +1723,4 @@ else
 <?php
 
 	require PUN_ROOT.'footer.php';
-}
\ No newline at end of file
+}
diff --git a/viewtopic.php b/viewtopic.php
index 7774823..8944c6c 100644
--- a/viewtopic.php
+++ b/viewtopic.php
@@ -237,7 +237,7 @@ while ($cur_post = $db->fetch_assoc($result))
 			if (isset($user_avatar_cache[$cur_post['poster_id']]))
 				$user_avatar = $user_avatar_cache[$cur_post['poster_id']];
 			else
-				$user_avatar = $user_avatar_cache[$cur_post['poster_id']] = generate_avatar_markup($cur_post['poster_id']);
+				$user_avatar = $user_avatar_cache[$cur_post['poster_id']] = generate_gravatar_markup($cur_post['email']);
 		}
 
 		// We only show location, register date, post count and the contact links if "Show user info" is enabled



More information about the Xfce4-commits mailing list