summaryrefslogtreecommitdiff
path: root/app/User/DatabaseBackendUserProvider.php
blob: 835d90beb413785385b9341bead2a55b136611f0 (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
<?php

namespace Kanboard\User;

use Kanboard\Core\Base;
use Kanboard\Core\User\UserBackendProviderInterface;
use Kanboard\Filter\UserNameFilter;
use Kanboard\Model\UserModel;

/**
 * Database Backend User Provider
 *
 * @package  Kanboard\User
 * @author   Frederic Guillot
 */
class DatabaseBackendUserProvider extends Base implements UserBackendProviderInterface
{
    /**
     * Find a group from a search query
     *
     * @access public
     * @param  string $input
     * @return DatabaseUserProvider[]
     */
    public function find($input)
    {
        $result = array();

        $users = $this->userQuery->withFilter(new UserNameFilter($input))
            ->getQuery()
            ->columns(UserModel::TABLE.'.id', UserModel::TABLE.'.username', UserModel::TABLE.'.name')
            ->eq(UserModel::TABLE.'.is_active', 1)
            ->asc(UserModel::TABLE.'.name')
            ->asc(UserModel::TABLE.'.username')
            ->findAll();

        foreach ($users as $user) {
            $result[] = new DatabaseUserProvider($user);
        }

        return $result;
    }
}