summaryrefslogtreecommitdiff
path: root/app/User
diff options
context:
space:
mode:
authorImbasaur <yarrusg@gmail.com>2016-04-13 17:05:59 +0200
committerImbasaur <yarrusg@gmail.com>2016-04-13 17:05:59 +0200
commit99f275e5bb033cca33eee87b0e914645730f13d1 (patch)
treead845419d56304f2bf014744f0878186f7155a3c /app/User
parent13d5bd8e48bd6c0109d1272da58a8879bf9a6737 (diff)
parentcd5bf9d4d214ec9282b706c26bb27cabf150ee63 (diff)
Merge pull request #1 from fguillot/master
Diffstat (limited to 'app/User')
-rw-r--r--app/User/Avatar/AvatarFileProvider.php42
-rw-r--r--app/User/Avatar/GravatarProvider.php5
-rw-r--r--app/User/Avatar/LetterAvatarProvider.php7
3 files changed, 49 insertions, 5 deletions
diff --git a/app/User/Avatar/AvatarFileProvider.php b/app/User/Avatar/AvatarFileProvider.php
new file mode 100644
index 00000000..eea565f0
--- /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', 'image', 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..f9659e61 100644
--- a/app/User/Avatar/LetterAvatarProvider.php
+++ b/app/User/Avatar/LetterAvatarProvider.php
@@ -24,13 +24,14 @@ 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)
{
$initials = $this->helper->user->getInitials($user['name'] ?: $user['username']);
- $rgb = $this->getBackgroundColor($initials);
+ $rgb = $this->getBackgroundColor($user['name'] ?: $user['username']);
return sprintf(
'<div class="avatar-letter" style="background-color: rgb(%d, %d, %d)" title="%s">%s</div>',