aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2012-12-04 15:12:04 +0100
committerMarc Alexander <admin@m-a-styles.de>2012-12-04 15:12:04 +0100
commitfb139a88203fb5475712c2bc39e653996cd9103f (patch)
tree3e26453bf8ba32c73c62bbc2e12b3e23f978d444
parent8aaa3e055fdc50faeea6f590408a7bcbb03a8d92 (diff)
downloadforums-fb139a88203fb5475712c2bc39e653996cd9103f.tar
forums-fb139a88203fb5475712c2bc39e653996cd9103f.tar.gz
forums-fb139a88203fb5475712c2bc39e653996cd9103f.tar.bz2
forums-fb139a88203fb5475712c2bc39e653996cd9103f.tar.xz
forums-fb139a88203fb5475712c2bc39e653996cd9103f.zip
[feature/avatars] Fix behavior of avatar manager and variables
The $force_all variable was only partially removed and the behavior was not consistent in all files. PHPBB3-10018
-rw-r--r--phpBB/includes/acp/acp_board.php2
-rw-r--r--phpBB/includes/acp/acp_groups.php10
-rw-r--r--phpBB/includes/avatar/manager.php20
-rw-r--r--tests/avatar/manager_test.php7
4 files changed, 21 insertions, 18 deletions
diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php
index 9e63e59403..a48d6eda83 100644
--- a/phpBB/includes/acp/acp_board.php
+++ b/phpBB/includes/acp/acp_board.php
@@ -113,7 +113,7 @@ class acp_board
$avatar_vars = array();
foreach ($avatar_drivers as $current_driver)
{
- $driver = $phpbb_avatar_manager->get_driver($current_driver);
+ $driver = $phpbb_avatar_manager->get_driver($current_driver, false);
/*
* First grab the settings for enabling/disabling the avatar
diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php
index b425b9d374..ae0abdd139 100644
--- a/phpBB/includes/acp/acp_groups.php
+++ b/phpBB/includes/acp/acp_groups.php
@@ -522,26 +522,26 @@ class acp_groups
$avatars_enabled = false;
$selected_driver = $phpbb_avatar_manager->clean_driver_name($request->variable('avatar_driver', $avatar_data['avatar_type']));
- foreach ($avatar_drivers as $driver)
+ foreach ($avatar_drivers as $current_driver)
{
- $driver = $phpbb_avatar_manager->get_driver($driver);
+ $driver = $phpbb_avatar_manager->get_driver($current_driver);
$avatars_enabled = true;
- $config_name = preg_replace('#^avatar\.driver.#', '', $driver);
+ $config_name = $phpbb_avatar_manager->get_driver_config_name($driver);
$template->set_filenames(array(
'avatar' => "acp_avatar_options_$config_name.html",
));
if ($driver->prepare_form($template, $avatar_data, $avatar_error))
{
- $driver_name = $phpbb_avatar_manager->prepare_driver_name($driver);
+ $driver_name = $phpbb_avatar_manager->prepare_driver_name($current_driver);
$driver_upper = strtoupper($driver_name);
$template->assign_block_vars('avatar_drivers', array(
'L_TITLE' => $user->lang($driver_upper . '_TITLE'),
'L_EXPLAIN' => $user->lang($driver_upper . '_EXPLAIN'),
'DRIVER' => $driver_name,
- 'SELECTED' => $driver == $selected_driver,
+ 'SELECTED' => $current_driver == $selected_driver,
'OUTPUT' => $template->assign_display('avatar'),
));
}
diff --git a/phpBB/includes/avatar/manager.php b/phpBB/includes/avatar/manager.php
index 81a135b46f..2789158de5 100644
--- a/phpBB/includes/avatar/manager.php
+++ b/phpBB/includes/avatar/manager.php
@@ -47,17 +47,19 @@ class phpbb_avatar_manager
* Get the driver object specified by the avatar type
*
* @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
+ * @param bool $load_valid Load only valid avatars
*
* @return object Avatar driver object
*/
- public function get_driver($avatar_type, $force_all = false)
+ public function get_driver($avatar_type, $load_valid = true)
{
- if (self::$valid_drivers === false || $force_all)
+ if (self::$valid_drivers === false)
{
- $this->load_valid_drivers($force_all);
+ $this->load_valid_drivers();
}
+ $avatar_drivers = ($load_valid) ? self::$valid_drivers : $this->get_all_drivers();
+
// Legacy stuff...
switch ($avatar_type)
{
@@ -72,7 +74,7 @@ class phpbb_avatar_manager
break;
}
- if (!isset(self::$valid_drivers[$avatar_type]))
+ if (!isset($avatar_drivers[$avatar_type]))
{
return null;
}
@@ -89,17 +91,15 @@ class phpbb_avatar_manager
/**
* Load the list of valid drivers
* This is executed once and fills self::$valid_drivers
- *
- * @param bool $force_all Force showing all avatar drivers
*/
- protected function load_valid_drivers($force_all = false)
+ protected function load_valid_drivers()
{
if (!empty($this->avatar_drivers))
{
self::$valid_drivers = array();
foreach ($this->avatar_drivers as $driver)
{
- if ($force_all || $this->is_enabled($driver))
+ if ($this->is_enabled($driver))
{
self::$valid_drivers[$driver->get_name()] = $driver->get_name();
}
@@ -138,7 +138,7 @@ class phpbb_avatar_manager
{
if (self::$valid_drivers === false)
{
- $this->load_valid_drivers($force_all);
+ $this->load_valid_drivers();
}
return self::$valid_drivers;
diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php
index af0a2edccc..cae72c982b 100644
--- a/tests/avatar/manager_test.php
+++ b/tests/avatar/manager_test.php
@@ -38,10 +38,13 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase
public function test_get_driver()
{
- $driver = $this->manager->get_driver('avatar.driver.foobar', true);
+ $driver = $this->manager->get_driver('avatar.driver.foobar', false);
$this->assertEquals('avatar.driver.foobar', $driver);
- $driver = $this->manager->get_driver('avatar.driver.foo_wrong', true);
+ $driver = $this->manager->get_driver('avatar.driver.foo_wrong', false);
+ $this->assertNull($driver);
+
+ $driver = $this->manager->get_driver('avatar.driver.foobar');
$this->assertNull($driver);
}