summaryrefslogtreecommitdiff
path: root/plugins/Customizer/Helper/DynamicAvatar.php
blob: cf7ab83fcb03e34fab5a7e7dfdaa800ed1cea5cf (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
<?php

namespace Kanboard\Plugin\Customizer\Helper;

use Kanboard\Helper\AvatarHelper;
use Kanboard\Core\Base;
/**
 * Avatar Helper
 *
 * @package helper
 * @author  Craig Crosby
 */
class DynamicAvatar extends AvatarHelper
{
    
    public function dynamicRender($user_id, $username, $name, $email, $avatar_path, $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, $avatar_path, $size);
        }
        return '<div id="'.$css.'" class="avatar avatar-dyn '.$css.'">'.$html.'</div>';
    }

    public function dynamic($user_id, $username, $name, $email, $avatar_path, $css = '', $size)
    {
        return $this->dynamicRender($user_id, $username, $name, $email, $avatar_path, $css, $size);
    }

    public function currentUserDynamic($css = '')
    {
        $user = $this->userSession->getAll();
        return $this->dynamic($user['id'], $user['username'], $user['name'], $user['email'], $user['avatar_path'], $css, $this->configModel->get('av_size', '20'));
    }
    
    public function boardDynamicRender($user_id, $username, $name, $email, $avatar_path, $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, $avatar_path, $size);
        }
        return '<div id="'.$css.'" class="avatar avatar-bdyn '.$css.'">'.$html.'</div>';
    }

    public function boardDynamic($user_id, $username, $name, $email, $avatar_path, $css = '', $size)
    {
        return $this->boardDynamicRender($user_id, $username, $name, $email, $avatar_path, $css, $size);
    }
    
    public function boardCurrentUserDynamic($css = '')
    {
        $user = $this->userSession->getAll();
        return $this->boardDynamic($user['id'], $user['username'], $user['name'], $user['email'], $user['avatar_path'], $css, $this->configModel->get('b_av_size', '20'));
    }


 }