From 9a98013736f1acebbb62c5fce6a10c02e32b516f Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 31 Jan 2015 11:21:43 -0500 Subject: Add table/pagination to the project list --- app/Controller/Project.php | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'app/Controller') diff --git a/app/Controller/Project.php b/app/Controller/Project.php index 4beb19ce..8178ab5f 100644 --- a/app/Controller/Project.php +++ b/app/Controller/Project.php @@ -17,24 +17,25 @@ class Project extends Base */ public function index() { - $projects = $this->project->getAll(! $this->userSession->isAdmin()); - $nb_projects = count($projects); - $active_projects = array(); - $inactive_projects = array(); - - foreach ($projects as $project) { - if ($project['is_active'] == 1) { - $active_projects[] = $project; - } - else { - $inactive_projects[] = $project; - } + if ($this->userSession->isAdmin()) { + $project_ids = $this->project->getAllIds(); + } + else { + $project_ids = $this->projectPermission->getMemberProjectIds($this->userSession->getId()); } + + $nb_projects = count($project_ids); + + $paginator = $this->paginator + ->setUrl('project', 'index') + ->setMax(20) + ->setOrder('name') + ->setQuery($this->project->getQueryColumnStats($project_ids)) + ->calculate(); $this->response->html($this->template->layout('project/index', array( 'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()), - 'active_projects' => $active_projects, - 'inactive_projects' => $inactive_projects, + 'paginator' => $paginator, 'nb_projects' => $nb_projects, 'title' => t('Projects').' ('.$nb_projects.')' ))); -- cgit v1.2.3