summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-01-25 11:55:12 -0500
committerFrederic Guillot <fred@kanboard.net>2015-01-25 11:55:12 -0500
commite506648cbcda0b6021cf0a3b5e2f6381d8f1d0ea (patch)
treecbb12b785f0ef33e725ef24a277fef7a682af5ff /app/Model
parent655d75a3cf154d14b10ffbf2baa42a549cf214f7 (diff)
Do not show inactive projects info on the dashboard and update picodb (merge #546)
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/Board.php10
-rw-r--r--app/Model/Category.php4
-rw-r--r--app/Model/Config.php2
-rw-r--r--app/Model/Project.php8
-rw-r--r--app/Model/ProjectPermission.php21
-rw-r--r--app/Model/SubTask.php1
-rw-r--r--app/Model/Swimlane.php10
-rw-r--r--app/Model/TaskFinder.php5
8 files changed, 40 insertions, 21 deletions
diff --git a/app/Model/Board.php b/app/Model/Board.php
index d5b83283..8dd68a80 100644
--- a/app/Model/Board.php
+++ b/app/Model/Board.php
@@ -178,7 +178,7 @@ class Board extends Base
*/
public function moveDown($project_id, $column_id)
{
- $columns = $this->db->table(self::TABLE)->eq('project_id', $project_id)->asc('position')->listing('id', 'position');
+ $columns = $this->db->hashtable(self::TABLE)->eq('project_id', $project_id)->asc('position')->getAll('id', 'position');
$positions = array_flip($columns);
if (isset($columns[$column_id]) && $columns[$column_id] < count($columns)) {
@@ -207,7 +207,7 @@ class Board extends Base
*/
public function moveUp($project_id, $column_id)
{
- $columns = $this->db->table(self::TABLE)->eq('project_id', $project_id)->asc('position')->listing('id', 'position');
+ $columns = $this->db->hashtable(self::TABLE)->eq('project_id', $project_id)->asc('position')->getAll('id', 'position');
$positions = array_flip($columns);
if (isset($columns[$column_id]) && $columns[$column_id] > 1) {
@@ -264,11 +264,11 @@ class Board extends Base
public function getColumnStats($project_id, $prepend = false)
{
$listing = $this->db
- ->table(Task::TABLE)
+ ->hashtable(Task::TABLE)
->eq('project_id', $project_id)
->eq('is_active', 1)
->groupBy('column_id')
- ->listing('column_id', 'COUNT(*) AS total');
+ ->getAll('column_id', 'COUNT(*) AS total');
return $prepend ? array(-1 => t('All columns')) + $listing : $listing;
}
@@ -295,7 +295,7 @@ class Board extends Base
*/
public function getColumnsList($project_id, $prepend = false)
{
- $listing = $this->db->table(self::TABLE)->eq('project_id', $project_id)->asc('position')->listing('id', 'title');
+ $listing = $this->db->hashtable(self::TABLE)->eq('project_id', $project_id)->asc('position')->getAll('id', 'title');
return $prepend ? array(-1 => t('All columns')) + $listing : $listing;
}
diff --git a/app/Model/Category.php b/app/Model/Category.php
index cd60e7f7..1c8ba96f 100644
--- a/app/Model/Category.php
+++ b/app/Model/Category.php
@@ -84,10 +84,10 @@ class Category extends Base
*/
public function getList($project_id, $prepend_none = true, $prepend_all = false)
{
- $listing = $this->db->table(self::TABLE)
+ $listing = $this->db->hashtable(self::TABLE)
->eq('project_id', $project_id)
->asc('name')
- ->listing('id', 'name');
+ ->getAll('id', 'name');
$prepend = array();
diff --git a/app/Model/Config.php b/app/Model/Config.php
index e6d66734..d078a00a 100644
--- a/app/Model/Config.php
+++ b/app/Model/Config.php
@@ -110,7 +110,7 @@ class Config extends Base
*/
public function getAll()
{
- return $this->db->table(self::TABLE)->listing('option', 'value');
+ return $this->db->hashtable(self::TABLE)->getAll('option', 'value');
}
/**
diff --git a/app/Model/Project.php b/app/Model/Project.php
index a9693fbb..a072a5c1 100644
--- a/app/Model/Project.php
+++ b/app/Model/Project.php
@@ -128,10 +128,10 @@ class Project extends Base
public function getList($prepend = true)
{
if ($prepend) {
- return array(t('None')) + $this->db->table(self::TABLE)->asc('name')->listing('id', 'name');
+ return array(t('None')) + $this->db->hashtable(self::TABLE)->asc('name')->getAll('id', 'name');
}
- return $this->db->table(self::TABLE)->asc('name')->listing('id', 'name');
+ return $this->db->hashtable(self::TABLE)->asc('name')->getAll('id', 'name');
}
/**
@@ -160,10 +160,10 @@ class Project extends Base
public function getListByStatus($status)
{
return $this->db
- ->table(self::TABLE)
+ ->hashtable(self::TABLE)
->asc('name')
->eq('is_active', $status)
- ->listing('id', 'name');
+ ->getAll('id', 'name');
}
/**
diff --git a/app/Model/ProjectPermission.php b/app/Model/ProjectPermission.php
index 02f3b428..352677d9 100644
--- a/app/Model/ProjectPermission.php
+++ b/app/Model/ProjectPermission.php
@@ -315,10 +315,27 @@ class ProjectPermission extends Base
public function getMemberProjects($user_id)
{
return $this->db
- ->table(Project::TABLE)
+ ->hashtable(Project::TABLE)
+ ->eq('user_id', $user_id)
+ ->join(self::TABLE, 'project_id', 'id')
+ ->getAll('projects.id', 'name');
+ }
+
+ /**
+ * Return a list of active projects where the user is member
+ *
+ * @access public
+ * @param integer $user_id User id
+ * @return array
+ */
+ public function getActiveMemberProjects($user_id)
+ {
+ return $this->db
+ ->hashtable(Project::TABLE)
->eq('user_id', $user_id)
+ ->eq(Project::TABLE.'.is_active', Project::ACTIVE)
->join(self::TABLE, 'project_id', 'id')
- ->listing('projects.id', 'name');
+ ->getAll('projects.id', 'name');
}
/**
diff --git a/app/Model/SubTask.php b/app/Model/SubTask.php
index e5b03ab0..3fccad47 100644
--- a/app/Model/SubTask.php
+++ b/app/Model/SubTask.php
@@ -101,6 +101,7 @@ class SubTask extends Base
Project::TABLE.'.name AS project_name'
)
->eq('user_id', $user_id)
+ ->eq(Project::TABLE.'.is_active', Project::ACTIVE)
->in(SubTask::TABLE.'.status', $status)
->join(Task::TABLE, 'id', 'task_id')
->join(Project::TABLE, 'id', 'project_id', Task::TABLE)
diff --git a/app/Model/Swimlane.php b/app/Model/Swimlane.php
index 7a88cec1..71b95ae9 100644
--- a/app/Model/Swimlane.php
+++ b/app/Model/Swimlane.php
@@ -171,7 +171,7 @@ class Swimlane extends Base
$swimlanes = array_merge(
$swimlanes,
- $this->db->table(self::TABLE)->eq('project_id', $project_id)->orderBy('name', 'asc')->listing('id', 'name')
+ $this->db->hashtable(self::TABLE)->eq('project_id', $project_id)->orderBy('name', 'asc')->getAll('id', 'name')
);
return $prepend ? array(-1 => t('All swimlanes')) + $swimlanes : $swimlanes;
@@ -354,11 +354,11 @@ class Swimlane extends Base
*/
public function moveDown($project_id, $swimlane_id)
{
- $swimlanes = $this->db->table(self::TABLE)
+ $swimlanes = $this->db->hashtable(self::TABLE)
->eq('project_id', $project_id)
->eq('is_active', self::ACTIVE)
->asc('position')
- ->listing('id', 'position');
+ ->getAll('id', 'position');
$positions = array_flip($swimlanes);
@@ -388,11 +388,11 @@ class Swimlane extends Base
*/
public function moveUp($project_id, $swimlane_id)
{
- $swimlanes = $this->db->table(self::TABLE)
+ $swimlanes = $this->db->hashtable(self::TABLE)
->eq('project_id', $project_id)
->eq('is_active', self::ACTIVE)
->asc('position')
- ->listing('id', 'position');
+ ->getAll('id', 'position');
$positions = array_flip($swimlanes);
diff --git a/app/Model/TaskFinder.php b/app/Model/TaskFinder.php
index 9d517ac5..6a19eeec 100644
--- a/app/Model/TaskFinder.php
+++ b/app/Model/TaskFinder.php
@@ -62,8 +62,9 @@ class TaskFinder extends Base
'projects.name AS project_name'
)
->join(Project::TABLE, 'id', 'project_id')
- ->eq('tasks.owner_id', $user_id)
- ->eq('tasks.is_active', Task::STATUS_OPEN);
+ ->eq(Task::TABLE.'.owner_id', $user_id)
+ ->eq(Task::TABLE.'.is_active', Task::STATUS_OPEN)
+ ->eq(Project::TABLE.'.is_active', Project::ACTIVE);
}
/**