Ejemplo n.º 1
0
 public function create(array $values)
 {
     $this->db->startTransaction();
     $values['token'] = self::generateToken();
     $this->db->table(self::TABLE)->save($values);
     $project_id = $this->db->getConnection()->getLastId();
     $boardModel = new \Model\Board();
     $boardModel->create($project_id, array(t('Backlog'), t('Ready'), t('Work in progress'), t('Done')));
     $this->db->closeTransaction();
     return $project_id;
 }
Ejemplo n.º 2
0
 public function add()
 {
     $token = $this->request->getStringParam('token');
     if ($this->config->get('webhooks_token') !== $token) {
         $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', '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)) {
         $this->response->text('OK');
     }
     $this->response->text('FAILED');
 }