2009-12-10 12:32:57 +09:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* StatusNet - the distributed open-source microblogging tool
|
2011-04-15 00:47:20 +09:00
|
|
|
* Copyright (C) 2009,2011 StatusNet, Inc.
|
2009-12-10 12:32:57 +09:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @package GravatarPlugin
|
|
|
|
* @maintainer Eric Helgeson <erichelgeson@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
|
|
|
// This check helps protect against security problems;
|
|
|
|
// your code file can't be executed directly from the web.
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
class GravatarPlugin extends Plugin
|
|
|
|
{
|
2011-04-15 00:38:41 +09:00
|
|
|
function onEndProfileGetAvatar($profile, $size, &$avatar)
|
|
|
|
{
|
2011-04-15 02:06:23 +09:00
|
|
|
if (empty($avatar)) {
|
2011-04-15 00:38:41 +09:00
|
|
|
$user = $profile->getUser();
|
|
|
|
if (!empty($user) && !empty($user->email)) {
|
|
|
|
// Fake one!
|
|
|
|
$avatar = new Avatar();
|
|
|
|
$avatar->width = $avatar->height = $size;
|
|
|
|
$avatar->url = $this->gravatar_url($user->email, $size);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-07 12:48:00 +09:00
|
|
|
function gravatar_url($email, $size)
|
|
|
|
{
|
2010-10-27 12:56:59 +09:00
|
|
|
$url = "https://secure.gravatar.com/avatar.php?gravatar_id=".
|
2009-12-10 12:32:57 +09:00
|
|
|
md5(strtolower($email)).
|
|
|
|
"&default=".urlencode(Avatar::defaultImage($size)).
|
|
|
|
"&size=".$size;
|
|
|
|
return $url;
|
|
|
|
}
|
2010-01-10 08:58:40 +09:00
|
|
|
|
|
|
|
function onPluginVersion(&$versions)
|
|
|
|
{
|
|
|
|
$versions[] = array('name' => 'Gravatar',
|
|
|
|
'version' => STATUSNET_VERSION,
|
2011-04-15 00:38:41 +09:00
|
|
|
'author' => 'Eric Helgeson, Evan Prodromou',
|
2010-01-10 08:58:40 +09:00
|
|
|
'homepage' => 'http://status.net/wiki/Plugin:Gravatar',
|
|
|
|
'rawdescription' =>
|
2011-04-09 01:46:41 +09:00
|
|
|
// TRANS: Plugin decsription.
|
2010-01-10 08:58:40 +09:00
|
|
|
_m('The Gravatar plugin allows users to use their <a href="http://www.gravatar.com/">Gravatar</a> with StatusNet.'));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2010-09-19 00:14:00 +09:00
|
|
|
}
|