mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-25 01:13:25 +01:00
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;
|
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)
|
function __construct($id_data)
|
||||||
{
|
{
|
||||||
@ -51,7 +52,8 @@ class Photo
|
|||||||
|
|
||||||
if (!($this->contact = $contact->read($id_data)))
|
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()
|
function hasPhoto()
|
||||||
{
|
{
|
||||||
|
if (!is_array($this->contact))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (!empty($this->contact['jpegphoto']))
|
if (!empty($this->contact['jpegphoto']))
|
||||||
{
|
{
|
||||||
return $this->contact['jpegphoto'];
|
return $this->contact['jpegphoto'];
|
||||||
@ -90,6 +96,24 @@ class Photo
|
|||||||
return NULL;
|
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
|
* Get session-independent url / sharing link for the contact photo
|
||||||
*
|
*
|
||||||
@ -101,7 +125,7 @@ class Photo
|
|||||||
|
|
||||||
if (empty($path))
|
if (empty($path))
|
||||||
{
|
{
|
||||||
return null;
|
return $this->anonLavatar();
|
||||||
}
|
}
|
||||||
// if we got photo, we have to create a temp. file to share
|
// if we got photo, we have to create a temp. file to share
|
||||||
if ($path[0] !== '/')
|
if ($path[0] !== '/')
|
||||||
@ -109,12 +133,12 @@ class Photo
|
|||||||
$tmp = tempnam($GLOBALS['egw_info']['server']['temp_dir'], '.jpeg');
|
$tmp = tempnam($GLOBALS['egw_info']['server']['temp_dir'], '.jpeg');
|
||||||
if (!file_put_contents($tmp, $path))
|
if (!file_put_contents($tmp, $path))
|
||||||
{
|
{
|
||||||
return null;
|
return $this->anonLavatar();
|
||||||
}
|
}
|
||||||
$path = $tmp;
|
$path = $tmp;
|
||||||
}
|
}
|
||||||
return Api\Vfs\Sharing::share2link(Api\Vfs\Sharing::create(
|
return Api\Vfs\Sharing::share2link(Api\Vfs\Sharing::create(
|
||||||
'', $path, Api\Vfs\Sharing::READONLY, basename($path), array()
|
'', $path, Api\Vfs\Sharing::READONLY, basename($path), array()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1051,11 +1051,13 @@ class calendar_boupdate extends calendar_bo
|
|||||||
// generate a personal videoconference url, if we need one
|
// generate a personal videoconference url, if we need one
|
||||||
if (!empty($event['##videoconference']) && class_exists('EGroupware\\Status\\Videoconference\\Call'))
|
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'], [
|
$details['videoconference'] = EGroupware\Status\Videoconference\Call::genMeetingUrl($event['##videoconference'], [
|
||||||
'name' => $fullname,
|
'name' => $fullname,
|
||||||
'email' => is_numeric($userid) ? Api\Accounts::id2name($userid, 'account_email') : $userid,
|
'email' => is_numeric($userid) ? Api\Accounts::id2name($userid, 'account_email') : $userid,
|
||||||
// todo: contacts and email-addresses (eg. Gravatar-Url)
|
'avatar' => (string)$avatar,
|
||||||
'avatar' => Api\Framework::getUrl(Api\Egw::link('/api/avatar.php', array('account_id' => $userid))),
|
|
||||||
'account_id' => $userid
|
'account_id' => $userid
|
||||||
]);
|
]);
|
||||||
$event_arr['videoconference'] = [
|
$event_arr['videoconference'] = [
|
||||||
|
Loading…
Reference in New Issue
Block a user