forked from extern/egroupware
Jitsi avatars: shareing url for pictures, anonymous letter-avatar or gravatar if none
This commit is contained in:
parent
6711e3a75f
commit
72116b9587
46
api/anon_lavatar.php
Normal file
46
api/anon_lavatar.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* EGroupware - Anonymous letter-avatar
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @author Ralf Becker <rb-at-egroupware.org>
|
||||
* @license http://opensource.org/licenses/gpl-license.php LGPL - GNU General Public License Version 2 or later
|
||||
* @package api
|
||||
* @subpackage contacts
|
||||
*/
|
||||
|
||||
use EGroupware\Api;
|
||||
|
||||
$GLOBALS['egw_info'] = array('flags' => array(
|
||||
'disable_Template_class' => True,
|
||||
'noheader' => True,
|
||||
// misuse session creation callback to send the image, in case we have no session
|
||||
'autocreate_session_callback' => 'send_image',
|
||||
'currentapp' => 'api',
|
||||
));
|
||||
|
||||
require('../header.inc.php');
|
||||
|
||||
send_image();
|
||||
|
||||
function send_image()
|
||||
{
|
||||
$params = [
|
||||
'firstname' => $_GET['firstname'],
|
||||
'lastname' => $_GET['lastname'],
|
||||
'id' => $_GET['id'],
|
||||
];
|
||||
Api\Session::cache_control(864000); // 10 days
|
||||
header('Content-type: image/jpeg');
|
||||
header('Etag: '.md5(json_encode($params)));
|
||||
|
||||
if (($image = Api\avatar::lavatar($params)) !== false)
|
||||
{
|
||||
echo $image;
|
||||
}
|
||||
else
|
||||
{
|
||||
http_response_code(404);
|
||||
}
|
||||
exit;
|
||||
}
|
@ -36,8 +36,9 @@ class Photo
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* Contructor
|
||||
*
|
||||
* @param int|str|array $id_data contact-id or array with data
|
||||
* @param int|string|array $id_data contact-id, "account:$account_id", array with contact-data or email for gravatar-url
|
||||
*/
|
||||
function __construct($id_data)
|
||||
{
|
||||
@ -51,7 +52,8 @@ class Photo
|
||||
|
||||
if (!($this->contact = $contact->read($id_data)))
|
||||
{
|
||||
throw Api\Exception\NotFound("Contact '$id_data' not found!");
|
||||
$this->contact = $id_data;
|
||||
//throw Api\Exception\NotFound("Contact '$id_data' not found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -79,6 +81,10 @@ class Photo
|
||||
*/
|
||||
function hasPhoto()
|
||||
{
|
||||
if (!is_array($this->contact))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (!empty($this->contact['jpegphoto']))
|
||||
{
|
||||
return $this->contact['jpegphoto'];
|
||||
@ -90,6 +96,24 @@ class Photo
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return URL for anonymous letter-avatar or Gravatar for email-addresses
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function anonLavatar()
|
||||
{
|
||||
if (!is_array($this->contact))
|
||||
{
|
||||
return 'https://gravatar.com/'.md5(trim(strtolower($this->contact)));
|
||||
}
|
||||
return Api\Framework::getUrl(Api\Egw::link('/api/anon_lavatar.php', [
|
||||
'firstname' => $this->contact['firstname'],
|
||||
'lastname' => $this->contact['lastname'],
|
||||
'id' => $this->contact['id'],
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get session-independent url / sharing link for the contact photo
|
||||
*
|
||||
@ -101,7 +125,7 @@ class Photo
|
||||
|
||||
if (empty($path))
|
||||
{
|
||||
return null;
|
||||
return $this->anonLavatar();
|
||||
}
|
||||
// if we got photo, we have to create a temp. file to share
|
||||
if ($path[0] !== '/')
|
||||
@ -109,7 +133,7 @@ class Photo
|
||||
$tmp = tempnam($GLOBALS['egw_info']['server']['temp_dir'], '.jpeg');
|
||||
if (!file_put_contents($tmp, $path))
|
||||
{
|
||||
return null;
|
||||
return $this->anonLavatar();
|
||||
}
|
||||
$path = $tmp;
|
||||
}
|
||||
|
@ -1051,11 +1051,13 @@ class calendar_boupdate extends calendar_bo
|
||||
// generate a personal videoconference url, if we need one
|
||||
if (!empty($event['##videoconference']) && class_exists('EGroupware\\Status\\Videoconference\\Call'))
|
||||
{
|
||||
$avatar = new Api\Contacts\Photo(is_numeric($userid) ? "account:$userid" :
|
||||
(isset($res_info) && $res_info['type'] === 'c' ? $res_info['res_id'] : $userid));
|
||||
|
||||
$details['videoconference'] = EGroupware\Status\Videoconference\Call::genMeetingUrl($event['##videoconference'], [
|
||||
'name' => $fullname,
|
||||
'email' => is_numeric($userid) ? Api\Accounts::id2name($userid, 'account_email') : $userid,
|
||||
// todo: contacts and email-addresses (eg. Gravatar-Url)
|
||||
'avatar' => Api\Framework::getUrl(Api\Egw::link('/api/avatar.php', array('account_id' => $userid))),
|
||||
'avatar' => (string)$avatar,
|
||||
'account_id' => $userid
|
||||
]);
|
||||
$event_arr['videoconference'] = [
|
||||
|
Loading…
Reference in New Issue
Block a user