@@ -28,21 +28,21 @@ |
||
| 28 | 28 | |
| 29 | 29 | class Label extends RelationalEntity implements JsonSerializable { |
| 30 | 30 | |
| 31 | - public $id; |
|
| 32 | - protected $title; |
|
| 33 | - protected $color; |
|
| 34 | - protected $boardId; |
|
| 35 | - protected $cardId; |
|
| 36 | - public function __construct() { |
|
| 37 | - $this->addType('id', 'integer'); |
|
| 38 | - } |
|
| 39 | - public function jsonSerialize() { |
|
| 40 | - return [ |
|
| 41 | - 'id' => $this->id, |
|
| 42 | - 'title' => $this->title, |
|
| 43 | - 'boardId' => $this->boardId, |
|
| 44 | - 'cardId' => $this->cardId, |
|
| 45 | - 'color' => $this->color, |
|
| 46 | - ]; |
|
| 47 | - } |
|
| 31 | + public $id; |
|
| 32 | + protected $title; |
|
| 33 | + protected $color; |
|
| 34 | + protected $boardId; |
|
| 35 | + protected $cardId; |
|
| 36 | + public function __construct() { |
|
| 37 | + $this->addType('id', 'integer'); |
|
| 38 | + } |
|
| 39 | + public function jsonSerialize() { |
|
| 40 | + return [ |
|
| 41 | + 'id' => $this->id, |
|
| 42 | + 'title' => $this->title, |
|
| 43 | + 'boardId' => $this->boardId, |
|
| 44 | + 'cardId' => $this->cardId, |
|
| 45 | + 'color' => $this->color, |
|
| 46 | + ]; |
|
| 47 | + } |
|
| 48 | 48 | } |
| 49 | 49 | \ No newline at end of file |
@@ -28,37 +28,37 @@ |
||
| 28 | 28 | |
| 29 | 29 | class Stack extends RelationalEntity implements JsonSerializable { |
| 30 | 30 | |
| 31 | - public $id; |
|
| 32 | - protected $title; |
|
| 33 | - protected $boardId; |
|
| 34 | - protected $cards = array(); |
|
| 35 | - protected $order; |
|
| 31 | + public $id; |
|
| 32 | + protected $title; |
|
| 33 | + protected $boardId; |
|
| 34 | + protected $cards = array(); |
|
| 35 | + protected $order; |
|
| 36 | 36 | |
| 37 | - public function __construct() { |
|
| 38 | - $this->addType('id', 'integer'); |
|
| 39 | - $this->addType('boardId', 'integer'); |
|
| 40 | - $this->addType('order', 'integer'); |
|
| 41 | - } |
|
| 37 | + public function __construct() { |
|
| 38 | + $this->addType('id', 'integer'); |
|
| 39 | + $this->addType('boardId', 'integer'); |
|
| 40 | + $this->addType('order', 'integer'); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public function setCards($cards) { |
|
| 44 | - $this->cards = $cards; |
|
| 45 | - } |
|
| 43 | + public function setCards($cards) { |
|
| 44 | + $this->cards = $cards; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - public function jsonSerialize() { |
|
| 48 | - if (!empty($this->cards)) { |
|
| 49 | - return [ |
|
| 50 | - 'id' => $this->id, |
|
| 51 | - 'title' => $this->title, |
|
| 52 | - 'order' => $this->order, |
|
| 53 | - 'boardId' => $this->boardId, |
|
| 54 | - 'cards' => $this->cards |
|
| 55 | - ]; |
|
| 56 | - } |
|
| 57 | - return [ |
|
| 58 | - 'id' => $this->id, |
|
| 59 | - 'title' => $this->title, |
|
| 60 | - 'order' => $this->order, |
|
| 61 | - 'boardId' => $this->boardId |
|
| 62 | - ]; |
|
| 63 | - } |
|
| 47 | + public function jsonSerialize() { |
|
| 48 | + if (!empty($this->cards)) { |
|
| 49 | + return [ |
|
| 50 | + 'id' => $this->id, |
|
| 51 | + 'title' => $this->title, |
|
| 52 | + 'order' => $this->order, |
|
| 53 | + 'boardId' => $this->boardId, |
|
| 54 | + 'cards' => $this->cards |
|
| 55 | + ]; |
|
| 56 | + } |
|
| 57 | + return [ |
|
| 58 | + 'id' => $this->id, |
|
| 59 | + 'title' => $this->title, |
|
| 60 | + 'order' => $this->order, |
|
| 61 | + 'boardId' => $this->boardId |
|
| 62 | + ]; |
|
| 63 | + } |
|
| 64 | 64 | } |
| 65 | 65 | \ No newline at end of file |
@@ -29,46 +29,46 @@ |
||
| 29 | 29 | |
| 30 | 30 | class StackMapper extends DeckMapper implements IPermissionMapper { |
| 31 | 31 | |
| 32 | - private $cardMapper; |
|
| 32 | + private $cardMapper; |
|
| 33 | 33 | |
| 34 | - public function __construct(IDBConnection $db, CardMapper $cardMapper) { |
|
| 35 | - parent::__construct($db, 'deck_stacks', '\OCA\Deck\Db\Stack'); |
|
| 36 | - $this->cardMapper = $cardMapper; |
|
| 37 | - } |
|
| 34 | + public function __construct(IDBConnection $db, CardMapper $cardMapper) { |
|
| 35 | + parent::__construct($db, 'deck_stacks', '\OCA\Deck\Db\Stack'); |
|
| 36 | + $this->cardMapper = $cardMapper; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * @param $id |
| 42 | 42 | * @return \OCP\AppFramework\Db\Entity if not found |
| 43 | 43 | */ |
| 44 | - public function find($id) { |
|
| 45 | - $sql = 'SELECT * FROM `*PREFIX*deck_stacks` ' . |
|
| 46 | - 'WHERE `id` = ?'; |
|
| 47 | - return $this->findEntity($sql, [$id]); |
|
| 48 | - } |
|
| 44 | + public function find($id) { |
|
| 45 | + $sql = 'SELECT * FROM `*PREFIX*deck_stacks` ' . |
|
| 46 | + 'WHERE `id` = ?'; |
|
| 47 | + return $this->findEntity($sql, [$id]); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | - public function findAll($boardId, $limit = null, $offset = null) { |
|
| 52 | - $sql = 'SELECT * FROM `*PREFIX*deck_stacks` WHERE `board_id` = ? ORDER BY `order`'; |
|
| 53 | - return $this->findEntities($sql, [$boardId], $limit, $offset); |
|
| 54 | - } |
|
| 51 | + public function findAll($boardId, $limit = null, $offset = null) { |
|
| 52 | + $sql = 'SELECT * FROM `*PREFIX*deck_stacks` WHERE `board_id` = ? ORDER BY `order`'; |
|
| 53 | + return $this->findEntities($sql, [$boardId], $limit, $offset); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | |
| 57 | - public function delete(Entity $entity) { |
|
| 58 | - // delete cards on stack |
|
| 57 | + public function delete(Entity $entity) { |
|
| 58 | + // delete cards on stack |
|
| 59 | 59 | $this->cardMapper->deleteByStack($entity->getId()); |
| 60 | - return parent::delete($entity); |
|
| 61 | - } |
|
| 60 | + return parent::delete($entity); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - public function isOwner($userId, $stackId) { |
|
| 64 | - $sql = 'SELECT owner FROM `*PREFIX*deck_boards` WHERE `id` IN (SELECT board_id FROM `*PREFIX*deck_stacks` WHERE id = ?)'; |
|
| 65 | - $stmt = $this->execute($sql, [$stackId]); |
|
| 66 | - $row = $stmt->fetch(); |
|
| 67 | - return ($row['owner'] === $userId); |
|
| 68 | - } |
|
| 63 | + public function isOwner($userId, $stackId) { |
|
| 64 | + $sql = 'SELECT owner FROM `*PREFIX*deck_boards` WHERE `id` IN (SELECT board_id FROM `*PREFIX*deck_stacks` WHERE id = ?)'; |
|
| 65 | + $stmt = $this->execute($sql, [$stackId]); |
|
| 66 | + $row = $stmt->fetch(); |
|
| 67 | + return ($row['owner'] === $userId); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - public function findBoardId($stackId) { |
|
| 71 | - $entity = $this->find($stackId); |
|
| 72 | - return $entity->getBoardId(); |
|
| 73 | - } |
|
| 70 | + public function findBoardId($stackId) { |
|
| 71 | + $entity = $this->find($stackId); |
|
| 72 | + return $entity->getBoardId(); |
|
| 73 | + } |
|
| 74 | 74 | } |
| 75 | 75 | \ No newline at end of file |
@@ -28,41 +28,41 @@ |
||
| 28 | 28 | |
| 29 | 29 | class Card extends RelationalEntity implements JsonSerializable { |
| 30 | 30 | |
| 31 | - public $id; |
|
| 32 | - protected $title; |
|
| 33 | - protected $description; |
|
| 34 | - protected $stackId; |
|
| 35 | - protected $type; |
|
| 36 | - protected $lastModified; |
|
| 37 | - protected $createdAt; |
|
| 38 | - protected $labels; |
|
| 39 | - protected $owner; |
|
| 40 | - protected $order; |
|
| 41 | - protected $archived = false; |
|
| 31 | + public $id; |
|
| 32 | + protected $title; |
|
| 33 | + protected $description; |
|
| 34 | + protected $stackId; |
|
| 35 | + protected $type; |
|
| 36 | + protected $lastModified; |
|
| 37 | + protected $createdAt; |
|
| 38 | + protected $labels; |
|
| 39 | + protected $owner; |
|
| 40 | + protected $order; |
|
| 41 | + protected $archived = false; |
|
| 42 | 42 | |
| 43 | - public function __construct() { |
|
| 44 | - $this->addType('id', 'integer'); |
|
| 45 | - $this->addType('stackId', 'integer'); |
|
| 46 | - $this->addType('order', 'integer'); |
|
| 47 | - $this->addType('lastModified', 'integer'); |
|
| 48 | - $this->addType('createdAt', 'integer'); |
|
| 49 | - $this->addType('archived', 'boolean'); |
|
| 50 | - $this->addRelation('labels'); |
|
| 51 | - } |
|
| 43 | + public function __construct() { |
|
| 44 | + $this->addType('id', 'integer'); |
|
| 45 | + $this->addType('stackId', 'integer'); |
|
| 46 | + $this->addType('order', 'integer'); |
|
| 47 | + $this->addType('lastModified', 'integer'); |
|
| 48 | + $this->addType('createdAt', 'integer'); |
|
| 49 | + $this->addType('archived', 'boolean'); |
|
| 50 | + $this->addRelation('labels'); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function jsonSerialize() { |
|
| 54 | - return [ |
|
| 55 | - 'id' => $this->id, |
|
| 56 | - 'title' => $this->title, |
|
| 57 | - 'description' => $this->description, |
|
| 58 | - 'type' => $this->type, |
|
| 59 | - 'lastModified' => $this->lastModified, |
|
| 60 | - 'createdAt' => $this->createdAt, |
|
| 61 | - 'owner' => $this->owner, |
|
| 62 | - 'order' => $this->order, |
|
| 63 | - 'stackId' => $this->stackId, |
|
| 64 | - 'labels' => $this->labels, |
|
| 65 | - 'archived' => $this->archived, |
|
| 66 | - ]; |
|
| 67 | - } |
|
| 53 | + public function jsonSerialize() { |
|
| 54 | + return [ |
|
| 55 | + 'id' => $this->id, |
|
| 56 | + 'title' => $this->title, |
|
| 57 | + 'description' => $this->description, |
|
| 58 | + 'type' => $this->type, |
|
| 59 | + 'lastModified' => $this->lastModified, |
|
| 60 | + 'createdAt' => $this->createdAt, |
|
| 61 | + 'owner' => $this->owner, |
|
| 62 | + 'order' => $this->order, |
|
| 63 | + 'stackId' => $this->stackId, |
|
| 64 | + 'labels' => $this->labels, |
|
| 65 | + 'archived' => $this->archived, |
|
| 66 | + ]; |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -27,49 +27,49 @@ |
||
| 27 | 27 | |
| 28 | 28 | class Board extends RelationalEntity implements JsonSerializable { |
| 29 | 29 | |
| 30 | - public $id; |
|
| 31 | - protected $title; |
|
| 32 | - protected $owner; |
|
| 33 | - protected $color; |
|
| 34 | - protected $archived = false; |
|
| 35 | - protected $labels; |
|
| 36 | - protected $acl; |
|
| 37 | - protected $shared; |
|
| 30 | + public $id; |
|
| 31 | + protected $title; |
|
| 32 | + protected $owner; |
|
| 33 | + protected $color; |
|
| 34 | + protected $archived = false; |
|
| 35 | + protected $labels; |
|
| 36 | + protected $acl; |
|
| 37 | + protected $shared; |
|
| 38 | 38 | |
| 39 | - public function __construct() { |
|
| 40 | - $this->addType('id', 'integer'); |
|
| 41 | - $this->addType('shared', 'integer'); |
|
| 42 | - $this->addType('archived', 'boolean'); |
|
| 43 | - $this->addRelation('labels'); |
|
| 44 | - $this->addRelation('acl'); |
|
| 45 | - $this->addRelation('shared'); |
|
| 46 | - $this->shared = -1; |
|
| 47 | - } |
|
| 39 | + public function __construct() { |
|
| 40 | + $this->addType('id', 'integer'); |
|
| 41 | + $this->addType('shared', 'integer'); |
|
| 42 | + $this->addType('archived', 'boolean'); |
|
| 43 | + $this->addRelation('labels'); |
|
| 44 | + $this->addRelation('acl'); |
|
| 45 | + $this->addRelation('shared'); |
|
| 46 | + $this->shared = -1; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public function jsonSerialize() { |
|
| 50 | - $result = [ |
|
| 51 | - 'id' => $this->id, |
|
| 52 | - 'title' => $this->title, |
|
| 53 | - 'owner' => $this->owner, |
|
| 54 | - 'color' => $this->color, |
|
| 55 | - 'labels' => $this->labels, |
|
| 56 | - 'acl' => $this->acl, |
|
| 57 | - ]; |
|
| 58 | - if ($this->shared !== -1) { |
|
| 59 | - $result['shared'] = $this->shared; |
|
| 60 | - } |
|
| 61 | - return $result; |
|
| 62 | - } |
|
| 49 | + public function jsonSerialize() { |
|
| 50 | + $result = [ |
|
| 51 | + 'id' => $this->id, |
|
| 52 | + 'title' => $this->title, |
|
| 53 | + 'owner' => $this->owner, |
|
| 54 | + 'color' => $this->color, |
|
| 55 | + 'labels' => $this->labels, |
|
| 56 | + 'acl' => $this->acl, |
|
| 57 | + ]; |
|
| 58 | + if ($this->shared !== -1) { |
|
| 59 | + $result['shared'] = $this->shared; |
|
| 60 | + } |
|
| 61 | + return $result; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - public function setLabels($labels) { |
|
| 65 | - foreach ($labels as $l) { |
|
| 66 | - $this->labels[] = $l; |
|
| 67 | - } |
|
| 68 | - } |
|
| 64 | + public function setLabels($labels) { |
|
| 65 | + foreach ($labels as $l) { |
|
| 66 | + $this->labels[] = $l; |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - public function setAcl($acl) { |
|
| 71 | - foreach ($acl as $a) { |
|
| 72 | - $this->acl[$a->id] = $a; |
|
| 73 | - } |
|
| 74 | - } |
|
| 70 | + public function setAcl($acl) { |
|
| 71 | + foreach ($acl as $a) { |
|
| 72 | + $this->acl[$a->id] = $a; |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | 75 | } |
| 76 | 76 | \ No newline at end of file |