@@ -50,8 +50,8 @@ |
||
| 50 | 50 | * @param string $attribute the name of the attribute |
| 51 | 51 | * @since 7.0.0 |
| 52 | 52 | */ |
| 53 | - protected function markFieldUpdated($attribute){ |
|
| 54 | - if(!in_array($attribute, $this->_relations)) { |
|
| 53 | + protected function markFieldUpdated($attribute) { |
|
| 54 | + if (!in_array($attribute, $this->_relations)) { |
|
| 55 | 55 | parent::markFieldUpdated($attribute); |
| 56 | 56 | } |
| 57 | 57 | } |
@@ -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 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 |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | |
| 51 | - public function findAll($boardId, $limit=null, $offset=null) { |
|
| 51 | + public function findAll($boardId, $limit = null, $offset = null) { |
|
| 52 | 52 | $sql = 'SELECT * FROM `*PREFIX*deck_stacks` WHERE `board_id` = ? ORDER BY `order`'; |
| 53 | 53 | return $this->findEntities($sql, [$boardId], $limit, $offset); |
| 54 | 54 | } |
@@ -28,41 +28,41 @@ |
||
| 28 | 28 | |
| 29 | 29 | class Card extends Entity 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 | } |
@@ -41,12 +41,12 @@ |
||
| 41 | 41 | protected $archived = false; |
| 42 | 42 | |
| 43 | 43 | public function __construct() { |
| 44 | - $this->addType('id','integer'); |
|
| 45 | - $this->addType('stackId','integer'); |
|
| 46 | - $this->addType('order','integer'); |
|
| 44 | + $this->addType('id', 'integer'); |
|
| 45 | + $this->addType('stackId', 'integer'); |
|
| 46 | + $this->addType('order', 'integer'); |
|
| 47 | 47 | $this->addType('lastModified', 'integer'); |
| 48 | 48 | $this->addType('createdAt', 'integer'); |
| 49 | - $this->addType('archived','boolean'); |
|
| 49 | + $this->addType('archived', 'boolean'); |
|
| 50 | 50 | $this->addRelation('labels'); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -27,49 +27,49 @@ |
||
| 27 | 27 | |
| 28 | 28 | class Board extends Entity 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 |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | protected $shared; |
| 38 | 38 | |
| 39 | 39 | public function __construct() { |
| 40 | - $this->addType('id','integer'); |
|
| 41 | - $this->addType('shared','integer'); |
|
| 42 | - $this->addType('archived','boolean'); |
|
| 40 | + $this->addType('id', 'integer'); |
|
| 41 | + $this->addType('shared', 'integer'); |
|
| 42 | + $this->addType('archived', 'boolean'); |
|
| 43 | 43 | $this->addRelation('labels'); |
| 44 | 44 | $this->addRelation('acl'); |
| 45 | 45 | $this->addRelation('shared'); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | 'labels' => $this->labels, |
| 56 | 56 | 'acl' => $this->acl, |
| 57 | 57 | ]; |
| 58 | - if($this->shared!==-1) { |
|
| 58 | + if ($this->shared !== -1) { |
|
| 59 | 59 | $result['shared'] = $this->shared; |
| 60 | 60 | } |
| 61 | 61 | return $result; |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | * Constructor |
| 29 | 29 | * @param string $msg the error message |
| 30 | 30 | */ |
| 31 | - public function __construct($msg=""){ |
|
| 31 | + public function __construct($msg = "") { |
|
| 32 | 32 | parent::__construct($msg); |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |
@@ -67,8 +67,9 @@ |
||
| 67 | 67 | } |
| 68 | 68 | $limit = 10; |
| 69 | 69 | foreach ($this->userManager->searchDisplayName($search, $limit, $offset) as $idx => $user) { |
| 70 | - if ($user->getUID() === $this->userId) |
|
| 71 | - continue; |
|
| 70 | + if ($user->getUID() === $this->userId) { |
|
| 71 | + continue; |
|
| 72 | + } |
|
| 72 | 73 | $acl = new Acl(); |
| 73 | 74 | $acl->setType('user'); |
| 74 | 75 | $acl->setParticipant($user->getUID()); |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | class LabelController extends Controller { |
| 32 | 32 | |
| 33 | - private $labelService; |
|
| 33 | + private $labelService; |
|
| 34 | 34 | |
| 35 | - public function __construct($appName, IRequest $request, LabelService $labelService){ |
|
| 36 | - parent::__construct($appName, $request); |
|
| 37 | - $this->labelService = $labelService; |
|
| 38 | - } |
|
| 35 | + public function __construct($appName, IRequest $request, LabelService $labelService){ |
|
| 36 | + parent::__construct($appName, $request); |
|
| 37 | + $this->labelService = $labelService; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * @NoAdminRequired |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | * @param $boardId |
| 45 | 45 | * @return \OCP\AppFramework\Db\Entity |
| 46 | 46 | */ |
| 47 | - public function create($title, $color, $boardId) { |
|
| 48 | - return $this->labelService->create($title, $color, $boardId); |
|
| 49 | - } |
|
| 47 | + public function create($title, $color, $boardId) { |
|
| 48 | + return $this->labelService->create($title, $color, $boardId); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * @NoAdminRequired |
@@ -55,17 +55,17 @@ discard block |
||
| 55 | 55 | * @param $color |
| 56 | 56 | * @return \OCP\AppFramework\Db\Entity |
| 57 | 57 | */ |
| 58 | - public function update($id, $title, $color) { |
|
| 59 | - return $this->labelService->update($id, $title, $color); |
|
| 60 | - } |
|
| 58 | + public function update($id, $title, $color) { |
|
| 59 | + return $this->labelService->update($id, $title, $color); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * @NoAdminRequired |
| 64 | 64 | * @param $labelId |
| 65 | 65 | * @return \OCP\AppFramework\Db\Entity |
| 66 | 66 | */ |
| 67 | - public function delete($labelId) { |
|
| 68 | - return $this->labelService->delete($labelId); |
|
| 69 | - } |
|
| 67 | + public function delete($labelId) { |
|
| 68 | + return $this->labelService->delete($labelId); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | 71 | } |
@@ -32,7 +32,7 @@ |
||
| 32 | 32 | |
| 33 | 33 | private $labelService; |
| 34 | 34 | |
| 35 | - public function __construct($appName, IRequest $request, LabelService $labelService){ |
|
| 35 | + public function __construct($appName, IRequest $request, LabelService $labelService) { |
|
| 36 | 36 | parent::__construct($appName, $request); |
| 37 | 37 | $this->labelService = $labelService; |
| 38 | 38 | } |
@@ -49,10 +49,10 @@ |
||
| 49 | 49 | $this->userInfo = $this->getBoardPrerequisites(); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * TODO: move to boardservice |
|
| 54 | - * @return array |
|
| 55 | - */ |
|
| 52 | + /** |
|
| 53 | + * TODO: move to boardservice |
|
| 54 | + * @return array |
|
| 55 | + */ |
|
| 56 | 56 | private function getBoardPrerequisites() { |
| 57 | 57 | $groups = $this->groupManager->getUserGroupIds( |
| 58 | 58 | $this->userManager->get($this->userId) |
@@ -31,31 +31,31 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | class StackController extends Controller { |
| 34 | - private $userId; |
|
| 35 | - private $stackService; |
|
| 36 | - public function __construct($appName, IRequest $request, StackService $cardService, $userId){ |
|
| 37 | - parent::__construct($appName, $request); |
|
| 38 | - $this->userId = $userId; |
|
| 39 | - $this->stackService = $cardService; |
|
| 40 | - } |
|
| 34 | + private $userId; |
|
| 35 | + private $stackService; |
|
| 36 | + public function __construct($appName, IRequest $request, StackService $cardService, $userId){ |
|
| 37 | + parent::__construct($appName, $request); |
|
| 38 | + $this->userId = $userId; |
|
| 39 | + $this->stackService = $cardService; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * @NoAdminRequired |
| 44 | 44 | * @param $boardId |
| 45 | 45 | * @return array |
| 46 | 46 | */ |
| 47 | - public function index($boardId) { |
|
| 48 | - return $this->stackService->findAll($boardId); |
|
| 49 | - } |
|
| 47 | + public function index($boardId) { |
|
| 48 | + return $this->stackService->findAll($boardId); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * @NoAdminRequired |
| 53 | 53 | * @param $boardId |
| 54 | 54 | * @return array |
| 55 | 55 | */ |
| 56 | - public function archived($boardId) { |
|
| 57 | - return $this->stackService->findAllArchived($boardId); |
|
| 58 | - } |
|
| 56 | + public function archived($boardId) { |
|
| 57 | + return $this->stackService->findAllArchived($boardId); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * @NoAdminRequired |
@@ -64,9 +64,9 @@ discard block |
||
| 64 | 64 | * @param int $order |
| 65 | 65 | * @return \OCP\AppFramework\Db\Entity |
| 66 | 66 | */ |
| 67 | - public function create($title, $boardId, $order=999) { |
|
| 68 | - return $this->stackService->create($title, $boardId, $order); |
|
| 69 | - } |
|
| 67 | + public function create($title, $boardId, $order=999) { |
|
| 68 | + return $this->stackService->create($title, $boardId, $order); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * @NoAdminRequired |
@@ -76,16 +76,16 @@ discard block |
||
| 76 | 76 | * @param $order |
| 77 | 77 | * @return \OCP\AppFramework\Db\Entity |
| 78 | 78 | */ |
| 79 | - public function update($id, $title, $boardId, $order) { |
|
| 80 | - return $this->stackService->update($id, $title, $boardId, $order); |
|
| 81 | - } |
|
| 79 | + public function update($id, $title, $boardId, $order) { |
|
| 80 | + return $this->stackService->update($id, $title, $boardId, $order); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * @NoAdminRequired |
| 85 | 85 | * @param $stackId |
| 86 | 86 | * @return \OCP\AppFramework\Db\Entity |
| 87 | 87 | */ |
| 88 | - public function delete($stackId) { |
|
| 89 | - return $this->stackService->delete($stackId); |
|
| 90 | - } |
|
| 88 | + public function delete($stackId) { |
|
| 89 | + return $this->stackService->delete($stackId); |
|
| 90 | + } |
|
| 91 | 91 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | class StackController extends Controller { |
| 34 | 34 | private $userId; |
| 35 | 35 | private $stackService; |
| 36 | - public function __construct($appName, IRequest $request, StackService $cardService, $userId){ |
|
| 36 | + public function __construct($appName, IRequest $request, StackService $cardService, $userId) { |
|
| 37 | 37 | parent::__construct($appName, $request); |
| 38 | 38 | $this->userId = $userId; |
| 39 | 39 | $this->stackService = $cardService; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @param int $order |
| 65 | 65 | * @return \OCP\AppFramework\Db\Entity |
| 66 | 66 | */ |
| 67 | - public function create($title, $boardId, $order=999) { |
|
| 67 | + public function create($title, $boardId, $order = 999) { |
|
| 68 | 68 | return $this->stackService->create($title, $boardId, $order); |
| 69 | 69 | } |
| 70 | 70 | |