Commit 5be710bd authored by Francois Marier's avatar Francois Marier
Browse files

gravatar images: add basic support for compatible avatar servers


Signed-off-by: default avatarFrancois Marier <francois@catalyst.net.nz>
parent 6f74a19c
...@@ -17,3 +17,10 @@ Gravatar in such an environment would simply add extra delays.</p> ...@@ -17,3 +17,10 @@ Gravatar in such an environment would simply add extra delays.</p>
<p>Also, for <b>sites delivered over https</b>, enabling Gravatar profile <p>Also, for <b>sites delivered over https</b>, enabling Gravatar profile
icons might trigger security warnings on some browsers. This is due to the icons might trigger security warnings on some browsers. This is due to the
fact that Gravatar images are served via normal unencrypted http.</p> fact that Gravatar images are served via normal unencrypted http.</p>
<h4>Custom avatar server</h4>
<p>If you have a custom avatar server which implements the Gravatar
protocol, you may specify its base url in your config.php file:</p>
<p><code>$cfg->remoteavatarbaseurl = 'http://example.com/avatar/';</code></p>
...@@ -222,4 +222,7 @@ $cfg->maxrunage = 300; ...@@ -222,4 +222,7 @@ $cfg->maxrunage = 300;
// if importing Leap2A over an xmlrpc mnet connection, set this to something higher than 0 to log import information // if importing Leap2A over an xmlrpc mnet connection, set this to something higher than 0 to log import information
// see the constants in import/leap/lib.php // see the constants in import/leap/lib.php
$cfg->leapovermnetloglevel = 0; $cfg->leapovermnetloglevel = 0;
?>
// base URL of avatar server (with the trailing slash)
// This should normally be set to http://www.gravatar.com/avatar/
//$cfg->remoteavatarbaseurl = 'http://www.gravatar.com/avatar/';
...@@ -1817,7 +1817,7 @@ function profile_icon_url($user, $maxwidth=40, $maxheight=40) { ...@@ -1817,7 +1817,7 @@ function profile_icon_url($user, $maxwidth=40, $maxheight=40) {
return $thumb . '?type=profileiconbyid&' . $sizeparams . '&id=' . $user->profileicon; return $thumb . '?type=profileiconbyid&' . $sizeparams . '&id=' . $user->profileicon;
} }
else if (get_config('remoteavatars')) { else if (get_config('remoteavatars')) {
return gravatar_icon($user->email, array('maxw' => $maxwidth, 'maxh' => $maxheight), $notfound); return remote_avatar($user->email, array('maxw' => $maxwidth, 'maxh' => $maxheight), $notfound);
} }
return $notfound; return $notfound;
} }
...@@ -1831,7 +1831,7 @@ function profile_icon_url($user, $maxwidth=40, $maxheight=40) { ...@@ -1831,7 +1831,7 @@ function profile_icon_url($user, $maxwidth=40, $maxheight=40) {
* *
* @returns string The URL of the image or FALSE if none was found * @returns string The URL of the image or FALSE if none was found
*/ */
function gravatar_icon($email, $size, $notfound) { function remote_avatar($email, $size, $notfound) {
if (!get_config('remoteavatars')) { if (!get_config('remoteavatars')) {
return false; return false;
} }
...@@ -1845,7 +1845,11 @@ function gravatar_icon($email, $size, $notfound) { ...@@ -1845,7 +1845,11 @@ function gravatar_icon($email, $size, $notfound) {
$s = min($newsize['w'], $newsize['h']); $s = min($newsize['w'], $newsize['h']);
} }
return "http://www.gravatar.com/avatar/{$md5sum}.jpg?r=g&s=$s&d=" . urlencode($notfound); $baseurl = 'http://www.gravatar.com/avatar/';
if (get_config('remoteavatarbaseurl')) {
$baseurl = get_config('remoteavatarbaseurl');
}
return "{$baseurl}{$md5sum}.jpg?r=g&s=$s&d=" . urlencode($notfound);
} }
/** /**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment