Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer
2017-01-31 13:01:52 +00:00
parent 239ac2020b
commit c01bfb5e44
17 changed files with 447 additions and 444 deletions

View File

@@ -28,25 +28,25 @@ use OCP\IDBConnection;
class AclMapper extends DeckMapper implements IPermissionMapper {
public function __construct(IDBConnection $db) {
parent::__construct($db, 'deck_board_acl', '\OCA\Deck\Db\Acl');
}
public function __construct(IDBConnection $db) {
parent::__construct($db, 'deck_board_acl', '\OCA\Deck\Db\Acl');
}
public function findAll($boardId, $limit = null, $offset = null) {
$sql = 'SELECT id, board_id, type, participant, permission_edit, permission_share, permission_manage FROM `*PREFIX*deck_board_acl` WHERE `board_id` = ? ';
return $this->findEntities($sql, [$boardId], $limit, $offset);
}
public function findAll($boardId, $limit = null, $offset = null) {
$sql = 'SELECT id, board_id, type, participant, permission_edit, permission_share, permission_manage FROM `*PREFIX*deck_board_acl` WHERE `board_id` = ? ';
return $this->findEntities($sql, [$boardId], $limit, $offset);
}
public function isOwner($userId, $aclId) {
$sql = 'SELECT owner FROM `*PREFIX*deck_boards` WHERE `id` IN (SELECT board_id FROM `*PREFIX*deck_board_acl` WHERE id = ?)';
$stmt = $this->execute($sql, [$aclId]);
$row = $stmt->fetch();
return ($row['owner'] === $userId);
}
public function isOwner($userId, $aclId) {
$sql = 'SELECT owner FROM `*PREFIX*deck_boards` WHERE `id` IN (SELECT board_id FROM `*PREFIX*deck_board_acl` WHERE id = ?)';
$stmt = $this->execute($sql, [$aclId]);
$row = $stmt->fetch();
return ($row['owner'] === $userId);
}
public function findBoardId($aclId) {
$entity = $this->find($aclId);
return $entity->getBoardId();
}
public function findBoardId($aclId) {
$entity = $this->find($aclId);
return $entity->getBoardId();
}
}

View File

@@ -27,49 +27,49 @@ use JsonSerializable;
class Board extends RelationalEntity implements JsonSerializable {
public $id;
protected $title;
protected $owner;
protected $color;
protected $archived = false;
protected $labels;
protected $acl;
protected $shared;
public $id;
protected $title;
protected $owner;
protected $color;
protected $archived = false;
protected $labels;
protected $acl;
protected $shared;
public function __construct() {
$this->addType('id', 'integer');
$this->addType('shared', 'integer');
$this->addType('archived', 'boolean');
$this->addRelation('labels');
$this->addRelation('acl');
$this->addRelation('shared');
$this->shared = -1;
}
public function __construct() {
$this->addType('id', 'integer');
$this->addType('shared', 'integer');
$this->addType('archived', 'boolean');
$this->addRelation('labels');
$this->addRelation('acl');
$this->addRelation('shared');
$this->shared = -1;
}
public function jsonSerialize() {
$result = [
'id' => $this->id,
'title' => $this->title,
'owner' => $this->owner,
'color' => $this->color,
'labels' => $this->labels,
'acl' => $this->acl,
];
if ($this->shared !== -1) {
$result['shared'] = $this->shared;
}
return $result;
}
public function jsonSerialize() {
$result = [
'id' => $this->id,
'title' => $this->title,
'owner' => $this->owner,
'color' => $this->color,
'labels' => $this->labels,
'acl' => $this->acl,
];
if ($this->shared !== -1) {
$result['shared'] = $this->shared;
}
return $result;
}
public function setLabels($labels) {
foreach ($labels as $l) {
$this->labels[] = $l;
}
}
public function setLabels($labels) {
foreach ($labels as $l) {
$this->labels[] = $l;
}
}
public function setAcl($acl) {
foreach ($acl as $a) {
$this->acl[$a->id] = $a;
}
}
public function setAcl($acl) {
foreach ($acl as $a) {
$this->acl[$a->id] = $a;
}
}
}

