summaryrefslogtreecommitdiff
path: root/app/User
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-03-18 23:06:32 -0400
committerFrederic Guillot <fred@kanboard.net>2016-03-18 23:06:32 -0400
commitfa86542f90774d7a7d8f3e81ee35821ca25b7fd4 (patch)
treee6dd027dc827b18e07536414cf4fb86321763060 /app/User
parentc4c200b530e0585fafadce41f75e383ec0ff057e (diff)
Added pluggable Avatar providers
Diffstat (limited to 'app/User')
-rw-r--r--app/User/Avatar/GravatarProvider.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/app/User/Avatar/GravatarProvider.php b/app/User/Avatar/GravatarProvider.php
new file mode 100644
index 00000000..10ab4390
--- /dev/null
+++ b/app/User/Avatar/GravatarProvider.php
@@ -0,0 +1,35 @@
+<?php
+
+namespace Kanboard\User\Avatar;
+
+use Kanboard\Core\Base;
+use Kanboard\Core\User\Avatar\AvatarProviderInterface;
+
+class GravatarProvider extends Base implements AvatarProviderInterface
+{
+ /**
+ * Render avatar html
+ *
+ * @access public
+ * @param array $user
+ * @param int $size
+ */
+ public function render(array $user, $size)
+ {
+ $url = sprintf('https://www.gravatar.com/avatar/%s?s=%d', md5(strtolower($user['email'])), $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['email']) && $this->config->get('integration_gravatar') == 1;
+ }
+}