summaryrefslogtreecommitdiff
path: root/app/User/Avatar/AvatarFileProvider.php
blob: 87a42c07e02b0c5b54262c98838d92991fa74f08 (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
<?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']);
    }
}