Add table/pagination to the project list

This commit is contained in:
Frederic Guillot
2015-01-31 11:21:43 -05:00
parent e1be338053
commit 9a98013736
14 changed files with 135 additions and 123 deletions

View File

@@ -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.')'
)));