summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/Controller/Project.php29
-rw-r--r--app/Model/Project.php26
-rw-r--r--app/Model/ProjectPermission.php16
-rw-r--r--app/Template/project/index.php59
4 files changed, 77 insertions, 53 deletions
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.')'
)));
diff --git a/app/Model/Project.php b/app/Model/Project.php
index f802e4ed..dbb9db1b 100644
--- a/app/Model/Project.php
+++ b/app/Model/Project.php
@@ -98,24 +98,22 @@ class Project extends Base
* Get all projects
*
* @access public
- * @param bool $filter_permissions If true, remove projects not allowed for the current user
* @return array
*/
- public function getAll($filter_permissions = false)
+ public function getAll()
{
- $projects = $this->db->table(self::TABLE)->asc('name')->findAll();
-
- if ($filter_permissions) {
-
- foreach ($projects as $key => $project) {
-
- if (! $this->projectPermission->isUserAllowed($project['id'], $this->userSession->getId())) {
- unset($projects[$key]);
- }
- }
- }
+ return $this->db->table(self::TABLE)->asc('name')->findAll();
+ }
- return $projects;
+ /**
+ * Get all project ids
+ *
+ * @access public
+ * @return array
+ */
+ public function getAllIds()
+ {
+ return $this->db->table(self::TABLE)->asc('name')->findAllByColumn('id');
}
/**
diff --git a/app/Model/ProjectPermission.php b/app/Model/ProjectPermission.php
index 352677d9..fb6316b6 100644
--- a/app/Model/ProjectPermission.php
+++ b/app/Model/ProjectPermission.php
@@ -322,6 +322,22 @@ class ProjectPermission extends Base
}
/**
+ * Return a list of project ids where the user is member
+ *
+ * @access public
+ * @param integer $user_id User id
+ * @return []integer
+ */
+ public function getMemberProjectIds($user_id)
+ {
+ return $this->db
+ ->table(Project::TABLE)
+ ->eq('user_id', $user_id)
+ ->join(self::TABLE, 'project_id', 'id')
+ ->findAllByColumn('projects.id');
+ }
+
+ /**
* Return a list of active projects where the user is member
*
* @access public
diff --git a/app/Template/project/index.php b/app/Template/project/index.php
index 58c520d1..a36a9ce1 100644
--- a/app/Template/project/index.php
+++ b/app/Template/project/index.php
@@ -8,15 +8,31 @@
</ul>
</div>
<section>
- <?php if (empty($active_projects) && empty($inactive_projects)): ?>
- <p class="alert"><?= t('No project') ?></p>
- <?php else: ?>
+ <?php if ($paginator->isEmpty()): ?>
+ <p class="alert"><?= t('No project') ?></p>
+ <?php else: ?>
+ <table class="table-fixed">
+ <tr>
+ <th class="column-8"><?= $paginator->order(t('Id'), 'id') ?></th>
+ <th class="column-8"><?= $paginator->order(t('Status'), 'is_active') ?></th>
+ <th class="column-20"><?= $paginator->order(t('Project'), 'name') ?></th>
+ <th><?= t('Columns') ?></th>
+ </tr>
+ <?php foreach ($paginator->getCollection() as $project): ?>
+ <tr>
+ <td>
+ <?= $this->a('#'.$project['id'], 'board', 'show', array('project_id' => $project['id']), false, 'dashboard-table-link') ?>
+ </td>
+ <td>
+ <?php if ($project['is_active']): ?>
+ <?= t('Active') ?>
+ <?php else: ?>
+ <?= t('Inactive') ?>
+ <?php endif ?>
+ </td>
+ <td>
+ <?= $this->a('<i class="fa fa-table"></i>', 'board', 'show', array('project_id' => $project['id']), false, 'dashboard-table-link', t('Board')) ?>&nbsp;
- <?php if (! empty($active_projects)): ?>
- <h3><?= t('Active projects') ?></h3>
- <ul class="project-listing">
- <?php foreach ($active_projects as $project): ?>
- <li>
<?php if ($project['is_public']): ?>
<i class="fa fa-share-alt fa-fw"></i>
<?php endif ?>
@@ -24,25 +40,18 @@
<i class="fa fa-lock fa-fw"></i>
<?php endif ?>
<?= $this->a($this->e($project['name']), 'project', 'show', array('project_id' => $project['id'])) ?>
- </li>
+ </td>
+ <td class="dashboard-project-stats">
+ <?php foreach ($project['columns'] as $column): ?>
+ <strong title="<?= t('Task count') ?>"><?= $column['nb_tasks'] ?></strong>
+ <span><?= $this->e($column['title']) ?></span>
+ <?php endforeach ?>
+ </td>
+ </tr>
<?php endforeach ?>
- </ul>
- <?php endif ?>
+ </table>
- <?php if (! empty($inactive_projects)): ?>
- <h3><?= t('Inactive projects') ?></h3>
- <ul class="project-listing">
- <?php foreach ($inactive_projects as $project): ?>
- <li>
- <?php if ($project['is_private']): ?>
- <i class="fa fa-lock"></i>
- <?php endif ?>
- <?= $this->a($this->e($project['name']), 'project', 'show', array('project_id' => $project['id'])) ?>
- </li>
- <?php endforeach ?>
- </ul>
+ <?= $paginator ?>
<?php endif ?>
-
- <?php endif ?>
</section>
</section> \ No newline at end of file