From 60e0753b90838120510861ebc674f826140b31de Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Thu, 21 Apr 2016 21:10:04 -0400 Subject: Added API procedure "getMemberGroups" --- app/Api/GroupMember.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/Api') diff --git a/app/Api/GroupMember.php b/app/Api/GroupMember.php index de62f0c6..9d2a4796 100644 --- a/app/Api/GroupMember.php +++ b/app/Api/GroupMember.php @@ -10,6 +10,11 @@ namespace Kanboard\Api; */ class GroupMember extends \Kanboard\Core\Base { + public function getMemberGroups($user_id) + { + return $this->groupMember->getGroups($user_id); + } + public function getGroupMembers($group_id) { return $this->groupMember->getMembers($group_id); -- cgit v1.2.3 From 756716766cb33da2c25544918574368b51cca26e Mon Sep 17 00:00:00 2001 From: Frederic Guillot 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(-) (limited to 'app/Api') 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 From da1725c225c94bcdffe4dba4c068db8e1e11cbe7 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Fri, 22 Apr 2016 18:49:19 -0400 Subject: Added searchTasks API procedure --- ChangeLog | 1 + app/Api/Base.php | 1 + app/Api/Task.php | 7 +++++ doc/api-task-procedures.markdown | 59 ++++++++++++++++++++++++++++++++++++++++ tests/integration/TaskTest.php | 20 ++++++++++++++ 5 files changed, 88 insertions(+) (limited to 'app/Api') diff --git a/ChangeLog b/ChangeLog index 99ddca45..898d2b00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,7 @@ New features: Improvements: +* Added tasks search with the API * Added priority field to API procedures * Added API procedure "getMemberGroups" * Added parameters for overdue tasks notifications: group by projects and send only to managers diff --git a/app/Api/Base.php b/app/Api/Base.php index 0959817e..2cc62da8 100644 --- a/app/Api/Base.php +++ b/app/Api/Base.php @@ -40,6 +40,7 @@ abstract class Base extends \Kanboard\Core\Base 'getBoard', 'getProjectActivity', 'getOverdueTasksByProject', + 'searchTasks', ); public function checkProcedurePermission($is_user, $procedure) diff --git a/app/Api/Task.php b/app/Api/Task.php index 202e9bb5..1d1211f2 100644 --- a/app/Api/Task.php +++ b/app/Api/Task.php @@ -2,6 +2,7 @@ namespace Kanboard\Api; +use Kanboard\Filter\TaskProjectFilter; use Kanboard\Model\Task as TaskModel; /** @@ -12,6 +13,12 @@ use Kanboard\Model\Task as TaskModel; */ class Task extends Base { + public function searchTasks($project_id, $query) + { + $this->checkProjectPermission($project_id); + return $this->taskLexer->build($query)->withFilter(new TaskProjectFilter($project_id))->toArray(); + } + public function getTask($task_id) { $this->checkTaskPermission($task_id); diff --git a/doc/api-task-procedures.markdown b/doc/api-task-procedures.markdown index d994d662..934b1e09 100644 --- a/doc/api-task-procedures.markdown +++ b/doc/api-task-procedures.markdown @@ -636,3 +636,62 @@ Response example: "result": 6 } ``` + +## searchTasks + +- Purpose: **Find tasks by using the search engine** +- Parameters: + - **project_id** (integer, required) + - **query** (string, required) +- Result on success: **list of tasks** +- Result on failure: **false** + +Request example: + +```json +{ + "jsonrpc": "2.0", + "method": "searchTasks", + "id": 1468511716, + "params": { + "project_id": 2, + "query": "assignee:nobody" + } +} +``` + +Response example: + +```json +{ + "jsonrpc": "2.0", + "id": 1468511716, + "result": [ + { + "nb_comments": "0", + "nb_files": "0", + "nb_subtasks": "0", + "nb_completed_subtasks": "0", + "nb_links": "0", + "nb_external_links": "0", + "is_milestone": null, + "id": "3", + "reference": "", + "title": "T3", + "description": "", + "date_creation": "1461365164", + "date_modification": "1461365164", + "date_completed": null, + "date_started": null, + "date_due": "0", + "color_id": "yellow", + "project_id": "2", + "column_id": "5", + "swimlane_id": "0", + "owner_id": "0", + "creator_id": "0" + // ... + } + ] +} +``` diff --git a/tests/integration/TaskTest.php b/tests/integration/TaskTest.php index 39fe41bf..0c398761 100644 --- a/tests/integration/TaskTest.php +++ b/tests/integration/TaskTest.php @@ -4,6 +4,26 @@ require_once __DIR__.'/Base.php'; class TaskTest extends Base { + public function testSearchTasks() + { + $project_id1 = $this->app->createProject('My project'); + $project_id2 = $this->app->createProject('My project'); + $this->assertNotFalse($project_id1); + $this->assertNotFalse($project_id2); + + $this->assertNotFalse($this->app->createTask(array('project_id' => $project_id1, 'title' => 'T1'))); + $this->assertNotFalse($this->app->createTask(array('project_id' => $project_id1, 'title' => 'T2'))); + $this->assertNotFalse($this->app->createTask(array('project_id' => $project_id2, 'title' => 'T3'))); + + $tasks = $this->app->searchTasks($project_id1, 't2'); + $this->assertCount(1, $tasks); + $this->assertEquals('T2', $tasks[0]['title']); + + $tasks = $this->app->searchTasks(array('project_id' => $project_id2, 'query' => 'assignee:nobody')); + $this->assertCount(1, $tasks); + $this->assertEquals('T3', $tasks[0]['title']); + } + public function testPriorityAttribute() { $project_id = $this->app->createProject('My project'); -- cgit v1.2.3 From 1936a74cb3affef4f439c695d7e3c9eacc5a9aae Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Tue, 26 Apr 2016 22:55:56 -0400 Subject: Update JsonRPC library --- app/Api/Auth.php | 4 ++-- app/Api/Base.php | 2 +- composer.json | 2 +- composer.lock | 14 +++++++------- tests/integration/Base.php | 6 +++--- tests/integration/MeTest.php | 10 +++++----- 6 files changed, 19 insertions(+), 19 deletions(-) (limited to 'app/Api') diff --git a/app/Api/Auth.php b/app/Api/Auth.php index 6c6e1ebe..1cc6627f 100644 --- a/app/Api/Auth.php +++ b/app/Api/Auth.php @@ -2,7 +2,7 @@ namespace Kanboard\Api; -use JsonRPC\AuthenticationFailure; +use JsonRPC\Exception\AuthenticationFailureException; /** * Base class @@ -32,7 +32,7 @@ class Auth extends Base $this->checkProcedurePermission(false, $method); } else { $this->logger->error('API authentication failure for '.$username); - throw new AuthenticationFailure('Wrong credentials'); + throw new AuthenticationFailureException('Wrong credentials'); } } diff --git a/app/Api/Base.php b/app/Api/Base.php index 2cc62da8..ea817f7d 100644 --- a/app/Api/Base.php +++ b/app/Api/Base.php @@ -2,7 +2,7 @@ namespace Kanboard\Api; -use JsonRPC\AccessDeniedException; +use JsonRPC\Exception\AccessDeniedException; /** * Base class diff --git a/composer.json b/composer.json index 7224f1ef..61f0218c 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "christian-riesen/otp" : "1.4", "eluceo/ical": "0.8.0", "erusev/parsedown" : "1.6.0", - "fguillot/json-rpc" : "1.0.3", + "fguillot/json-rpc" : "1.1.0", "fguillot/picodb" : "1.0.8", "fguillot/simpleLogger" : "1.0.0", "fguillot/simple-validator" : "1.0.0", diff --git a/composer.lock b/composer.lock index 70881a39..1c736f1d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "ecdd93c089273876816339ff22d67cc7", - "content-hash": "a5edc6f9c9ae2cd356e3f8ac96ef5532", + "hash": "715601e3833e0ee04d8d00d266302f8b", + "content-hash": "ef38cdd1e92bd2cd299db9c6d429d24f", "packages": [ { "name": "christian-riesen/base32", @@ -203,16 +203,16 @@ }, { "name": "fguillot/json-rpc", - "version": "v1.0.3", + "version": "v1.1.0", "source": { "type": "git", "url": "https://github.com/fguillot/JsonRPC.git", - "reference": "0a77cd311783431c851e4c8eed33858663c17277" + "reference": "e915dab71940e7ac251955c785570048f460d332" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fguillot/JsonRPC/zipball/0a77cd311783431c851e4c8eed33858663c17277", - "reference": "0a77cd311783431c851e4c8eed33858663c17277", + "url": "https://api.github.com/repos/fguillot/JsonRPC/zipball/e915dab71940e7ac251955c785570048f460d332", + "reference": "e915dab71940e7ac251955c785570048f460d332", "shasum": "" }, "require": { @@ -235,7 +235,7 @@ ], "description": "Simple Json-RPC client/server library that just works", "homepage": "https://github.com/fguillot/JsonRPC", - "time": "2015-09-19 02:27:10" + "time": "2016-04-27 02:48:10" }, { "name": "fguillot/picodb", diff --git a/tests/integration/Base.php b/tests/integration/Base.php index 983d0ed9..6f3ae076 100644 --- a/tests/integration/Base.php +++ b/tests/integration/Base.php @@ -35,15 +35,15 @@ abstract class Base extends PHPUnit_Framework_TestCase { $this->app = new JsonRPC\Client(API_URL); $this->app->authentication('jsonrpc', API_KEY); - // $this->app->debug = true; + $this->app->getHttpClient()->withDebug(); $this->admin = new JsonRPC\Client(API_URL); $this->admin->authentication('admin', 'admin'); - // $this->admin->debug = true; + $this->admin->getHttpClient()->withDebug(); $this->user = new JsonRPC\Client(API_URL); $this->user->authentication('user', 'password'); - // $this->user->debug = true; + $this->user->getHttpClient()->withDebug(); } protected function getProjectId() diff --git a/tests/integration/MeTest.php b/tests/integration/MeTest.php index 21f61756..1b028b84 100644 --- a/tests/integration/MeTest.php +++ b/tests/integration/MeTest.php @@ -15,7 +15,7 @@ class MeTest extends Base } /** - * @expectedException JsonRPC\AccessDeniedException + * @expectedException JsonRPC\Exception\AccessDeniedException */ public function testNotAllowedAppProcedure() { @@ -23,7 +23,7 @@ class MeTest extends Base } /** - * @expectedException JsonRPC\AccessDeniedException + * @expectedException JsonRPC\Exception\AccessDeniedException */ public function testNotAllowedUserProcedure() { @@ -31,7 +31,7 @@ class MeTest extends Base } /** - * @expectedException JsonRPC\AccessDeniedException + * @expectedException JsonRPC\Exception\AccessDeniedException */ public function testNotAllowedProjectForUser() { @@ -140,7 +140,7 @@ class MeTest extends Base } /** - * @expectedException JsonRPC\AccessDeniedException + * @expectedException JsonRPC\Exception\AccessDeniedException */ public function testGetAdminTask() { @@ -148,7 +148,7 @@ class MeTest extends Base } /** - * @expectedException JsonRPC\AccessDeniedException + * @expectedException JsonRPC\Exception\AccessDeniedException */ public function testGetProjectActivityDenied() { -- cgit v1.2.3