View File

@@ -28,41 +28,41 @@ use JsonSerializable;
class Card extends RelationalEntity implements JsonSerializable {
public $id;
protected $title;
protected $description;
protected $stackId;
protected $type;
protected $lastModified;
protected $createdAt;
protected $labels;
protected $owner;
protected $order;
protected $archived = false;
public $id;
protected $title;
protected $description;
protected $stackId;
protected $type;
protected $lastModified;
protected $createdAt;
protected $labels;
protected $owner;
protected $order;
protected $archived = false;
public function __construct() {
$this->addType('id', 'integer');
$this->addType('stackId', 'integer');
$this->addType('order', 'integer');
$this->addType('lastModified', 'integer');
$this->addType('createdAt', 'integer');
$this->addType('archived', 'boolean');
$this->addRelation('labels');
}
public function __construct() {
$this->addType('id', 'integer');
$this->addType('stackId', 'integer');
$this->addType('order', 'integer');
$this->addType('lastModified', 'integer');
$this->addType('createdAt', 'integer');
$this->addType('archived', 'boolean');
$this->addRelation('labels');
}
public function jsonSerialize() {
return [
'id' => $this->id,
'title' => $this->title,
'description' => $this->description,
'type' => $this->type,
'lastModified' => $this->lastModified,
'createdAt' => $this->createdAt,
'owner' => $this->owner,
'order' => $this->order,
'stackId' => $this->stackId,
'labels' => $this->labels,
'archived' => $this->archived,
];
}
public function jsonSerialize() {
return [
'id' => $this->id,
'title' => $this->title,
'description' => $this->description,
'type' => $this->type,
'lastModified' => $this->lastModified,
'createdAt' => $this->createdAt,
'owner' => $this->owner,
'order' => $this->order,
'stackId' => $this->stackId,
'labels' => $this->labels,
'archived' => $this->archived,
];
}
}

View File

@@ -28,21 +28,21 @@ use JsonSerializable;
class Label extends RelationalEntity implements JsonSerializable {
public $id;
protected $title;
protected $color;
protected $boardId;
protected $cardId;
public function __construct() {
$this->addType('id', 'integer');
}
public function jsonSerialize() {
return [
'id' => $this->id,
'title' => $this->title,
'boardId' => $this->boardId,
'cardId' => $this->cardId,
'color' => $this->color,
];
}
public $id;
protected $title;
protected $color;
protected $boardId;
protected $cardId;
public function __construct() {
$this->addType('id', 'integer');
}
public function jsonSerialize() {
return [
'id' => $this->id,
'title' => $this->title,
'boardId' => $this->boardId,
'cardId' => $this->cardId,
'color' => $this->color,
];
}
}

View File

