summaryrefslogtreecommitdiff
path: root/app/Pagination/DashboardPagination.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-03-12 21:36:52 -0400
committerFrederic Guillot <fred@kanboard.net>2017-03-12 21:36:52 -0400
commit9b34631135f29480dda3ed2df463fbb5aab7c9e4 (patch)
tree46da2f342a440cc699b7aa9c61bd18d0d2ea01f5 /app/Pagination/DashboardPagination.php
parentf6b42eb8024b7db959f6d75118b3de0f96301262 (diff)
Simplify dashboard to use new tasks list view
Diffstat (limited to 'app/Pagination/DashboardPagination.php')
-rw-r--r--app/Pagination/DashboardPagination.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/app/Pagination/DashboardPagination.php b/app/Pagination/DashboardPagination.php
new file mode 100644
index 00000000..b8fc4434
--- /dev/null
+++ b/app/Pagination/DashboardPagination.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace Kanboard\Pagination;
+
+use Kanboard\Core\Base;
+use Kanboard\Model\ProjectModel;
+use Kanboard\Model\TaskModel;
+
+/**
+ * Class DashboardPagination
+ *
+ * @package Kanboard\Pagination
+ * @author Frederic Guillot
+ */
+class DashboardPagination extends Base
+{
+ /**
+ * Get user listing pagination
+ *
+ * @access public
+ * @param integer $userId
+ * @return array
+ */
+ public function getOverview($userId)
+ {
+ $paginators = array();
+ $projects = $this->projectUserRoleModel->getActiveProjectsByUser($userId);
+
+ foreach ($projects as $projectId => $projectName) {
+ $paginator = $this->paginator
+ ->setUrl('DashboardController', 'show', array('user_id' => $userId))
+ ->setMax(50)
+ ->setOrder(TaskModel::TABLE.'.priority')
+ ->setDirection('DESC')
+ ->setFormatter($this->taskListSubtaskAssigneeFormatter->withUserId($userId))
+ ->setQuery($this->taskFinderModel->getUserQuery($userId)->eq(ProjectModel::TABLE.'.id', $projectId))
+ ->calculate();
+
+ if ($paginator->getTotal() > 0) {
+ $paginators[] = array(
+ 'project_id' => $projectId,
+ 'project_name' => $projectName,
+ 'paginator' => $paginator,
+ );
+ }
+ }
+
+ return $paginators;
+ }
+}