mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-07 16:15:22 +02:00
[feature/avatars] Let avatar manager handle $ignore_config
The avatar manager already handles if avatars are enabled. It should also handle ignoring the config settings. PHPBB3-10018
This commit is contained in:
parent
562ebe5c12
commit
d5cbedaaa2
@ -351,7 +351,7 @@ class acp_groups
|
||||
}
|
||||
else
|
||||
{
|
||||
$avatar = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type'])
|
||||
$avatar = $phpbb_avatar_manager->get_driver($user->data['user_avatar_type']);
|
||||
if ($avatar)
|
||||
{
|
||||
$avatar->delete($avatar_data);
|
||||
|
@ -78,7 +78,7 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_data($row, $ignore_config = false)
|
||||
public function get_data($row)
|
||||
{
|
||||
return array(
|
||||
'src' => '',
|
||||
@ -90,7 +90,7 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_custom_html($row, $ignore_config = false, $alt = '')
|
||||
public function get_custom_html($row, $alt = '')
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
@ -29,30 +29,19 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_data($row, $ignore_config = false)
|
||||
public function get_data($row)
|
||||
{
|
||||
if ($ignore_config || $this->config['allow_avatar_gravatar'])
|
||||
{
|
||||
return array(
|
||||
'src' => $row['avatar'],
|
||||
'width' => $row['avatar_width'],
|
||||
'height' => $row['avatar_height'],
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return array(
|
||||
'src' => '',
|
||||
'width' => 0,
|
||||
'height' => 0,
|
||||
);
|
||||
}
|
||||
return array(
|
||||
'src' => $row['avatar'],
|
||||
'width' => $row['avatar_width'],
|
||||
'height' => $row['avatar_height'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_custom_html($row, $ignore_config = false, $alt = '')
|
||||
public function get_custom_html($row, $alt = '')
|
||||
{
|
||||
return '<img src="' . $this->get_gravatar_url($row) . '" ' .
|
||||
($row['avatar_width'] ? ('width="' . $row['avatar_width'] . '" ') : '') .
|
||||
|
@ -31,23 +31,21 @@ interface phpbb_avatar_driver_interface
|
||||
/**
|
||||
* Get the avatar url and dimensions
|
||||
*
|
||||
* @param $ignore_config Whether this function should respect the users prefs
|
||||
* and board configuration configuration option, or should just render
|
||||
* the avatar anyways. Useful for the ACP.
|
||||
* @param array $row User data or group data that has been cleaned with
|
||||
* phpbb_avatar_manager::clean_row
|
||||
* @return array Avatar data, must have keys src, width and height, e.g.
|
||||
* ['src' => '', 'width' => 0, 'height' => 0]
|
||||
* ['src' => '', 'width' => 0, 'height' => 0]
|
||||
*/
|
||||
public function get_data($row, $ignore_config = false);
|
||||
public function get_data($row);
|
||||
|
||||
/**
|
||||
* Returns custom html if it is needed for displaying this avatar
|
||||
*
|
||||
* @param bool $ignore_config Whether this function should respect the users prefs
|
||||
* and board configuration configuration option, or should just render
|
||||
* the avatar anyways. Useful for the ACP.
|
||||
* @param string $alt Alternate text for avatar image
|
||||
*
|
||||
* @return string HTML
|
||||
*/
|
||||
public function get_custom_html($row, $ignore_config = false, $alt = '');
|
||||
public function get_custom_html($row, $alt = '');
|
||||
|
||||
/**
|
||||
* Prepare form for changing the settings of this avatar
|
||||
|
@ -24,24 +24,13 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_data($row, $ignore_config = false)
|
||||
public function get_data($row)
|
||||
{
|
||||
if ($ignore_config || $this->config['allow_avatar_local'])
|
||||
{
|
||||
return array(
|
||||
'src' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $row['avatar'],
|
||||
'width' => $row['avatar_width'],
|
||||
'height' => $row['avatar_height'],
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return array(
|
||||
'src' => '',
|
||||
'width' => 0,
|
||||
'height' => 0,
|
||||
);
|
||||
}
|
||||
return array(
|
||||
'src' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $row['avatar'],
|
||||
'width' => $row['avatar_width'],
|
||||
'height' => $row['avatar_height'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,24 +24,13 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function get_data($row, $ignore_config = false)
|
||||
public function get_data($row)
|
||||
{
|
||||
if ($ignore_config || $this->config['allow_avatar_remote'])
|
||||
{
|
||||
return array(
|
||||
'src' => $row['avatar'],
|
||||
'width' => $row['avatar_width'],
|
||||
'height' => $row['avatar_height'],
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return array(
|
||||
'src' => '',
|
||||
'width' => 0,
|
||||
'height' => 0,
|
||||
);
|
||||
}
|
||||
return array(
|
||||
'src' => $row['avatar'],
|
||||
'width' => $row['avatar_width'],
|
||||
'height' => $row['avatar_height'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,15 +54,16 @@ class phpbb_avatar_manager
|
||||
/**
|
||||
* Get the driver object specified by the avatar type
|
||||
*
|
||||
* @param string Avatar type; by default an avatar's service container name
|
||||
* @param string $avatar_type Avatar type; by default an avatar's service container name
|
||||
* @param bool $force_all Grab all avatar drivers, no matter if enabled or not
|
||||
*
|
||||
* @return object Avatar driver object
|
||||
*/
|
||||
public function get_driver($avatar_type)
|
||||
public function get_driver($avatar_type, $force_all = false)
|
||||
{
|
||||
if (self::$valid_drivers === false)
|
||||
if (self::$valid_drivers === false || $force_all)
|
||||
{
|
||||
$this->load_valid_drivers();
|
||||
$this->load_valid_drivers($force_all);
|
||||
}
|
||||
|
||||
// Legacy stuff...
|
||||
|
@ -1367,7 +1367,7 @@ function get_avatar($row, $alt, $ignore_config = false)
|
||||
);
|
||||
|
||||
$phpbb_avatar_manager = $phpbb_container->get('avatar.manager');
|
||||
$avatar = $phpbb_avatar_manager->get_driver($row['avatar_type']);
|
||||
$avatar = $phpbb_avatar_manager->get_driver($row['avatar_type'], $ignore_config);
|
||||
$html = '';
|
||||
|
||||
if ($avatar)
|
||||
|
Loading…
x
Reference in New Issue
Block a user