summaryrefslogtreecommitdiff
path: root/app/Controller/ProjectListController.php
blob: 95ff5d91de20fb48a3500f17bc518b9cf1239aa3 (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
<?php

namespace Kanboard\Controller;

/**
 * Class ProjectListController
 *
 * @package Kanboard\Controller
 * @author  Frederic Guillot
 */
class ProjectListController extends BaseController
{
    /**
     * List of projects
     *
     * @access public
     */
    public function show()
    {
        if ($this->userSession->isAdmin()) {
            $projectIds = $this->projectModel->getAllIds();
        } else {
            $projectIds = $this->projectPermissionModel->getProjectIds($this->userSession->getId());
        }

        $paginator = $this->paginator
            ->setUrl('ProjectListController', 'show')
            ->setMax(20)
            ->setOrder('name')
            ->setQuery($this->projectModel->getQueryByProjectIds($projectIds))
            ->calculate();

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