diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-09-12 15:14:59 +0200 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-09-12 15:14:59 +0200 |
commit | 15e1ed6148632b7008875207f26345f472a909d1 (patch) | |
tree | e79e82a64ffb154baa470ea1b76cce38d3750d23 /jsonrpc.php | |
parent | dd64bacbb13b6d07c8df01fb88ae417ac57b4239 (diff) |
Improve API calls for subtasks
Diffstat (limited to 'jsonrpc.php')
-rw-r--r-- | jsonrpc.php | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/jsonrpc.php b/jsonrpc.php index 0a6913d6..f6a2da45 100644 --- a/jsonrpc.php +++ b/jsonrpc.php @@ -315,8 +315,24 @@ $server->register('removeComment', function($comment_id) use ($comment) { /** * Subtask procedures */ -$server->register('createSubtask', function(array $values) use ($subtask) { - list($valid,) = $subtask->validate($values); +$server->register('createSubtask', function($task_id, $title, $user_id = 0, $time_estimated = 0, $time_spent = 0, $status = 0) use ($subtask) { + + $values = array( + 'title' => $title, + 'task_id' => $task_id, + 'user_id' => $user_id, + 'time_estimated' => $time_estimated, + 'time_spent' => $time_spent, + 'status' => $status, + ); + + foreach ($values as $key => $value) { + if (is_null($value)) { + unset($values[$key]); + } + } + + list($valid,) = $subtask->validateCreation($values); return $valid && $subtask->create($values); }); @@ -328,8 +344,25 @@ $server->register('getAllSubtasks', function($task_id) use ($subtask) { return $subtask->getAll($task_id); }); -$server->register('updateSubtask', function($values) use ($subtask) { - list($valid,) = $subtask->validate($values); +$server->register('updateSubtask', function($id, $task_id, $title = null, $user_id = 0, $time_estimated = 0, $time_spent = 0, $status = 0) use ($subtask) { + + $values = array( + 'id' => $id, + 'task_id' => $task_id, + 'title' => $title, + 'user_id' => $user_id, + 'time_estimated' => $time_estimated, + 'time_spent' => $time_spent, + 'status' => $status, + ); + + foreach ($values as $key => $value) { + if (is_null($value)) { + unset($values[$key]); + } + } + + list($valid,) = $subtask->validateModification($values); return $valid && $subtask->update($values); }); |