summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/Acl.php3
-rw-r--r--app/Model/Board.php11
-rw-r--r--app/Model/TaskFilter.php17
-rw-r--r--app/Model/TaskFinder.php18
-rw-r--r--app/Model/TaskPosition.php5
-rw-r--r--app/Model/UserSession.php24
6 files changed, 58 insertions, 20 deletions
diff --git a/app/Model/Acl.php b/app/Model/Acl.php
index 91ed035b..09638302 100644
--- a/app/Model/Acl.php
+++ b/app/Model/Acl.php
@@ -37,7 +37,8 @@ class Acl extends Base
'comment' => '*',
'file' => '*',
'project' => array('show'),
- 'projectinfo' => array('tasks', 'search', 'activity'),
+ 'listing' => '*',
+ 'activity' => '*',
'subtask' => '*',
'task' => '*',
'tasklink' => '*',
diff --git a/app/Model/Board.php b/app/Model/Board.php
index f6f968f4..bcf77b3e 100644
--- a/app/Model/Board.php
+++ b/app/Model/Board.php
@@ -237,10 +237,11 @@ class Board extends Base
* Get all tasks sorted by columns and swimlanes
*
* @access public
- * @param integer $project_id Project id
+ * @param integer $project_id
+ * @param callable $callback
* @return array
*/
- public function getBoard($project_id)
+ public function getBoard($project_id, $callback = null)
{
$swimlanes = $this->swimlane->getSwimlanes($project_id);
$columns = $this->getColumns($project_id);
@@ -253,7 +254,11 @@ class Board extends Base
$swimlanes[$i]['nb_tasks'] = 0;
for ($j = 0; $j < $nb_columns; $j++) {
- $swimlanes[$i]['columns'][$j]['tasks'] = $this->taskFinder->getTasksByColumnAndSwimlane($project_id, $columns[$j]['id'], $swimlanes[$i]['id']);
+
+ $column_id = $columns[$j]['id'];
+ $swimlane_id = $swimlanes[$i]['id'];
+
+ $swimlanes[$i]['columns'][$j]['tasks'] = $callback === null ? $this->taskFinder->getTasksByColumnAndSwimlane($project_id, $column_id, $swimlane_id) : $callback($project_id, $column_id, $swimlane_id);
$swimlanes[$i]['columns'][$j]['nb_tasks'] = count($swimlanes[$i]['columns'][$j]['tasks']);
$swimlanes[$i]['columns'][$j]['score'] = $this->getColumnSum($swimlanes[$i]['columns'][$j]['tasks'], 'score');
$swimlanes[$i]['nb_tasks'] += $swimlanes[$i]['columns'][$j]['nb_tasks'];
diff --git a/app/Model/TaskFilter.php b/app/Model/TaskFilter.php
index 31080cb5..e9d9ccbd 100644
--- a/app/Model/TaskFilter.php
+++ b/app/Model/TaskFilter.php
@@ -513,6 +513,23 @@ class TaskFilter extends Base
}
/**
+ * Get swimlanes and tasks to display the board
+ *
+ * @access public
+ * @return array
+ */
+ public function getBoard($project_id)
+ {
+ $tasks = $this->filterByProject($project_id)->query->asc(Task::TABLE.'.position')->findAll();
+
+ return $this->board->getBoard($project_id, function ($project_id, $column_id, $swimlane_id) use ($tasks) {
+ return array_filter($tasks, function(array $task) use ($column_id, $swimlane_id) {
+ return $task['column_id'] == $column_id && $task['swimlane_id'] == $swimlane_id;
+ });
+ });
+ }
+
+ /**
* Format the results to the ajax autocompletion
*
* @access public
diff --git a/app/Model/TaskFinder.php b/app/Model/TaskFinder.php
index b91f4bad..2b0453a5 100644
--- a/app/Model/TaskFinder.php
+++ b/app/Model/TaskFinder.php
@@ -13,20 +13,6 @@ use PDO;
class TaskFinder extends Base
{
/**
- * Get query for closed tasks
- *
- * @access public
- * @param integer $project_id Project id
- * @return \PicoDb\Table
- */
- public function getClosedTaskQuery($project_id)
- {
- return $this->getExtendedQuery()
- ->eq(Task::TABLE.'.project_id', $project_id)
- ->eq(Task::TABLE.'.is_active', Task::STATUS_CLOSED);
- }
-
- /**
* Get query for assigned user tasks
*
* @access public
@@ -142,8 +128,8 @@ class TaskFinder extends Base
{
return $this->db
->table(Task::TABLE)
- ->eq('project_id', $project_id)
- ->eq('is_active', $status_id)
+ ->eq(Task::TABLE.'.project_id', $project_id)
+ ->eq(Task::TABLE.'.is_active', $status_id)
->findAll();
}
diff --git a/app/Model/TaskPosition.php b/app/Model/TaskPosition.php
index 0c4beb2d..a33a4029 100644
--- a/app/Model/TaskPosition.php
+++ b/app/Model/TaskPosition.php
@@ -28,6 +28,11 @@ class TaskPosition extends Base
{
$original_task = $this->taskFinder->getById($task_id);
+ // Ignore closed tasks
+ if ($original_task['is_active'] == Task::STATUS_CLOSED) {
+ return true;
+ }
+
$result = $this->calculateAndSave($project_id, $task_id, $column_id, $position, $swimlane_id);
if ($result) {
diff --git a/app/Model/UserSession.php b/app/Model/UserSession.php
index f1f2ffee..6de4a182 100644
--- a/app/Model/UserSession.php
+++ b/app/Model/UserSession.php
@@ -94,4 +94,28 @@ class UserSession extends Base
{
return ! empty($this->session['user']);
}
+
+ /**
+ * Get project filters from the session
+ *
+ * @access public
+ * @param integer $project_id
+ * @return string
+ */
+ public function getFilters($project_id)
+ {
+ return ! empty($_SESSION['filters'][$project_id]) ? $_SESSION['filters'][$project_id] : 'status:open';
+ }
+
+ /**
+ * Save project filters in the session
+ *
+ * @access public
+ * @param integer $project_id
+ * @param string $filters
+ */
+ public function setFilters($project_id, $filters)
+ {
+ $_SESSION['filters'][$project_id] = $filters;
+ }
}