diff --git a/phpBB/adm/style/acp_avatar_options_gravatar.html b/phpBB/adm/style/acp_avatar_options_gravatar.html
new file mode 100644
index 0000000000..47422a6ecd
--- /dev/null
+++ b/phpBB/adm/style/acp_avatar_options_gravatar.html
@@ -0,0 +1,11 @@
+
+
+
diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_gravatar.html b/phpBB/styles/prosilver/template/ucp_avatar_options_gravatar.html
new file mode 100644
index 0000000000..692f50cb9a
--- /dev/null
+++ b/phpBB/styles/prosilver/template/ucp_avatar_options_gravatar.html
@@ -0,0 +1,25 @@
+
+
+
+
{L_GRAVATAR_AVATAR_EMAIL_EXPLAIN}
+
+
+
+
{L_GRAVATAR_AVATAR_SIZE_EXPLAIN}
+ -
+ ×
+
+
+
diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_local.html b/phpBB/styles/prosilver/template/ucp_avatar_options_local.html
new file mode 100644
index 0000000000..3946b9d269
--- /dev/null
+++ b/phpBB/styles/prosilver/template/ucp_avatar_options_local.html
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
{L_NO_AVATARS}
+
diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html b/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html
new file mode 100644
index 0000000000..39a8483dc4
--- /dev/null
+++ b/phpBB/styles/prosilver/template/ucp_avatar_options_remote.html
@@ -0,0 +1,25 @@
+
+
+
+
{L_LINK_REMOTE_AVATAR_EXPLAIN}
+
+
+
+
{L_LINK_REMOTE_SIZE_EXPLAIN}
+ -
+ ×
+
+
+
diff --git a/phpBB/styles/prosilver/template/ucp_avatar_options_upload.html b/phpBB/styles/prosilver/template/ucp_avatar_options_upload.html
new file mode 100644
index 0000000000..9d3efbd018
--- /dev/null
+++ b/phpBB/styles/prosilver/template/ucp_avatar_options_upload.html
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
{L_UPLOAD_AVATAR_URL_EXPLAIN}
+
+
+
diff --git a/phpBB/styles/prosilver/template/ucp_groups_manage.html b/phpBB/styles/prosilver/template/ucp_groups_manage.html
index 6b017ea3fa..f6fcfa043d 100644
--- a/phpBB/styles/prosilver/template/ucp_groups_manage.html
+++ b/phpBB/styles/prosilver/template/ucp_groups_manage.html
@@ -70,9 +70,7 @@
diff --git a/phpBB/styles/prosilver/template/ucp_profile_avatar.html b/phpBB/styles/prosilver/template/ucp_profile_avatar.html
index a25c43a588..8157d8c15b 100644
--- a/phpBB/styles/prosilver/template/ucp_profile_avatar.html
+++ b/phpBB/styles/prosilver/template/ucp_profile_avatar.html
@@ -6,14 +6,8 @@
-
+{S_HIDDEN_FIELDS}
+{S_FORM_TOKEN}
diff --git a/phpBB/styles/subsilver2/template/avatars.js b/phpBB/styles/subsilver2/template/avatars.js
new file mode 100644
index 0000000000..146aca94d3
--- /dev/null
+++ b/phpBB/styles/subsilver2/template/avatars.js
@@ -0,0 +1,15 @@
+(function($) { // Avoid conflicts with other libraries
+
+"use strict";
+
+function avatarHide() {
+ $('.[class^="avatar_option_"]').hide();
+
+ var selected = $('#avatar_driver').val();
+ $('.avatar_option_' + selected).show();
+}
+
+avatarHide();
+$('#avatar_driver').bind('change', avatarHide);
+
+})(jQuery); // Avoid conflicts with other libraries
diff --git a/phpBB/styles/subsilver2/template/ucp_avatar_options_gravatar.html b/phpBB/styles/subsilver2/template/ucp_avatar_options_gravatar.html
new file mode 100644
index 0000000000..b8840e0aab
--- /dev/null
+++ b/phpBB/styles/subsilver2/template/ucp_avatar_options_gravatar.html
@@ -0,0 +1,13 @@
+
diff --git a/phpBB/styles/subsilver2/template/ucp_avatar_options_local.html b/phpBB/styles/subsilver2/template/ucp_avatar_options_local.html
new file mode 100644
index 0000000000..87e5608fec
--- /dev/null
+++ b/phpBB/styles/subsilver2/template/ucp_avatar_options_local.html
@@ -0,0 +1,39 @@
+
diff --git a/phpBB/styles/subsilver2/template/ucp_avatar_options_remote.html b/phpBB/styles/subsilver2/template/ucp_avatar_options_remote.html
new file mode 100644
index 0000000000..50ebb9b93d
--- /dev/null
+++ b/phpBB/styles/subsilver2/template/ucp_avatar_options_remote.html
@@ -0,0 +1,10 @@
+
diff --git a/phpBB/styles/subsilver2/template/ucp_avatar_options_upload.html b/phpBB/styles/subsilver2/template/ucp_avatar_options_upload.html
new file mode 100644
index 0000000000..6b813baeaa
--- /dev/null
+++ b/phpBB/styles/subsilver2/template/ucp_avatar_options_upload.html
@@ -0,0 +1,12 @@
+
diff --git a/phpBB/styles/subsilver2/template/ucp_groups_manage.html b/phpBB/styles/subsilver2/template/ucp_groups_manage.html
index 12319c9e4e..8064e1e6e9 100644
--- a/phpBB/styles/subsilver2/template/ucp_groups_manage.html
+++ b/phpBB/styles/subsilver2/template/ucp_groups_manage.html
@@ -60,74 +60,43 @@
{L_AVATAR_EXPLAIN} |
- {AVATAR_IMAGE}
{L_DELETE_AVATAR} |
+ {AVATAR_IMAGE}
{L_DELETE_AVATAR} |
-
-
-
- |
- |
-
-
-
-
- {L_UPLOAD_AVATAR_URL_EXPLAIN} |
- |
-
-
-
-
- {L_LINK_REMOTE_AVATAR_EXPLAIN} |
- |
-
-
- {L_LINK_REMOTE_SIZE_EXPLAIN} |
- px X px |
-
-
-
-
- |
- |
-
-
-
-
-
- {L_AVATAR_GALLERY} |
-
-
- |
- |
-
-
-
-
- |
- |
-
-
-
+
+
+ {L_AVATAR_FEATURES_DISABLED} |
+
+
+
+ {L_AVATAR_SELECT} |
+
+
+ {L_AVATAR_TYPE}{L_COLON} |
+
+ |
+
+
+
+ {avatar_drivers.L_EXPLAIN} |
+
+
+ {avatar_drivers.OUTPUT} |
+
+
-
+ | {S_HIDDEN_FIELDS}
|
+
+
{L_GROUP_MEMBERS}
diff --git a/phpBB/styles/subsilver2/template/ucp_profile_avatar.html b/phpBB/styles/subsilver2/template/ucp_profile_avatar.html
index 160f8a2399..4c7458e940 100644
--- a/phpBB/styles/subsilver2/template/ucp_profile_avatar.html
+++ b/phpBB/styles/subsilver2/template/ucp_profile_avatar.html
@@ -12,7 +12,7 @@
{L_CURRENT_IMAGE}{L_COLON} {L_AVATAR_EXPLAIN} |
- {AVATAR}
{L_DELETE_AVATAR}
+ {AVATAR}
{L_DELETE_AVATAR}
|
@@ -21,67 +21,33 @@
{L_AVATAR_FEATURES_DISABLED} |
-
-
- {L_UPLOAD_AVATAR_FILE}{L_COLON} |
- |
+
+ {L_AVATAR_SELECT} |
-
-
-
- {L_UPLOAD_AVATAR_URL}{L_COLON} {L_UPLOAD_AVATAR_URL_EXPLAIN} |
- |
+
+ {L_AVATAR_TYPE}{L_COLON} |
+
+ |
-
-
-
- {L_LINK_REMOTE_AVATAR}{L_COLON} {L_LINK_REMOTE_AVATAR_EXPLAIN} |
- |
+
+
+ {avatar_drivers.L_EXPLAIN} |
-
- {L_LINK_REMOTE_SIZE}{L_COLON} {L_LINK_REMOTE_SIZE_EXPLAIN} |
- {L_PIXEL} × {L_PIXEL} |
+
+ {avatar_drivers.OUTPUT} |
-
-
-
- {L_AVATAR_GALLERY}{L_COLON} |
- {L_DISPLAY_GALLERY} |
-
-
+
-
-
- {L_AVATAR_GALLERY} |
-
-
- {L_AVATAR_CATEGORY}{L_COLON} |
-
-
-
-
- |
-
-
-
-
{S_HIDDEN_FIELDS} |
-
+
+
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index bd2c7bea77..59ef7bbc80 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -1083,7 +1083,7 @@ while ($row = $db->sql_fetchrow($result))
'sig_bbcode_bitfield' => '',
'online' => false,
- 'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '',
+ 'avatar' => ($user->optionget('viewavatars')) ? phpbb_get_user_avatar($row) : '',
'rank_title' => '',
'rank_image' => '',
'rank_image_src' => '',
@@ -1149,7 +1149,7 @@ while ($row = $db->sql_fetchrow($result))
'viewonline' => $row['user_allow_viewonline'],
'allow_pm' => $row['user_allow_pm'],
- 'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '',
+ 'avatar' => ($user->optionget('viewavatars')) ? phpbb_get_user_avatar($row) : '',
'age' => '',
'rank_title' => '',
diff --git a/tests/avatar/driver/barfoo.php b/tests/avatar/driver/barfoo.php
new file mode 100644
index 0000000000..0b701a4d70
--- /dev/null
+++ b/tests/avatar/driver/barfoo.php
@@ -0,0 +1,19 @@
+phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $this->phpbb_container->expects($this->any())
+ ->method('get')
+ ->with('avatar.driver.foobar')->will($this->returnValue('avatar.driver.foobar'));
+
+ // Prepare dependencies for avatar manager and driver
+ $config = new phpbb_config(array());
+ $request = $this->getMock('phpbb_request');
+ $cache = $this->getMock('phpbb_cache_driver_interface');
+
+ $this->avatar_foobar = $this->getMock('phpbb_avatar_driver_foobar', array('get_name'), array($config, $phpbb_root_path, $phpEx, $cache));
+ $this->avatar_foobar->expects($this->any())
+ ->method('get_name')
+ ->will($this->returnValue('avatar.driver.foobar'));
+ $this->avatar_barfoo = $this->getMock('phpbb_avatar_driver_barfoo', array('get_name'));
+ $this->avatar_barfoo->expects($this->any())
+ ->method('get_name')
+ ->will($this->returnValue('avatar.driver.barfoo'));
+
+ $avatar_drivers = array($this->avatar_foobar, $this->avatar_barfoo);
+
+ $config['allow_avatar_' . get_class($this->avatar_foobar)] = true;
+ $config['allow_avatar_' . get_class($this->avatar_barfoo)] = false;
+
+ // Set up avatar manager
+ $this->manager = new phpbb_avatar_manager($config, $avatar_drivers, $this->phpbb_container);
+ }
+
+ public function test_get_driver()
+ {
+ $driver = $this->manager->get_driver('avatar.driver.foobar', false);
+ $this->assertEquals('avatar.driver.foobar', $driver);
+
+ $driver = $this->manager->get_driver('avatar.driver.foo_wrong', false);
+ $this->assertNull($driver);
+
+ $driver = $this->manager->get_driver('avatar.driver.foobar');
+ $this->assertEquals('avatar.driver.foobar', $driver);
+
+ $driver = $this->manager->get_driver('avatar.driver.foo_wrong');
+ $this->assertNull($driver);
+ }
+
+ public function test_get_all_drivers()
+ {
+ $drivers = $this->manager->get_all_drivers();
+ $this->assertArrayHasKey('avatar.driver.foobar', $drivers);
+ $this->assertArrayHasKey('avatar.driver.barfoo', $drivers);
+ $this->assertEquals('avatar.driver.foobar', $drivers['avatar.driver.foobar']);
+ $this->assertEquals('avatar.driver.barfoo', $drivers['avatar.driver.barfoo']);
+ }
+
+ public function test_get_enabled_drivers()
+ {
+ $drivers = $this->manager->get_enabled_drivers();
+ $this->assertArrayHasKey('avatar.driver.foobar', $drivers);
+ $this->assertArrayNotHasKey('avatar.driver.barfoo', $drivers);
+ $this->assertEquals('avatar.driver.foobar', $drivers['avatar.driver.foobar']);
+ }
+
+ public function test_get_avatar_settings()
+ {
+ $avatar_settings = $this->manager->get_avatar_settings($this->avatar_foobar);
+
+ $expected_settings = array(
+ 'allow_avatar_' . get_class($this->avatar_foobar) => array('lang' => 'ALLOW_' . strtoupper(get_class($this->avatar_foobar)), 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
+ );
+
+ $this->assertEquals($expected_settings, $avatar_settings);
+ }
+}