summaryrefslogtreecommitdiff
path: root/app/Controller/UserListController.php
blob: 580c853cf81c45340f5cf8798a7374ca478b40cc (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
<?php

namespace Kanboard\Controller;

use Kanboard\Filter\UserNameFilter;

/**
 * Class User List Controller
 *
 * @package Kanboard\Controller
 * @author  Frederic Guillot
 */
class UserListController extends BaseController
{
    /**
     * List all users
     *
     * @access public
     */
    public function show()
    {
        $paginator = $this->userPagination->getListingPaginator();

        $this->response->html($this->helper->layout->app('user_list/listing', array(
            'title' => t('Users').' ('.$paginator->getTotal().')',
            'paginator' => $paginator,
        )));
    }

    /**
     * Search in users
     *
     * @access public
     */
    public function search()
    {
        $search = urldecode($this->request->getStringParam('search'));
        $paginator = $this->userPagination->getListingPaginator();

        if ($search !== '' && ! $paginator->isEmpty()) {

            $paginator = $paginator
                ->setUrl('UserListController', 'search', array('search' => $search))
                ->setQuery($this->userQuery
                    ->withFilter(new UserNameFilter($search))
                    ->getQuery()
                )
                ->calculate();
        }

        $this->response->html($this->helper->layout->app('user_list/listing', array(
            'title' => t('Users').' ('.$paginator->getTotal().')',
            'values' => array(
                'search' => $search,
            ),
            'paginator' => $paginator
        )));
    }

}