1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-08 16:45:19 +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:
Marc Alexander 2012-11-30 15:12:34 +01:00
parent 562ebe5c12
commit d5cbedaaa2
8 changed files with 35 additions and 69 deletions

View File

@ -351,7 +351,7 @@ class acp_groups
} }
else 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) if ($avatar)
{ {
$avatar->delete($avatar_data); $avatar->delete($avatar_data);

View File

@ -78,7 +78,7 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function get_data($row, $ignore_config = false) public function get_data($row)
{ {
return array( return array(
'src' => '', 'src' => '',
@ -90,7 +90,7 @@ abstract class phpbb_avatar_driver implements phpbb_avatar_driver_interface
/** /**
* @inheritdoc * @inheritdoc
*/ */
public function get_custom_html($row, $ignore_config = false, $alt = '') public function get_custom_html($row, $alt = '')
{ {
return ''; return '';
} }

View File

@ -29,30 +29,19 @@ class phpbb_avatar_driver_gravatar extends phpbb_avatar_driver
/** /**
* @inheritdoc * @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'],
return array( 'width' => $row['avatar_width'],
'src' => $row['avatar'], 'height' => $row['avatar_height'],
'width' => $row['avatar_width'], );
'height' => $row['avatar_height'],
);
}
else
{
return array(
'src' => '',
'width' => 0,
'height' => 0,
);
}
} }
/** /**
* @inheritdoc * @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) . '" ' . return '<img src="' . $this->get_gravatar_url($row) . '" ' .
($row['avatar_width'] ? ('width="' . $row['avatar_width'] . '" ') : '') . ($row['avatar_width'] ? ('width="' . $row['avatar_width'] . '" ') : '') .

View File

@ -31,23 +31,21 @@ interface phpbb_avatar_driver_interface
/** /**
* Get the avatar url and dimensions * Get the avatar url and dimensions
* *
* @param $ignore_config Whether this function should respect the users prefs * @param array $row User data or group data that has been cleaned with
* and board configuration configuration option, or should just render * phpbb_avatar_manager::clean_row
* the avatar anyways. Useful for the ACP.
* @return array Avatar data, must have keys src, width and height, e.g. * @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 * Returns custom html if it is needed for displaying this avatar
* *
* @param bool $ignore_config Whether this function should respect the users prefs * @param string $alt Alternate text for avatar image
* and board configuration configuration option, or should just render *
* the avatar anyways. Useful for the ACP.
* @return string HTML * @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 * Prepare form for changing the settings of this avatar

View File

@ -24,24 +24,13 @@ class phpbb_avatar_driver_local extends phpbb_avatar_driver
/** /**
* @inheritdoc * @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'],
return array( 'width' => $row['avatar_width'],
'src' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $row['avatar'], 'height' => $row['avatar_height'],
'width' => $row['avatar_width'], );
'height' => $row['avatar_height'],
);
}
else
{
return array(
'src' => '',
'width' => 0,
'height' => 0,
);
}
} }
/** /**

View File

@ -24,24 +24,13 @@ class phpbb_avatar_driver_remote extends phpbb_avatar_driver
/** /**
* @inheritdoc * @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'],
return array( 'width' => $row['avatar_width'],
'src' => $row['avatar'], 'height' => $row['avatar_height'],
'width' => $row['avatar_width'], );
'height' => $row['avatar_height'],
);
}
else
{
return array(
'src' => '',
'width' => 0,
'height' => 0,
);
}
} }
/** /**

View File

@ -54,15 +54,16 @@ class phpbb_avatar_manager
/** /**
* Get the driver object specified by the avatar type * 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 * @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... // Legacy stuff...

View File

@ -1367,7 +1367,7 @@ function get_avatar($row, $alt, $ignore_config = false)
); );
$phpbb_avatar_manager = $phpbb_container->get('avatar.manager'); $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 = ''; $html = '';
if ($avatar) if ($avatar)