summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Controller/App.php2
-rw-r--r--app/Controller/Task.php4
-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
-rw-r--r--composer.json2
-rw-r--r--composer.lock12
12 files changed, 50 insertions, 31 deletions
diff --git a/app/Controller/App.php b/app/Controller/App.php
index cf8d606f..6eab2bcd 100644
--- a/app/Controller/App.php
+++ b/app/Controller/App.php
@@ -31,7 +31,7 @@ class App extends Base
{
$status = array(SubTaskModel::STATUS_TODO, SubTaskModel::STATUS_INPROGRESS);
$user_id = $this->userSession->getId();
- $projects = $this->projectPermission->getMemberProjects($user_id);
+ $projects = $this->projectPermission->getActiveMemberProjects($user_id);
$project_ids = array_keys($projects);
$task_paginator = $this->paginator
diff --git a/app/Controller/Task.php b/app/Controller/Task.php
index 7f85f36c..c25a4b9d 100644
--- a/app/Controller/Task.php
+++ b/app/Controller/Task.php
@@ -418,7 +418,7 @@ class Task extends Base
$task = $this->getTask();
$values = $task;
$errors = array();
- $projects_list = $this->projectPermission->getMemberProjects($this->userSession->getId());
+ $projects_list = $this->projectPermission->getActiveMemberProjects($this->userSession->getId());
unset($projects_list[$task['project_id']]);
@@ -457,7 +457,7 @@ class Task extends Base
$task = $this->getTask();
$values = $task;
$errors = array();
- $projects_list = $this->projectPermission->getMemberProjects($this->userSession->getId());
+ $projects_list = $this->projectPermission->getActiveMemberProjects($this->userSession->getId());
unset($projects_list[$task['project_id']]);
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);
}
/**
diff --git a/composer.json b/composer.json
index 8ae49653..537aed86 100644
--- a/composer.json
+++ b/composer.json
@@ -4,7 +4,7 @@
"fguillot/simple-validator": "0.0.1",
"swiftmailer/swiftmailer": "@stable",
"fguillot/json-rpc": "0.0.1",
- "fguillot/picodb": "0.0.1",
+ "fguillot/picodb": "0.0.2",
"erusev/parsedown": "1.1.1",
"lusitanian/oauth": "0.3.5",
"pimple/pimple": "~3.0",
diff --git a/composer.lock b/composer.lock
index 2283ee39..3091ab74 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "b20bc90f39f04bf9d6828329d56cdc75",
+ "hash": "a5f10d6c565a2a7b5b63650d550cabf2",
"packages": [
{
"name": "erusev/parsedown",
@@ -84,16 +84,16 @@
},
{
"name": "fguillot/picodb",
- "version": "v0.0.1",
+ "version": "v0.0.2",
"source": {
"type": "git",
"url": "https://github.com/fguillot/picoDb.git",
- "reference": "f36d8e0191e2fa6f033baf94bc35ec6a00798bc0"
+ "reference": "b3ef5f79e7e5e33729fdbf9c02c8a252a3d76b6b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/fguillot/picoDb/zipball/f36d8e0191e2fa6f033baf94bc35ec6a00798bc0",
- "reference": "f36d8e0191e2fa6f033baf94bc35ec6a00798bc0",
+ "url": "https://api.github.com/repos/fguillot/picoDb/zipball/b3ef5f79e7e5e33729fdbf9c02c8a252a3d76b6b",
+ "reference": "b3ef5f79e7e5e33729fdbf9c02c8a252a3d76b6b",
"shasum": ""
},
"require": {
@@ -117,7 +117,7 @@
],
"description": "Minimalist database query builder",
"homepage": "https://github.com/fguillot/picoDb",
- "time": "2015-01-18 22:35:36"
+ "time": "2015-01-25 16:20:14"
},
{
"name": "fguillot/simple-validator",