@@ -28,44 +28,44 @@ use OCP\IDBConnection;
class LabelMapper extends DeckMapper implements IPermissionMapper {
public function __construct(IDBConnection $db) {
parent::__construct($db, 'deck_labels', '\OCA\Deck\Db\Label');
}
public function __construct(IDBConnection $db) {
parent::__construct($db, 'deck_labels', '\OCA\Deck\Db\Label');
}
public function findAll($boardId, $limit = null, $offset = null) {
$sql = 'SELECT * FROM `*PREFIX*deck_labels` WHERE `board_id` = ? ORDER BY `id`';
return $this->findEntities($sql, [$boardId], $limit, $offset);
}
public function findAll($boardId, $limit = null, $offset = null) {
$sql = 'SELECT * FROM `*PREFIX*deck_labels` WHERE `board_id` = ? ORDER BY `id`';
return $this->findEntities($sql, [$boardId], $limit, $offset);
}
public function delete(\OCP\AppFramework\Db\Entity $entity) {
public function delete(\OCP\AppFramework\Db\Entity $entity) {
// delete assigned labels
$this->deleteLabelAssignments($entity->getId());
// delete label
return parent::delete($entity);
}
return parent::delete($entity);
}
public function findAssignedLabelsForCard($cardId, $limit = null, $offset = null) {
$sql = 'SELECT l.* FROM `*PREFIX*deck_assigned_labels` as al INNER JOIN *PREFIX*deck_labels as l ON l.id = al.label_id WHERE `card_id` = ? ORDER BY l.id';
return $this->findEntities($sql, [$cardId], $limit, $offset);
}
public function findAssignedLabelsForBoard($boardId, $limit = null, $offset = null) {
$sql = "SELECT c.id as card_id, l.id as id, l.title as title, l.color as color FROM oc_deck_cards as c " .
" INNER JOIN oc_deck_assigned_labels as al ON al.card_id = c.id INNER JOIN oc_deck_labels as l ON al.label_id = l.id WHERE board_id=? ORDER BY l.id";
$entities = $this->findEntities($sql, [$boardId], $limit, $offset);
return $entities;
}
public function findAssignedLabelsForCard($cardId, $limit = null, $offset = null) {
$sql = 'SELECT l.* FROM `*PREFIX*deck_assigned_labels` as al INNER JOIN *PREFIX*deck_labels as l ON l.id = al.label_id WHERE `card_id` = ? ORDER BY l.id';
return $this->findEntities($sql, [$cardId], $limit, $offset);
}
public function findAssignedLabelsForBoard($boardId, $limit = null, $offset = null) {
$sql = "SELECT c.id as card_id, l.id as id, l.title as title, l.color as color FROM oc_deck_cards as c " .
" INNER JOIN oc_deck_assigned_labels as al ON al.card_id = c.id INNER JOIN oc_deck_labels as l ON al.label_id = l.id WHERE board_id=? ORDER BY l.id";
$entities = $this->findEntities($sql, [$boardId], $limit, $offset);
return $entities;
}
public function getAssignedLabelsForBoard($boardId) {
$labels = $this->findAssignedLabelsForBoard($boardId);
$result = array();
foreach ($labels as $label) {
if (!array_key_exists($label->getCardId(), $result)) {
$result[$label->getCardId()] = array();
}
$result[$label->getCardId()][] = $label;
}
return $result;
}
public function getAssignedLabelsForBoard($boardId) {
$labels = $this->findAssignedLabelsForBoard($boardId);
$result = array();
foreach ($labels as $label) {
if (!array_key_exists($label->getCardId(), $result)) {
$result[$label->getCardId()] = array();
}
$result[$label->getCardId()][] = $label;
}
return $result;
}
public function deleteLabelAssignments($labelId) {
$sql = 'DELETE FROM `*PREFIX*deck_assigned_labels` WHERE label_id = ?';
@@ -81,15 +81,15 @@ class LabelMapper extends DeckMapper implements IPermissionMapper {
$stmt->execute();
}
public function isOwner($userId, $labelId) {
$sql = 'SELECT owner FROM `*PREFIX*deck_boards` WHERE `id` IN (SELECT board_id FROM `*PREFIX*deck_labels` WHERE id = ?)';
$stmt = $this->execute($sql, [$labelId]);
$row = $stmt->fetch();
return ($row['owner'] === $userId);
}
public function isOwner($userId, $labelId) {
$sql = 'SELECT owner FROM `*PREFIX*deck_boards` WHERE `id` IN (SELECT board_id FROM `*PREFIX*deck_labels` WHERE id = ?)';
$stmt = $this->execute($sql, [$labelId]);
$row = $stmt->fetch();
return ($row['owner'] === $userId);
}
public function findBoardId($labelId) {
$entity = $this->find($labelId);
return $entity->getBoardId();
}
public function findBoardId($labelId) {
$entity = $this->find($labelId);
return $entity->getBoardId();
}
}

View File

@@ -28,37 +28,37 @@ use JsonSerializable;
class Stack extends RelationalEntity implements JsonSerializable {
public $id;
protected $title;
protected $boardId;
protected $cards = array();
protected $order;
public $id;
protected $title;
protected $boardId;
protected $cards = array();
protected $order;
public function __construct() {
$this->addType('id', 'integer');
$this->addType('boardId', 'integer');
$this->addType('order', 'integer');
}
public function __construct() {
$this->addType('id', 'integer');
$this->addType('boardId', 'integer');
$this->addType('order', 'integer');
}
public function setCards($cards) {
$this->cards = $cards;
}
public function setCards($cards) {
$this->cards = $cards;
}
public function jsonSerialize() {
if (!empty($this->cards)) {
return [
'id' => $this->id,
'title' => $this->title,
'order' => $this->order,
'boardId' => $this->boardId,
'cards' => $this->cards
];
}
return [
'id' => $this->id,
'title' => $this->title,
'order' => $this->order,
'boardId' => $this->boardId
];
}
public function jsonSerialize() {
if (!empty($this->cards)) {
return [
'id' => $this->id,
'title' => $this->title,
'order' => $this->order,
'boardId' => $this->boardId,
'cards' => $this->cards
];
}
return [
'id' => $this->id,
'title' => $this->title,
'order' => $this->order,
'boardId' => $this->boardId
];
}
}

View File

@@ -29,46 +29,46 @@ use OCP\IDBConnection;
class StackMapper extends DeckMapper implements IPermissionMapper {
private $cardMapper;
private $cardMapper;
public function __construct(IDBConnection $db, CardMapper $cardMapper) {
parent::__construct($db, 'deck_stacks', '\OCA\Deck\Db\Stack');
$this->cardMapper = $cardMapper;
}
public function __construct(IDBConnection $db, CardMapper $cardMapper) {
parent::__construct($db, 'deck_stacks', '\OCA\Deck\Db\Stack');
$this->cardMapper = $cardMapper;
}
/**
* @param $id
* @return \OCP\AppFramework\Db\Entity if not found
*/
public function find($id) {
$sql = 'SELECT * FROM `*PREFIX*deck_stacks` ' .
'WHERE `id` = ?';
return $this->findEntity($sql, [$id]);
}
public function find($id) {
$sql = 'SELECT * FROM `*PREFIX*deck_stacks` ' .
'WHERE `id` = ?';
return $this->findEntity($sql, [$id]);
}
public function findAll($boardId, $limit = null, $offset = null) {
$sql = 'SELECT * FROM `*PREFIX*deck_stacks` WHERE `board_id` = ? ORDER BY `order`';
return $this->findEntities($sql, [$boardId], $limit, $offset);
}
public function findAll($boardId, $limit = null, $offset = null) {
$sql = 'SELECT * FROM `*PREFIX*deck_stacks` WHERE `board_id` = ? ORDER BY `order`';
return $this->findEntities($sql, [$boardId], $limit, $offset);
}
public function delete(Entity $entity) {
// delete cards on stack
public function delete(Entity $entity) {
// delete cards on stack
$this->cardMapper->deleteByStack($entity->getId());
return parent::delete($entity);
}
return parent::delete($entity);
}
public function isOwner($userId, $stackId) {
$sql = 'SELECT owner FROM `*PREFIX*deck_boards` WHERE `id` IN (SELECT board_id FROM `*PREFIX*deck_stacks` WHERE id = ?)';
$stmt = $this->execute($sql, [$stackId]);
$row = $stmt->fetch();
return ($row['owner'] === $userId);
}
public function isOwner($userId, $stackId) {
$sql = 'SELECT owner FROM `*PREFIX*deck_boards` WHERE `id` IN (SELECT board_id FROM `*PREFIX*deck_stacks` WHERE id = ?)';
$stmt = $this->execute($sql, [$stackId]);
$row = $stmt->fetch();
return ($row['owner'] === $userId);
}
public function findBoardId($stackId) {
$entity = $this->find($stackId);
return $entity->getBoardId();
}
public function findBoardId($stackId) {
$entity = $this->find($stackId);
return $entity->getBoardId();
}
}