From 756716766cb33da2c25544918574368b51cca26e Mon Sep 17 00:00:00 2001
From: Frederic Guillot <fred@kanboard.net>
Date: Thu, 21 Apr 2016 21:21:34 -0400
Subject: Added priority field to API procedures

---
 ChangeLog                        |  1 +
 app/Api/Task.php                 |  6 ++++--
 doc/api-task-procedures.markdown |  2 ++
 tests/integration/TaskTest.php   | 16 ++++++++++++++++
 4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 15d35b85..99ddca45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,7 @@ New features:
 
 Improvements:
 
+* Added priority field to API procedures
 * Added API procedure "getMemberGroups"
 * Added parameters for overdue tasks notifications: group by projects and send only to managers
 * Allow people to install Kanboard outside of the DocumentRoot
diff --git a/app/Api/Task.php b/app/Api/Task.php
index 177a09c6..202e9bb5 100644
--- a/app/Api/Task.php
+++ b/app/Api/Task.php
@@ -75,7 +75,7 @@ class Task extends Base
     }
 
     public function createTask($title, $project_id, $color_id = '', $column_id = 0, $owner_id = 0, $creator_id = 0,
-                                $date_due = '', $description = '', $category_id = 0, $score = 0, $swimlane_id = 0,
+                                $date_due = '', $description = '', $category_id = 0, $score = 0, $swimlane_id = 0, $priority = 0,
                                 $recurrence_status = 0, $recurrence_trigger = 0, $recurrence_factor = 0, $recurrence_timeframe = 0,
                                 $recurrence_basedate = 0, $reference = '')
     {
@@ -107,6 +107,7 @@ class Task extends Base
             'recurrence_timeframe' => $recurrence_timeframe,
             'recurrence_basedate' => $recurrence_basedate,
             'reference' => $reference,
+            'priority' => $priority,
         );
 
         list($valid, ) = $this->taskValidator->validateCreation($values);
@@ -115,7 +116,7 @@ class Task extends Base
     }
 
     public function updateTask($id, $title = null, $color_id = null, $owner_id = null,
-                                $date_due = null, $description = null, $category_id = null, $score = null,
+                                $date_due = null, $description = null, $category_id = null, $score = null, $priority = null,
                                 $recurrence_status = null, $recurrence_trigger = null, $recurrence_factor = null,
                                 $recurrence_timeframe = null, $recurrence_basedate = null, $reference = null)
     {
@@ -146,6 +147,7 @@ class Task extends Base
             'recurrence_timeframe' => $recurrence_timeframe,
             'recurrence_basedate' => $recurrence_basedate,
             'reference' => $reference,
+            'priority' => $priority,
         );
 
         foreach ($values as $key => $value) {
diff --git a/doc/api-task-procedures.markdown b/doc/api-task-procedures.markdown
index 486c0a09..d994d662 100644
--- a/doc/api-task-procedures.markdown
+++ b/doc/api-task-procedures.markdown
@@ -16,6 +16,7 @@ API Task Procedures
     - **category_id** (integer, optional)
     - **score** (integer, optional)
     - **swimlane_id** (integer, optional)
+    - **priority** (integer, optional)
     - **recurrence_status**  (integer, optional)
     - **recurrence_trigger**  (integer, optional)
     - **recurrence_factor**  (integer, optional)
@@ -398,6 +399,7 @@ Response example:
     - **description** Markdown content (string, optional)
     - **category_id** (integer, optional)
     - **score** (integer, optional)
+    - **priority** (integer, optional)
     - **recurrence_status**  (integer, optional)
     - **recurrence_trigger**  (integer, optional)
     - **recurrence_factor**  (integer, optional)
diff --git a/tests/integration/TaskTest.php b/tests/integration/TaskTest.php
index 6d500da4..39fe41bf 100644
--- a/tests/integration/TaskTest.php
+++ b/tests/integration/TaskTest.php
@@ -4,6 +4,22 @@ require_once __DIR__.'/Base.php';
 
 class TaskTest extends Base
 {
+    public function testPriorityAttribute()
+    {
+        $project_id = $this->app->createProject('My project');
+        $this->assertNotFalse($project_id);
+
+        $task_id = $this->app->createTask(array('project_id' => $project_id, 'title' => 'My task', 'priority' => 2));
+
+        $task = $this->app->getTask($task_id);
+        $this->assertEquals(2, $task['priority']);
+
+        $this->assertTrue($this->app->updateTask(array('id' => $task_id, 'project_id' => $project_id, 'priority' => 3)));
+
+        $task = $this->app->getTask($task_id);
+        $this->assertEquals(3, $task['priority']);
+    }
+
     public function testChangeAssigneeToAssignableUser()
     {
         $project_id = $this->app->createProject('My project');
-- 
cgit v1.2.3