summaryrefslogtreecommitdiff
path: root/app/Helper/AvatarHelper.php
blob: c4e27ed952bbee203fa074e62732c7205234f2ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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);
    }
}