mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-23 18:38:53 +00:00
[feature/avatars] Use request object in avatar drivers
PHPBB3-10018
This commit is contained in:
parent
3b0e0dba32
commit
e861bb0e04
9 changed files with 33 additions and 21 deletions
|
@ -289,7 +289,7 @@ class acp_groups
|
|||
|
||||
if ($config['allow_avatar'])
|
||||
{
|
||||
$avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->getDriver());
|
||||
$avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->getDriver());
|
||||
|
||||
$avatar_drivers = $avatar_manager->get_valid_drivers();
|
||||
sort($avatar_drivers);
|
||||
|
|
|
@ -32,6 +32,7 @@ class acp_users
|
|||
{
|
||||
global $config, $db, $user, $auth, $template, $cache;
|
||||
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads;
|
||||
global $request;
|
||||
|
||||
$user->add_lang(array('posting', 'ucp', 'acp/users'));
|
||||
$this->tpl_name = 'acp_users';
|
||||
|
@ -466,7 +467,7 @@ class acp_users
|
|||
$db->sql_query($sql);
|
||||
|
||||
// Delete old avatar if present
|
||||
$avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->getDriver());
|
||||
$avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->getDriver());
|
||||
if ($driver = $avatar_manager->get_driver($user_row['user_avatar_type']))
|
||||
{
|
||||
$driver->delete($user_row);
|
||||
|
@ -1687,7 +1688,7 @@ class acp_users
|
|||
$avatars_enabled = false;
|
||||
if ($config['allow_avatar'])
|
||||
{
|
||||
$avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->getDriver());
|
||||
$avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->getDriver());
|
||||
|
||||
$avatar_drivers = $avatar_manager->get_valid_drivers();
|
||||
sort($avatar_drivers);
|
||||
|
|
|
@ -26,7 +26,13 @@ abstract class phpbb_avatar_driver
|
|||
* @type phpbb_config
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
|
||||
/**
|
||||
* Current board configuration
|
||||
* @type phpbb_config
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* Current $phpbb_root_path
|
||||
* @type string
|
||||
|
@ -62,13 +68,15 @@ abstract class phpbb_avatar_driver
|
|||
* Construct an driver object
|
||||
*
|
||||
* @param $config The phpBB configuration
|
||||
* @param $request The request object
|
||||
* @param $phpbb_root_path The path to the phpBB root
|
||||
* @param $phpEx The php file extension
|
||||
* @param $cache A cache driver
|
||||
*/
|
||||
public function __construct(phpbb_config $config, $phpbb_root_path, $phpEx, phpbb_cache_driver_interface $cache = null)
|
||||
public function __construct(phpbb_config $config, phpbb_request $request, $phpbb_root_path, $phpEx, phpbb_cache_driver_interface $cache = null)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->phpEx = $phpEx;
|
||||
$this->cache = $cache;
|
||||
|
|
|
@ -50,7 +50,7 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver
|
|||
public function prepare_form($template, $row, &$error)
|
||||
{
|
||||
$avatar_list = $this->get_avatar_list();
|
||||
$category = request_var('av_local_cat', '');
|
||||
$category = $this->request->variable('av_local_cat', '');
|
||||
|
||||
$categories = array_keys($avatar_list);
|
||||
|
||||
|
@ -110,9 +110,9 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver
|
|||
public function process_form($template, $row, &$error)
|
||||
{
|
||||
$avatar_list = $this->get_avatar_list();
|
||||
$category = request_var('av_local_cat', '');
|
||||
|
||||
$file = request_var('av_local_file', '');
|
||||
$category = $this->request->variable('av_local_cat', '');
|
||||
|
||||
$file = $this->request->variable('av_local_file', '');
|
||||
if (!isset($avatar_list[$category][urldecode($file)]))
|
||||
{
|
||||
$error[] = 'AVATAR_URL_NOT_FOUND';
|
||||
|
|
|
@ -50,8 +50,8 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver
|
|||
public function prepare_form($template, $row, &$error)
|
||||
{
|
||||
$template->assign_vars(array(
|
||||
'AV_REMOTE_WIDTH' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar_width']) ? $row['avatar_width'] : request_var('av_local_width', 0),
|
||||
'AV_REMOTE_HEIGHT' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar_height']) ? $row['avatar_height'] : request_var('av_local_width', 0),
|
||||
'AV_REMOTE_WIDTH' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar_width']) ? $row['avatar_width'] : $this->request->variable('av_local_width', 0),
|
||||
'AV_REMOTE_HEIGHT' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar_height']) ? $row['avatar_height'] : $this->request->variable('av_local_width', 0),
|
||||
'AV_REMOTE_URL' => (($row['avatar_type'] == AVATAR_REMOTE || $row['avatar_type'] == 'remote') && $row['avatar']) ? $row['avatar'] : '',
|
||||
));
|
||||
|
||||
|
@ -63,10 +63,10 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver
|
|||
*/
|
||||
public function process_form($template, $row, &$error)
|
||||
{
|
||||
$url = request_var('av_remote_url', '');
|
||||
$width = request_var('av_remote_width', 0);
|
||||
$height = request_var('av_remote_height', 0);
|
||||
|
||||
$url = $this->request->variable('av_remote_url', '');
|
||||
$width = $this->request->variable('av_remote_width', 0);
|
||||
$height = $this->request->variable('av_remote_height', 0);
|
||||
|
||||
if (!preg_match('#^(http|https|ftp)://#i', $url))
|
||||
{
|
||||
$url = 'http://' . $url;
|
||||
|
|
|
@ -76,7 +76,7 @@ class phpbb_avatar_driver_upload extends phpbb_avatar_driver
|
|||
|
||||
$upload = new fileupload('AVATAR_', array('jpg', 'jpeg', 'gif', 'png'), $this->config['avatar_filesize'], $this->config['avatar_min_width'], $this->config['avatar_min_height'], $this->config['avatar_max_width'], $this->config['avatar_max_height'], (isset($this->config['mime_triggers']) ? explode('|', $this->config['mime_triggers']) : false));
|
||||
|
||||
$url = request_var('av_upload_url', '');
|
||||
$url = $this->request->variable('av_upload_url', '');
|
||||
|
||||
if (!empty($_FILES['av_upload_file']['name']))
|
||||
{
|
||||
|
|
|
@ -23,17 +23,19 @@ class phpbb_avatar_manager
|
|||
private $phpbb_root_path;
|
||||
private $phpEx;
|
||||
private $config;
|
||||
private $request;
|
||||
private $cache;
|
||||
private static $valid_drivers = false;
|
||||
|
||||
/**
|
||||
* @TODO
|
||||
**/
|
||||
public function __construct($phpbb_root_path, $phpEx, phpbb_config $config, phpbb_cache_driver_interface $cache = null)
|
||||
public function __construct($phpbb_root_path, $phpEx, phpbb_config $config, phpbb_request $request, phpbb_cache_driver_interface $cache = null)
|
||||
{
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->phpEx = $phpEx;
|
||||
$this->config = $config;
|
||||
$this->request = $request;
|
||||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
|
@ -66,7 +68,7 @@ class phpbb_avatar_manager
|
|||
if ($new || !is_object(self::$valid_drivers[$avatar_type]))
|
||||
{
|
||||
$class_name = 'phpbb_avatar_driver_' . $avatar_type;
|
||||
self::$valid_drivers[$avatar_type] = new $class_name($this->config, $this->phpbb_root_path, $this->phpEx, $this->cache);
|
||||
self::$valid_drivers[$avatar_type] = new $class_name($this->config, $this->request, $this->phpbb_root_path, $this->phpEx, $this->cache);
|
||||
}
|
||||
|
||||
return self::$valid_drivers[$avatar_type];
|
||||
|
|
|
@ -1312,6 +1312,7 @@ function get_group_avatar($user_row, $alt = 'GROUP_AVATAR', $ignore_config = fal
|
|||
function get_avatar($row, $alt, $ignore_config = false)
|
||||
{
|
||||
global $user, $config, $cache, $phpbb_root_path, $phpEx;
|
||||
global $request;
|
||||
|
||||
static $avatar_manager = null;
|
||||
|
||||
|
@ -1369,7 +1370,7 @@ function get_avatar($row, $alt, $ignore_config = false)
|
|||
default:
|
||||
if (empty($avatar_manager))
|
||||
{
|
||||
$avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->get_driver());
|
||||
$avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->get_driver());
|
||||
}
|
||||
|
||||
$avatar = $avatar_manager->get_driver($row['avatar_type']);
|
||||
|
|
|
@ -552,8 +552,8 @@ class ucp_profile
|
|||
|
||||
if ($config['allow_avatar'] && $auth->acl_get('u_chgavatar'))
|
||||
{
|
||||
$avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $cache->getDriver());
|
||||
|
||||
$avatar_manager = new phpbb_avatar_manager($phpbb_root_path, $phpEx, $config, $request, $cache->getDriver());
|
||||
|
||||
$avatar_drivers = $avatar_manager->get_valid_drivers();
|
||||
sort($avatar_drivers);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue