mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-14 04:42:04 +02:00
Merge branch '3.1.x'
This commit is contained in:
commit
ea6bcdff52
@ -676,9 +676,8 @@ class acp_groups
|
||||
$driver = $phpbb_avatar_manager->get_driver($current_driver);
|
||||
|
||||
$avatars_enabled = true;
|
||||
$config_name = $phpbb_avatar_manager->get_driver_config_name($driver);
|
||||
$template->set_filenames(array(
|
||||
'avatar' => "acp_avatar_options_{$config_name}.html",
|
||||
'avatar' => $driver->get_acp_template_name(),
|
||||
));
|
||||
|
||||
if ($driver->prepare_form($request, $template, $user, $avatar_data, $avatar_error))
|
||||
|
@ -1919,9 +1919,8 @@ class acp_users
|
||||
$driver = $phpbb_avatar_manager->get_driver($current_driver);
|
||||
|
||||
$avatars_enabled = true;
|
||||
$config_name = $phpbb_avatar_manager->get_driver_config_name($driver);
|
||||
$template->set_filenames(array(
|
||||
'avatar' => "acp_avatar_options_{$config_name}.html",
|
||||
'avatar' => $driver->get_acp_template_name(),
|
||||
));
|
||||
|
||||
if ($driver->prepare_form($request, $template, $user, $avatar_data, $error))
|
||||
|
@ -124,6 +124,22 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_config_name()
|
||||
{
|
||||
return preg_replace('#^phpbb\\\\avatar\\\\driver\\\\#', '', get_class($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_acp_template_name()
|
||||
{
|
||||
return 'acp_avatar_options_' . $this->get_config_name() . '.html';
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the driver.
|
||||
*
|
||||
|
@ -25,6 +25,13 @@ interface driver_interface
|
||||
*/
|
||||
public function get_name();
|
||||
|
||||
/**
|
||||
* Returns the config name of the driver. To be used in accessing the CONFIG variables.
|
||||
*
|
||||
* @return string Config name of driver.
|
||||
*/
|
||||
public function get_config_name();
|
||||
|
||||
/**
|
||||
* Get the avatar url and dimensions
|
||||
*
|
||||
@ -110,4 +117,11 @@ interface driver_interface
|
||||
* @return string Avatar driver's template name
|
||||
*/
|
||||
public function get_template_name();
|
||||
|
||||
/**
|
||||
* Get the avatar driver's template name (ACP)
|
||||
*
|
||||
* @return string Avatar driver's template name
|
||||
*/
|
||||
public function get_acp_template_name();
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ class manager
|
||||
*/
|
||||
public function is_enabled($driver)
|
||||
{
|
||||
$config_name = $this->get_driver_config_name($driver);
|
||||
$config_name = $driver->get_config_name();
|
||||
|
||||
return $this->config["allow_avatar_{$config_name}"];
|
||||
}
|
||||
@ -260,25 +260,13 @@ class manager
|
||||
*/
|
||||
public function get_avatar_settings($driver)
|
||||
{
|
||||
$config_name = $this->get_driver_config_name($driver);
|
||||
$config_name = $driver->get_config_name();
|
||||
|
||||
return array(
|
||||
'allow_avatar_' . $config_name => array('lang' => 'ALLOW_' . strtoupper(str_replace('\\', '_', $config_name)), 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the config name of an avatar driver
|
||||
*
|
||||
* @param object $driver Avatar driver object
|
||||
*
|
||||
* @return string Avatar driver config name
|
||||
*/
|
||||
public function get_driver_config_name($driver)
|
||||
{
|
||||
return preg_replace('#^phpbb\\\\avatar\\\\driver\\\\#', '', get_class($driver));
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace "error" strings with their real, localized form
|
||||
*
|
||||
|
@ -67,10 +67,13 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
|
||||
->method('get_name')
|
||||
->will($this->returnValue('avatar.driver.foobar'));
|
||||
// barfoo driver can't be mocked with constructor arguments
|
||||
$this->avatar_barfoo = $this->getMock('\phpbb\avatar\driver\barfoo', array('get_name'));
|
||||
$this->avatar_barfoo = $this->getMock('\phpbb\avatar\driver\barfoo', array('get_name', 'get_config_name'));
|
||||
$this->avatar_barfoo->expects($this->any())
|
||||
->method('get_name')
|
||||
->will($this->returnValue('avatar.driver.barfoo'));
|
||||
$this->avatar_barfoo->expects($this->any())
|
||||
->method('get_config_name')
|
||||
->will($this->returnValue('barfoo'));
|
||||
$avatar_drivers = array($this->avatar_foobar, $this->avatar_barfoo);
|
||||
|
||||
$files_factory = new \phpbb\files\factory($phpbb_container);
|
||||
|
Loading…
x
Reference in New Issue
Block a user