summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-01-31 11:21:43 -0500
committerFrederic Guillot <fred@kanboard.net>2015-01-31 11:21:43 -0500
commit9a98013736f1acebbb62c5fce6a10c02e32b516f (patch)
treefeff8f7ad561e3d33e585d585ce37a1158aa558f /app/Model
parente1be33805370874849d8db76f3014a145d73fb60 (diff)
Add table/pagination to the project list
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/Project.php26
-rw-r--r--app/Model/ProjectPermission.php16
2 files changed, 28 insertions, 14 deletions
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