diff options
| author | Cullen Walsh <ckwalsh@phpbb.com> | 2011-04-17 19:29:48 -0700 |
|---|---|---|
| committer | Cullen Walsh <ckwalsh@cullenwalsh.com> | 2012-03-18 22:19:16 +0000 |
| commit | 16bb0f00b79102aed7da984cbca8a4b1741c62af (patch) | |
| tree | 61fab4bddc21cb73bc6ae16426cdccbbc71ea2fc /phpBB/includes | |
| parent | 1bd3d40121960c203d0dabb4b1a04c16c564b6f1 (diff) | |
| download | forums-16bb0f00b79102aed7da984cbca8a4b1741c62af.tar forums-16bb0f00b79102aed7da984cbca8a4b1741c62af.tar.gz forums-16bb0f00b79102aed7da984cbca8a4b1741c62af.tar.bz2 forums-16bb0f00b79102aed7da984cbca8a4b1741c62af.tar.xz forums-16bb0f00b79102aed7da984cbca8a4b1741c62af.zip | |
[feature/avatars] Add drivers for standard avatar types
Adding drivers for gallery, uploaded, and remote avatars. These may
be used as examples for others to develop their own avatar drivers.
PHPBB3-10018
Diffstat (limited to 'phpBB/includes')
| -rw-r--r-- | phpBB/includes/avatar/driver/gallery.php | 50 | ||||
| -rw-r--r-- | phpBB/includes/avatar/driver/remote.php | 50 | ||||
| -rw-r--r-- | phpBB/includes/avatar/driver/upload.php | 50 |
3 files changed, 150 insertions, 0 deletions
diff --git a/phpBB/includes/avatar/driver/gallery.php b/phpBB/includes/avatar/driver/gallery.php new file mode 100644 index 0000000000..b937332b2d --- /dev/null +++ b/phpBB/includes/avatar/driver/gallery.php @@ -0,0 +1,50 @@ +<?php +/** +* +* @package avatar +* @copyright (c) 2005, 2009 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* Handles avatars selected from the board gallery +* @package avatars +*/ +class phpbb_avatar_driver_gallery extends phpbb_avatar_driver +{ + /** + * Get the avatar url and dimensions + * + * @param $ignore_config Whether $user or global avatar visibility settings + * should be ignored + * @return array Avatar data + */ + public function get_data($user_row, $ignore_config = false) + { + if ($ignore_config || $this->config['allow_avatar_local']) + { + return array( + 'src' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $user_row['user_avatar'], + 'width' => $user_row['user_avatar_width'], + 'height' => $user_row['user_avatar_height'], + ); + } + else + { + return array( + 'src' => '', + 'width' => 0, + 'height' => 0, + ); + } + } +} diff --git a/phpBB/includes/avatar/driver/remote.php b/phpBB/includes/avatar/driver/remote.php new file mode 100644 index 0000000000..dbd567124d --- /dev/null +++ b/phpBB/includes/avatar/driver/remote.php @@ -0,0 +1,50 @@ +<?php +/** +* +* @package avatar +* @copyright (c) 2005, 2009 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* Handles avatars hosted remotely +* @package avatars +*/ +class phpbb_avatar_driver_remote extends phpbb_avatar_driver +{ + /** + * Get the avatar url and dimensions + * + * @param $ignore_config Whether $user or global avatar visibility settings + * should be ignored + * @return array Avatar data + */ + public function get_data($user_row, $ignore_config = false) + { + if ($ignore_config || $this->config['allow_avatar_remote']) + { + return array( + 'src' => $user_row['user_avatar'], + 'width' => $user_row['user_avatar_width'], + 'height' => $user_row['user_avatar_height'], + ); + } + else + { + return array( + 'src' => '', + 'width' => 0, + 'height' => 0, + ); + } + } +} diff --git a/phpBB/includes/avatar/driver/upload.php b/phpBB/includes/avatar/driver/upload.php new file mode 100644 index 0000000000..777c9c2060 --- /dev/null +++ b/phpBB/includes/avatar/driver/upload.php @@ -0,0 +1,50 @@ +<?php +/** +* +* @package avatar +* @copyright (c) 2005, 2009 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* Handles avatars uploaded to the board +* @package avatars +*/ +class phpbb_avatar_driver_upload extends phpbb_avatar_driver +{ + /** + * Get the avatar url and dimensions + * + * @param $ignore_config Whether $user or global avatar visibility settings + * should be ignored + * @return array Avatar data + */ + public function get_data($user_row, $ignore_config = false) + { + if (ignore_config || $this->config['allow_avatar_upload']) + { + return array( + 'src' => $this->phpbb_root_path . 'download/file.' . $this->php_ext . '?avatar=' . $user_row['user_avatar'], + 'width' => $user_row['user_avatar_width'], + 'height' => $user_row['user_avatar_height'], + ); + } + else + { + return array( + 'src' => '', + 'width' => 0, + 'height' => 0, + ); + } + } +} |
