summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDzial Techniczny WMW Projekt s.c <techniczna@wmwprojekt.pl>2020-01-15 15:54:11 +0100
committerDzial Techniczny WMW Projekt s.c <techniczna@wmwprojekt.pl>2020-01-15 15:54:11 +0100
commitb6f34622b169652c57e7cabd8d11e28605f110c3 (patch)
tree39496fdf3c35177aaccb394bba8cd46d221b6426
parent3317d87addb03688a08a7fb12200b4913125dba7 (diff)
Extending extended query for tasks with possible hooks
-rw-r--r--app/Model/TaskFinderModel.php4
-rw-r--r--app/Template/task/dropdown.php7
-rw-r--r--libs/picodb/lib/PicoDb/Table.php12
-rw-r--r--plugins/Group_assign/Model/NewTaskFinderModel.php4
-rw-r--r--plugins/Group_assign/Model/OldTaskFinderModel.php4
5 files changed, 27 insertions, 4 deletions
diff --git a/app/Model/TaskFinderModel.php b/app/Model/TaskFinderModel.php
index 8e6b081a..22454e0d 100644
--- a/app/Model/TaskFinderModel.php
+++ b/app/Model/TaskFinderModel.php
@@ -77,7 +77,7 @@ class TaskFinderModel extends Base
*/
public function getExtendedQuery()
{
- return $this->db
+ $query = $this->db
->table(TaskModel::TABLE)
->columns(
'(SELECT COUNT(*) FROM '.CommentModel::TABLE.' WHERE task_id=tasks.id) AS nb_comments',
@@ -136,6 +136,8 @@ class TaskFinderModel extends Base
->join(ColumnModel::TABLE, 'id', 'column_id', TaskModel::TABLE)
->join(SwimlaneModel::TABLE, 'id', 'swimlane_id', TaskModel::TABLE)
->join(ProjectModel::TABLE, 'id', 'project_id', TaskModel::TABLE);
+ $query = $this->hook->reference('task:query:extended', $query);
+ return $query;
}
/**
diff --git a/app/Template/task/dropdown.php b/app/Template/task/dropdown.php
index cc97d1a1..e51c33e6 100644
--- a/app/Template/task/dropdown.php
+++ b/app/Template/task/dropdown.php
@@ -1,5 +1,10 @@
<div class="dropdown">
- <a href="#" class="dropdown-menu dropdown-menu-link-icon"><strong>#<?= $task['id'] ?> <i class="fa fa-caret-down"></i></strong></a>
+ <a href="#" class="dropdown-menu dropdown-menu-link-icon">
+ <strong>#<?=
+ isset($task['internal_task_id']) ?
+ ($task['internal_task_id'] . "<small>&nbsp;(" . $task['id'] . ")</small>") :
+ $task['id']
+ ?><i class="fa fa-caret-down"></i></strong></a>
<ul>
<?php if ($this->projectRole->canUpdateTask($task)): ?>
<?php if ($this->projectRole->canChangeAssignee($task) && array_key_exists('owner_id', $task) && $task['owner_id'] != $this->user->getId()): ?>
diff --git a/libs/picodb/lib/PicoDb/Table.php b/libs/picodb/lib/PicoDb/Table.php
index 404b5cbe..74b121f0 100644
--- a/libs/picodb/lib/PicoDb/Table.php
+++ b/libs/picodb/lib/PicoDb/Table.php
@@ -638,6 +638,18 @@ class Table
}
/**
+ * Add columns to the select
+ *
+ * @access public
+ * @return $this
+ */
+ public function addColumns()
+ {
+ $this->columns = array_merge($this->columns, func_get_args());
+ return $this;
+ }
+
+ /**
* Sum column
*
* @access public
diff --git a/plugins/Group_assign/Model/NewTaskFinderModel.php b/plugins/Group_assign/Model/NewTaskFinderModel.php
index b8b10916..474f6494 100644
--- a/plugins/Group_assign/Model/NewTaskFinderModel.php
+++ b/plugins/Group_assign/Model/NewTaskFinderModel.php
@@ -146,7 +146,7 @@ class NewTaskFinderModel extends Base
*/
public function getExtendedQuery()
{
- return $this->db
+ $query = $this->db
->table(TaskModel::TABLE)
->columns(
'(SELECT COUNT(*) FROM '.CommentModel::TABLE.' WHERE task_id=tasks.id) AS nb_comments',
@@ -208,6 +208,8 @@ class NewTaskFinderModel extends Base
->join(GroupModel::TABLE, 'id', 'owner_gp', TaskModel::TABLE)
->join(MultiselectModel::TABLE, 'id', 'owner_ms', TaskModel::TABLE)
->join(ProjectModel::TABLE, 'id', 'project_id', TaskModel::TABLE);
+ $query = $this->hook->reference('task:query:extended', $query);
+ return $query;
}
/**
diff --git a/plugins/Group_assign/Model/OldTaskFinderModel.php b/plugins/Group_assign/Model/OldTaskFinderModel.php
index 70d06126..9aeeb6dc 100644
--- a/plugins/Group_assign/Model/OldTaskFinderModel.php
+++ b/plugins/Group_assign/Model/OldTaskFinderModel.php
@@ -146,7 +146,7 @@ class OldTaskFinderModel extends Base
*/
public function getExtendedQuery()
{
- return $this->db
+ $query = $this->db
->table(TaskModel::TABLE)
->columns(
'(SELECT COUNT(*) FROM '.CommentModel::TABLE.' WHERE task_id=tasks.id) AS nb_comments',
@@ -207,6 +207,8 @@ class OldTaskFinderModel extends Base
->join(GroupModel::TABLE, 'id', 'owner_gp', TaskModel::TABLE)
->join(MultiselectModel::TABLE, 'id', 'owner_ms', TaskModel::TABLE)
->join(ProjectModel::TABLE, 'id', 'project_id', TaskModel::TABLE);
+ $query = $this->hook->reference('task:query:extended', $query);
+ return $query;
}
/**