diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-03-26 14:43:41 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-03-26 14:43:41 -0400 |
commit | 820c929ab38273c80d0930e2e6140dd7676ba4df (patch) | |
tree | 3944047e41d14077f7e5e8c0d50856b360a22567 /app/User | |
parent | e71f37238c82f01cd02d6d7343b42328d9603d14 (diff) |
Added avatar image upload
Diffstat (limited to 'app/User')
-rw-r--r-- | app/User/Avatar/AvatarFileProvider.php | 42 | ||||
-rw-r--r-- | app/User/Avatar/GravatarProvider.php | 5 | ||||
-rw-r--r-- | app/User/Avatar/LetterAvatarProvider.php | 5 |
3 files changed, 48 insertions, 4 deletions
diff --git a/app/User/Avatar/AvatarFileProvider.php b/app/User/Avatar/AvatarFileProvider.php new file mode 100644 index 00000000..87a42c07 --- /dev/null +++ b/app/User/Avatar/AvatarFileProvider.php @@ -0,0 +1,42 @@ +<?php + +namespace Kanboard\User\Avatar; + +use Kanboard\Core\Base; +use Kanboard\Core\User\Avatar\AvatarProviderInterface; + +/** + * Avatar Local Image File Provider + * + * @package avatar + * @author Frederic Guillot + */ +class AvatarFileProvider extends Base implements AvatarProviderInterface +{ + /** + * Render avatar html + * + * @access public + * @param array $user + * @param int $size + * @return string + */ + public function render(array $user, $size) + { + $url = $this->helper->url->href('AvatarFile', 'show', array('user_id' => $user['id'], 'size' => $size)); + $title = $this->helper->text->e($user['name'] ?: $user['username']); + return '<img src="' . $url . '" alt="' . $title . '" title="' . $title . '">'; + } + + /** + * Determine if the provider is active + * + * @access public + * @param array $user + * @return boolean + */ + public function isActive(array $user) + { + return !empty($user['avatar_path']); + } +} diff --git a/app/User/Avatar/GravatarProvider.php b/app/User/Avatar/GravatarProvider.php index 7a719734..87ca51b1 100644 --- a/app/User/Avatar/GravatarProvider.php +++ b/app/User/Avatar/GravatarProvider.php @@ -17,8 +17,9 @@ class GravatarProvider extends Base implements AvatarProviderInterface * Render avatar html * * @access public - * @param array $user - * @param int $size + * @param array $user + * @param int $size + * @return string */ public function render(array $user, $size) { diff --git a/app/User/Avatar/LetterAvatarProvider.php b/app/User/Avatar/LetterAvatarProvider.php index 81c4586d..cf04f2a7 100644 --- a/app/User/Avatar/LetterAvatarProvider.php +++ b/app/User/Avatar/LetterAvatarProvider.php @@ -24,8 +24,9 @@ class LetterAvatarProvider extends Base implements AvatarProviderInterface * Render avatar html * * @access public - * @param array $user - * @param int $size + * @param array $user + * @param int $size + * @return string */ public function render(array $user, $size) { |