diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-09-05 18:57:58 -0700 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-09-05 18:57:58 -0700 |
commit | 532ea3b8685cb141526fbcd2cd3dd13667452783 (patch) | |
tree | 176e55dc2c4b4fd7b5673d27454200dcc909dad3 /jsonrpc.php | |
parent | a0dcfc9e4ce373b7d491c9dd1902a87d41523bf0 (diff) |
Start to improve task Api operations and doc
Diffstat (limited to 'jsonrpc.php')
-rw-r--r-- | jsonrpc.php | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/jsonrpc.php b/jsonrpc.php index 22b44df6..e4e2a778 100644 --- a/jsonrpc.php +++ b/jsonrpc.php @@ -116,7 +116,21 @@ $server->register('allowUser', function($project_id, $user_id) use ($project) { /** * Task procedures */ -$server->register('createTask', function(array $values) use ($task) { +$server->register('createTask', function($title, $project_id, $color_id, $column_id, $owner_id = 0, $creator_id = 0, $date_due = '', $description = '', $category_id = 0, $score = 0) use ($task) { + + $values = array( + 'title' => $title, + 'project_id' => $project_id, + 'color_id' => $color_id, + 'column_id' => $column_id, + 'owner_id' => $owner_id, + 'creator_id' => $creator_id, + 'date_due' => $date_due, + 'description' => $description, + 'category_id' => $category_id, + 'score' => $score, + ); + list($valid,) = $task->validateCreation($values); return $valid && $task->create($values) !== false; }); @@ -129,8 +143,29 @@ $server->register('getAllTasks', function($project_id, array $status) use ($task return $task->getAll($project_id, $status); }); -$server->register('updateTask', function($values) use ($task) { - list($valid,) = $task->validateModification($values); +$server->register('updateTask', function($id, $title = null, $project_id = null, $color_id = null, $column_id = null, $owner_id = null, $creator_id = null, $date_due = null, $description = null, $category_id = null, $score = null) use ($task) { + + $values = array( + 'id' => $id, + 'title' => $title, + 'project_id' => $project_id, + 'color_id' => $color_id, + 'column_id' => $column_id, + 'owner_id' => $owner_id, + 'creator_id' => $creator_id, + 'date_due' => $date_due, + 'description' => $description, + 'category_id' => $category_id, + 'score' => $score, + ); + + foreach ($values as $key => $value) { + if (is_null($value)) { + unset($values[$key]); + } + } + + list($valid) = $task->validateModification($values); return $valid && $task->update($values); }); |