This commit is contained in:
Julius Haertl
2016-07-28 23:37:38 +02:00
parent 43023aa9d3
commit d61dcdb614
19 changed files with 220 additions and 57 deletions

View File

@@ -17,6 +17,9 @@ class Acl extends Entity implements JsonSerializable {
public function __construct() {
$this->addType('id','integer');
$this->addType('boardId','integer');
$this->addType('permissionWrite', 'boolean');
$this->addType('permissionInvite', 'boolean');
$this->addType('permissionManage', 'boolean');
}
public function jsonSerialize() {
return [

View File

@@ -11,8 +11,8 @@ class Board extends \OCA\Deck\Db\Entity implements JsonSerializable {
protected $owner;
protected $color;
protected $archived;
public $acl = array();
protected $labels;
protected $acl;
public function __construct() {
$this->addType('id','integer');
@@ -30,4 +30,16 @@ class Board extends \OCA\Deck\Db\Entity implements JsonSerializable {
'acl' => $this->acl,
];
}
public function setLabels($labels) {
foreach ($labels as $l) {
$this->labels[$l->id] = $l;
}
}
public function setAcl($acl) {
foreach ($acl as $a) {
$this->acl[$a->id] = $a;
}
}
}

View File

@@ -30,12 +30,15 @@ class BoardMapper extends Mapper {
$sql = 'SELECT * FROM `*PREFIX*deck_boards` ' .
'WHERE `id` = ?';
$board = $this->findEntity($sql, [$id]);
// Add labels
$labels = $this->labelMapper->findAll($id);
$board->setLabels($labels);
// Add sharees
// Add acl
$acl = $this->aclMapper->findAll($id);
$board->setAcl($acl);
return $board;
}

View File

@@ -16,6 +16,8 @@ class Card extends Entity implements JsonSerializable {
protected $labels;
protected $owner;
protected $order;
protected $archived;
public function __construct() {
$this->addType('id','integer');
$this->addType('stackId','integer');
@@ -35,6 +37,7 @@ class Card extends Entity implements JsonSerializable {
'order' => $this->order,
'stackId' => $this->stackId,
'labels' => $this->labels,
'archived' => $this->archived,
];
}
}

View File

@@ -51,7 +51,16 @@ class CardMapper extends Mapper {
}
public function findAll($stackId, $limit=null, $offset=null) {
$sql = 'SELECT * FROM `*PREFIX*deck_cards` WHERE `stack_id` = ? ORDER BY `order`';
$sql = 'SELECT * FROM `*PREFIX*deck_cards`
WHERE `stack_id` = ? AND NOT archived ORDER BY `order`';
$entities = $this->findEntities($sql, [$stackId], $limit, $offset);
return $entities;
}
// TODO: test
public function findAllArchived($boardId, $limit=null, $offset=null) {
$sql = 'SELECT * FROM `*PREFIX*deck_cards` as c, `*PREFIX*deck_stacks` as s
WHERE `s.board_id` = ? AND c.stack_id = s.id AND archived ORDER BY `last_modified`';
$entities = $this->findEntities($sql, [$stackId], $limit, $offset);
return $entities;
}