summaryrefslogtreecommitdiff
path: root/app/Model/TaskFilter.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-07-18 11:42:54 -0400
committerFrederic Guillot <fred@kanboard.net>2015-07-18 11:42:54 -0400
commit3260dfb0492ed9f18268ba0773b8ad9bee8dc747 (patch)
tree01fb8f8af51c7c0b56dda82238041eee13f03e17 /app/Model/TaskFilter.php
parentdfd79722270b4f7a6653cb130b6518dcd7bd8c95 (diff)
parent0f2d57ca5b00fb58e5b3baadb64fcd011c666ff6 (diff)
Merge pull-request #1012
Diffstat (limited to 'app/Model/TaskFilter.php')
-rw-r--r--app/Model/TaskFilter.php30
1 files changed, 29 insertions, 1 deletions
diff --git a/app/Model/TaskFilter.php b/app/Model/TaskFilter.php
index 822397ec..d7d5148b 100644
--- a/app/Model/TaskFilter.php
+++ b/app/Model/TaskFilter.php
@@ -340,10 +340,11 @@ class TaskFilter extends Base
$this->query->beginOr();
foreach ($values as $assignee) {
-
+ $subtaskQuery = $this->buildSubtaskQuery();
switch ($assignee) {
case 'me':
$this->query->eq(Task::TABLE.'.owner_id', $this->userSession->getId());
+ $subtaskQuery->eq(Subtask::TABLE.'.user_id',$this->userSession->getId() );
break;
case 'nobody':
$this->query->eq(Task::TABLE.'.owner_id', 0);
@@ -351,6 +352,14 @@ class TaskFilter extends Base
default:
$this->query->ilike(User::TABLE.'.username', '%'.$assignee.'%');
$this->query->ilike(User::TABLE.'.name', '%'.$assignee.'%');
+ $subtaskQuery->beginOr();
+ $subtaskQuery->ilike(User::TABLE.'.username', '%'.$assignee.'%');
+ $subtaskQuery->ilike(User::TABLE.'.name', '%'.$assignee.'%');
+ $subtaskQuery->closeOr();
+ }
+ if ($assignee != 'nobody'){
+ $subtasks = $subtaskQuery->findAll();
+ $this->addTasksWithFoundSubtask($subtasks);
}
}
@@ -787,4 +796,23 @@ class TaskFilter extends Base
return $this;
}
+
+ private function buildSubtaskQuery(){
+ return $this->db->table(Subtask::TABLE)
+ ->columns(
+ Subtask::TABLE.'.user_id',
+ Subtask::TABLE.'.task_id',
+ User::TABLE.'.name',
+ User::TABLE.'.username')
+ ->join(User::TABLE, 'id', 'user_id', Subtask::TABLE)
+ ->neq(Subtask::TABLE.'.status', Subtask::STATUS_DONE);
+
+ }
+
+ private function addTasksWithFoundSubtask($subtasks) {
+ foreach ($subtasks as $subtask) {
+ $this->query->eq(Task::TABLE.'.id',$subtask['task_id']);
+ }
+ }
+
}