Improve API calls for comments

This commit is contained in:
Frédéric Guillot
2014-09-16 17:54:17 +02:00
parent a76939066b
commit eb6dfdca53
5 changed files with 374 additions and 17 deletions

View File

@@ -288,7 +288,14 @@ $server->register('removeCategory', function($category_id) use ($category) {
/**
* Comments procedures
*/
$server->register('createComment', function(array $values) use ($comment) {
$server->register('createComment', function($task_id, $user_id, $content) use ($comment) {
$values = array(
'task_id' => $task_id,
'user_id' => $user_id,
'comment' => $content,
);
list($valid,) = $comment->validateCreation($values);
return $valid && $comment->create($values);
});
@@ -301,7 +308,13 @@ $server->register('getAllComments', function($task_id) use ($comment) {
return $comment->getAll($task_id);
});
$server->register('updateComment', function($values) use ($comment) {
$server->register('updateComment', function($id, $content) use ($comment) {
$values = array(
'id' => $id,
'comment' => $content,
);
list($valid,) = $comment->validateModification($values);
return $valid && $comment->update($values);
});