mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-14 15:28:52 +00:00
[feature/avatars] Add drivers for standard avatar types
Adding drivers for gallery, uploaded, and remote avatars. These may be used as examples for others to develop their own avatar drivers. PHPBB3-10018
This commit is contained in:
parent
1bd3d40121
commit
16bb0f00b7
3 changed files with 150 additions and 0 deletions
50
phpBB/includes/avatar/driver/gallery.php
Normal file
50
phpBB/includes/avatar/driver/gallery.php
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package avatar
|
||||||
|
* @copyright (c) 2005, 2009 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
if (!defined('IN_PHPBB'))
|
||||||
|
{
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles avatars selected from the board gallery
|
||||||
|
* @package avatars
|
||||||
|
*/
|
||||||
|
class phpbb_avatar_driver_gallery extends phpbb_avatar_driver
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the avatar url and dimensions
|
||||||
|
*
|
||||||
|
* @param $ignore_config Whether $user or global avatar visibility settings
|
||||||
|
* should be ignored
|
||||||
|
* @return array Avatar data
|
||||||
|
*/
|
||||||
|
public function get_data($user_row, $ignore_config = false)
|
||||||
|
{
|
||||||
|
if ($ignore_config || $this->config['allow_avatar_local'])
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'src' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $user_row['user_avatar'],
|
||||||
|
'width' => $user_row['user_avatar_width'],
|
||||||
|
'height' => $user_row['user_avatar_height'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'src' => '',
|
||||||
|
'width' => 0,
|
||||||
|
'height' => 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
50
phpBB/includes/avatar/driver/remote.php
Normal file
50
phpBB/includes/avatar/driver/remote.php
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package avatar
|
||||||
|
* @copyright (c) 2005, 2009 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
if (!defined('IN_PHPBB'))
|
||||||
|
{
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles avatars hosted remotely
|
||||||
|
* @package avatars
|
||||||
|
*/
|
||||||
|
class phpbb_avatar_driver_remote extends phpbb_avatar_driver
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the avatar url and dimensions
|
||||||
|
*
|
||||||
|
* @param $ignore_config Whether $user or global avatar visibility settings
|
||||||
|
* should be ignored
|
||||||
|
* @return array Avatar data
|
||||||
|
*/
|
||||||
|
public function get_data($user_row, $ignore_config = false)
|
||||||
|
{
|
||||||
|
if ($ignore_config || $this->config['allow_avatar_remote'])
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'src' => $user_row['user_avatar'],
|
||||||
|
'width' => $user_row['user_avatar_width'],
|
||||||
|
'height' => $user_row['user_avatar_height'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'src' => '',
|
||||||
|
'width' => 0,
|
||||||
|
'height' => 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
50
phpBB/includes/avatar/driver/upload.php
Normal file
50
phpBB/includes/avatar/driver/upload.php
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package avatar
|
||||||
|
* @copyright (c) 2005, 2009 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
if (!defined('IN_PHPBB'))
|
||||||
|
{
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles avatars uploaded to the board
|
||||||
|
* @package avatars
|
||||||
|
*/
|
||||||
|
class phpbb_avatar_driver_upload extends phpbb_avatar_driver
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get the avatar url and dimensions
|
||||||
|
*
|
||||||
|
* @param $ignore_config Whether $user or global avatar visibility settings
|
||||||
|
* should be ignored
|
||||||
|
* @return array Avatar data
|
||||||
|
*/
|
||||||
|
public function get_data($user_row, $ignore_config = false)
|
||||||
|
{
|
||||||
|
if (ignore_config || $this->config['allow_avatar_upload'])
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'src' => $this->phpbb_root_path . 'download/file.' . $this->php_ext . '?avatar=' . $user_row['user_avatar'],
|
||||||
|
'width' => $user_row['user_avatar_width'],
|
||||||
|
'height' => $user_row['user_avatar_height'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'src' => '',
|
||||||
|
'width' => 0,
|
||||||
|
'height' => 0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue