summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Core/User/UserSession.php11
-rw-r--r--app/Helper/AvatarHelper.php64
-rw-r--r--app/Helper/UserHelper.php23
-rw-r--r--app/ServiceProvider/HelperProvider.php1
-rw-r--r--app/Template/comment/show.php2
-rw-r--r--app/Template/event/events.php2
-rw-r--r--app/Template/header.php2
7 files changed, 80 insertions, 25 deletions
diff --git a/app/Core/User/UserSession.php b/app/Core/User/UserSession.php
index 534e5192..e494e7b4 100644
--- a/app/Core/User/UserSession.php
+++ b/app/Core/User/UserSession.php
@@ -36,6 +36,17 @@ class UserSession extends Base
}
/**
+ * Get user properties
+ *
+ * @access public
+ * @return array
+ */
+ public function getAll()
+ {
+ return $this->sessionStorage->user;
+ }
+
+ /**
* Get user application role
*
* @access public
diff --git a/app/Helper/AvatarHelper.php b/app/Helper/AvatarHelper.php
new file mode 100644
index 00000000..c4e27ed9
--- /dev/null
+++ b/app/Helper/AvatarHelper.php
@@ -0,0 +1,64 @@
+<?php
+
+namespace Kanboard\Helper;
+
+use Kanboard\Core\Base;
+
+/**
+ * Avatar Helper
+ *
+ * @package helper
+ * @author Frederic Guillot
+ */
+class AvatarHelper extends Base
+{
+ /**
+ * Render user avatar
+ *
+ * @access public
+ * @param string $user_id
+ * @param string $username
+ * @param string $name
+ * @param string $email
+ * @param string $css
+ * @param int $size
+ * @return string
+ */
+ public function render($user_id, $username, $name, $email, $css = 'avatar-left', $size = 48)
+ {
+ if (empty($user_id) && empty($username)) {
+ $html = $this->avatarManager->renderDefault($size);
+ } else {
+ $html = $this->avatarManager->render($user_id, $username, $name, $email, $size);
+ }
+
+ return '<div class="avatar avatar-'.$size.' '.$css.'">'.$html.'</div>';
+ }
+
+ /**
+ * Render small user avatar
+ *
+ * @access public
+ * @param string $user_id
+ * @param string $username
+ * @param string $name
+ * @param string $email
+ * @return string
+ */
+ public function small($user_id, $username, $name, $email, $css = '')
+ {
+ return $this->render($user_id, $username, $name, $email, $css, 20);
+ }
+
+ /**
+ * Get a small avatar for the current user
+ *
+ * @access public
+ * @return string
+ */
+ public function currentUserSmall($css = '')
+ {
+ $user = $this->userSession->getAll();
+ return $this->small($user['id'], $user['username'], $user['name'], $user['email'], $css);
+ }
+}
diff --git a/app/Helper/UserHelper.php b/app/Helper/UserHelper.php
index c60c35c2..ee7d8ba5 100644
--- a/app/Helper/UserHelper.php
+++ b/app/Helper/UserHelper.php
@@ -156,27 +156,6 @@ class UserHelper extends Base
*/
public function getFullname(array $user = array())
{
- return $this->user->getFullname(empty($user) ? $this->sessionStorage->user : $user);
- }
-
- /**
- * Display avatar
- *
- * @access public
- * @param string $user_id
- * @param string $username
- * @param string $name
- * @param string $email
- * @return string
- */
- public function avatar($user_id, $username, $name, $email)
- {
- if (empty($user_id) && empty($username)) {
- $html = $this->avatarManager->renderDefault(48);
- } else {
- $html = $this->avatarManager->render($user_id, $username, $name, $email, 48);
- }
-
- return '<div class="avatar">'.$html.'</div>';
+ return $this->user->getFullname(empty($user) ? $this->userSession->getAll() : $user);
}
}
diff --git a/app/ServiceProvider/HelperProvider.php b/app/ServiceProvider/HelperProvider.php
index 42a0c85e..37be5a05 100644
--- a/app/ServiceProvider/HelperProvider.php
+++ b/app/ServiceProvider/HelperProvider.php
@@ -26,6 +26,7 @@ class HelperProvider implements ServiceProviderInterface
$container['helper']->register('text', '\Kanboard\Helper\TextHelper');
$container['helper']->register('url', '\Kanboard\Helper\UrlHelper');
$container['helper']->register('user', '\Kanboard\Helper\UserHelper');
+ $container['helper']->register('avatar', '\Kanboard\Helper\AvatarHelper');
$container['template'] = new Template($container['helper']);
diff --git a/app/Template/comment/show.php b/app/Template/comment/show.php
index ebf4142b..ce456c5d 100644
--- a/app/Template/comment/show.php
+++ b/app/Template/comment/show.php
@@ -1,6 +1,6 @@
<div class="comment <?= isset($preview) ? 'comment-preview' : '' ?>" id="comment-<?= $comment['id'] ?>">
- <?= $this->user->avatar($comment['user_id'], $comment['username'], $comment['name'], $comment['email']) ?>
+ <?= $this->avatar->render($comment['user_id'], $comment['username'], $comment['name'], $comment['email']) ?>
<div class="comment-title">
<?php if (! empty($comment['username'])): ?>
diff --git a/app/Template/event/events.php b/app/Template/event/events.php
index 097da318..6bef8df4 100644
--- a/app/Template/event/events.php
+++ b/app/Template/event/events.php
@@ -17,7 +17,7 @@
&nbsp;<?= $this->dt->datetime($event['date_creation']) ?>
</p>
<div class="activity-content">
- <?= $this->user->avatar(
+ <?= $this->avatar->render(
$event['creator_id'],
$event['author_username'],
$event['author_name'],
diff --git a/app/Template/header.php b/app/Template/header.php
index d891118c..a8fd47f2 100644
--- a/app/Template/header.php
+++ b/app/Template/header.php
@@ -58,7 +58,7 @@
<?php endif ?>
<div class="dropdown">
- <a href="#" class="dropdown-menu dropdown-menu-link-icon"><i class="fa fa-user fa-fw"></i><i class="fa fa-caret-down"></i></a>
+ <a href="#" class="dropdown-menu dropdown-menu-link-icon"><?= $this->avatar->currentUserSmall('avatar-inline') ?><i class="fa fa-caret-down"></i></a>
<ul>
<li class="no-hover"><strong><?= $this->text->e($this->user->getFullname()) ?></strong></li>
<li>