diff options
author | Frédéric Guillot <contact@fredericguillot.com> | 2014-02-16 18:47:11 -0500 |
---|---|---|
committer | Frédéric Guillot <contact@fredericguillot.com> | 2014-02-16 18:47:11 -0500 |
commit | c2f8e1c4360cbdd0c740b747d017034d97d8e053 (patch) | |
tree | 0de69c3cbae82cdfa910f1cbbdb87750f8b6fcdc /controllers/task.php | |
parent | e155edd1bdb3c98f240292642c6ee38bf2b1e2cf (diff) |
Improve webhook to add a task
Diffstat (limited to 'controllers/task.php')
-rw-r--r-- | controllers/task.php | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/controllers/task.php b/controllers/task.php index b022f37c..e42d1eec 100644 --- a/controllers/task.php +++ b/controllers/task.php @@ -13,15 +13,23 @@ class Task extends Base $this->response->text('Not Authorized', 401); } + $projectModel = new \Model\Project; + $defaultProject = $projectModel->getFirst(); + $values = array( 'title' => $this->request->getStringParam('title'), 'description' => $this->request->getStringParam('description'), - 'color_id' => $this->request->getStringParam('color_id'), - 'project_id' => $this->request->getIntegerParam('project_id'), + 'color_id' => $this->request->getStringParam('color_id', 'blue'), + 'project_id' => $this->request->getIntegerParam('project_id', $defaultProject['id']), 'owner_id' => $this->request->getIntegerParam('owner_id'), 'column_id' => $this->request->getIntegerParam('column_id'), ); + if ($values['column_id'] == 0) { + $boardModel = new \Model\Board; + $values['column_id'] = $boardModel->getFirstColumn($values['project_id']); + } + list($valid,) = $this->task->validateCreation($values); if ($valid && $this->task->create($values)) { |