summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-09-11 18:28:17 +0200
committerFrédéric Guillot <fred@kanboard.net>2014-09-11 18:28:17 +0200
commit61927232aeeea277344262aa5c92cd9fbedce854 (patch)
treea79bc0e22281535d0b95390407a1402c742b56c9 /app
parentd9850ae66ac7c6545633b3cfa0fe1b811b27bc41 (diff)
Improve API calls for categories
Diffstat (limited to 'app')
-rw-r--r--app/Model/Category.php13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/Model/Category.php b/app/Model/Category.php
index 4f296944..db26ebca 100644
--- a/app/Model/Category.php
+++ b/app/Model/Category.php
@@ -123,11 +123,17 @@ class Category extends Base
public function remove($category_id)
{
$this->db->startTransaction();
- $r1 = $this->db->table(Task::TABLE)->eq('category_id', $category_id)->update(array('category_id' => 0));
- $r2 = $this->db->table(self::TABLE)->eq('id', $category_id)->remove();
+
+ $this->db->table(Task::TABLE)->eq('category_id', $category_id)->update(array('category_id' => 0));
+
+ if (! $this->db->table(self::TABLE)->eq('id', $category_id)->remove()) {
+ $this->db->cancelTransaction();
+ return false;
+ }
+
$this->db->closeTransaction();
- return $r1 && $r2;
+ return true;
}
/**
@@ -192,7 +198,6 @@ class Category extends Base
$v = new Validator($values, array(
new Validators\Required('id', t('The id is required')),
new Validators\Integer('id', t('The id must be an integer')),
- new Validators\Required('project_id', t('The project id is required')),
new Validators\Integer('project_id', t('The project id must be an integer')),
new Validators\Required('name', t('The name is required')),
new Validators\MaxLength('name', t('The maximum length is %d characters', 50), 50)