Completed
Push — master ( 5c1713...deb9d0 )
by Julius
05:06 queued 02:41
created
lib/Service/PermissionService.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -75,35 +75,35 @@  discard block
 block discarded – undo
75 75
 	 * @return bool
76 76
 	 * @throws NoPermissionException
77 77
 	 */
78
-    public function checkPermission($mapper, $id, $permission) {
79
-        try {
80
-            if ($mapper instanceof IPermissionMapper) {
81
-                $boardId = $mapper->findBoardId($id);
82
-            } else {
83
-                $boardId = $id;
84
-            }
85
-            if ($boardId === null) {
86
-                // Throw NoPermission to not leak information about existing entries
87
-                throw new NoPermissionException('Permission denied');
88
-            }
78
+	public function checkPermission($mapper, $id, $permission) {
79
+		try {
80
+			if ($mapper instanceof IPermissionMapper) {
81
+				$boardId = $mapper->findBoardId($id);
82
+			} else {
83
+				$boardId = $id;
84
+			}
85
+			if ($boardId === null) {
86
+				// Throw NoPermission to not leak information about existing entries
87
+				throw new NoPermissionException('Permission denied');
88
+			}
89 89
 
90
-            if ($this->userIsBoardOwner($boardId)) {
91
-                return true;
92
-            }
93
-            $acls = $this->aclMapper->findAll($boardId);
94
-            $result = $this->userCan($acls, $permission);
95
-            if ($result) {
96
-                return true;
97
-            }
90
+			if ($this->userIsBoardOwner($boardId)) {
91
+				return true;
92
+			}
93
+			$acls = $this->aclMapper->findAll($boardId);
94
+			$result = $this->userCan($acls, $permission);
95
+			if ($result) {
96
+				return true;
97
+			}
98 98
 
99
-        } catch (DoesNotExistException $exception) {
100
-            // Throw NoPermission to not leak information about existing entries
101
-            throw new NoPermissionException('Permission denied');
102
-        }
99
+		} catch (DoesNotExistException $exception) {
100
+			// Throw NoPermission to not leak information about existing entries
101
+			throw new NoPermissionException('Permission denied');
102
+		}
103 103
 
104
-        throw new NoPermissionException('Permission denied.');
104
+		throw new NoPermissionException('Permission denied.');
105 105
 
106
-    }
106
+	}
107 107
 
108 108
 	/**
109 109
 	 * @param $boardId
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 		if ($board && $this->userId === $board->getOwner()) {
115 115
 			return true;
116 116
 		}
117
-        return false;
117
+		return false;
118 118
 	}
119 119
 
120 120
 	/**
Please login to merge, or discard this patch.
lib/Service/CardService.php 1 patch
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -32,118 +32,118 @@
 block discarded – undo
32 32
 
33 33
 class CardService {
34 34
 
35
-    private $cardMapper;
36
-
37
-    public function __construct(CardMapper $cardMapper, StackMapper $stackMapper, PermissionService $permissionService) {
38
-        $this->cardMapper = $cardMapper;
39
-        $this->stackMapper = $stackMapper;
40
-        $this->permissionService = $permissionService;
41
-    }
42
-
43
-    public function find($cardId) {
44
-        $this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ);
45
-        return $this->cardMapper->find($cardId);
46
-    }
47
-
48
-    public function create($title, $stackId, $type, $order, $owner) {
49
-        $this->permissionService->checkPermission($this->stackMapper, $stackId, Acl::PERMISSION_EDIT);
50
-        $card = new Card();
51
-        $card->setTitle($title);
52
-        $card->setStackId($stackId);
53
-        $card->setType($type);
54
-        $card->setOrder($order);
55
-        $card->setOwner($owner);
56
-        return $this->cardMapper->insert($card);
57
-
58
-    }
59
-
60
-    public function delete($id) {
61
-        $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
62
-        return $this->cardMapper->delete($this->cardMapper->find($id));
63
-    }
64
-
65
-    public function update($id, $title, $stackId, $type, $order, $description, $owner) {
66
-        $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
67
-        $card = $this->cardMapper->find($id);
68
-        if ($card->getArchived()) {
69
-            throw new CardArchivedException();
70
-        }
71
-        $card->setTitle($title);
72
-        $card->setStackId($stackId);
73
-        $card->setType($type);
74
-        $card->setOrder($order);
75
-        $card->setOwner($owner);
76
-        $card->setDescription($description);
77
-        return $this->cardMapper->update($card);
78
-    }
79
-
80
-    public function rename($id, $title) {
81
-        $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
82
-        $card = $this->cardMapper->find($id);
83
-        if ($card->getArchived()) {
84
-            throw new CardArchivedException();
85
-        }
86
-        $card->setTitle($title);
87
-        return $this->cardMapper->update($card);
88
-    }
89
-
90
-    public function reorder($id, $stackId, $order) {
91
-        $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
92
-        $cards = $this->cardMapper->findAll($stackId);
93
-        $result = [];
94
-        $i = 0;
95
-        foreach ($cards as $card) {
96
-            if ($card->getArchived()) {
97
-                throw new CardArchivedException();
98
-            }
99
-            if ($card->id === $id) {
100
-                $card->setOrder($order);
101
-                $card->setLastModified(time());
102
-            }
103
-
104
-            if ($i === $order) {
105
-                            $i++;
106
-            }
107
-
108
-            if ($card->id !== $id) {
109
-                $card->setOrder($i++);
110
-            }
111
-            $this->cardMapper->update($card);
112
-            $result[$card->getOrder()] = $card;
113
-        }
114
-
115
-        return $result;
116
-    }
117
-
118
-    public function archive($id) {
119
-        $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
120
-        $card = $this->cardMapper->find($id);
121
-        $card->setArchived(true);
122
-        return $this->cardMapper->update($card);
123
-    }
124
-
125
-    public function unarchive($id) {
126
-        $this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
127
-        $card = $this->cardMapper->find($id);
128
-        $card->setArchived(false);
129
-        return $this->cardMapper->update($card);
130
-    }
131
-
132
-    public function assignLabel($cardId, $labelId) {
133
-        $this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
134
-        $card = $this->cardMapper->find($cardId);
135
-        if ($card->getArchived()) {
136
-            throw new CardArchivedException();
137
-        }
138
-        $this->cardMapper->assignLabel($cardId, $labelId);
139
-    }
140
-
141
-    public function removeLabel($cardId, $labelId) {
142
-        $this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
143
-        $card = $this->cardMapper->find($cardId);
144
-        if ($card->getArchived()) {
145
-            throw new CardArchivedException();
146
-        }
147
-        $this->cardMapper->removeLabel($cardId, $labelId);
148
-    }
35
+	private $cardMapper;
36
+
37
+	public function __construct(CardMapper $cardMapper, StackMapper $stackMapper, PermissionService $permissionService) {
38
+		$this->cardMapper = $cardMapper;
39
+		$this->stackMapper = $stackMapper;
40
+		$this->permissionService = $permissionService;
41
+	}
42
+
43
+	public function find($cardId) {
44
+		$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ);
45
+		return $this->cardMapper->find($cardId);
46
+	}
47
+
48
+	public function create($title, $stackId, $type, $order, $owner) {
49
+		$this->permissionService->checkPermission($this->stackMapper, $stackId, Acl::PERMISSION_EDIT);
50
+		$card = new Card();
51
+		$card->setTitle($title);
52
+		$card->setStackId($stackId);
53
+		$card->setType($type);
54
+		$card->setOrder($order);
55
+		$card->setOwner($owner);
56
+		return $this->cardMapper->insert($card);
57
+
58
+	}
59
+
60
+	public function delete($id) {
61
+		$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
62
+		return $this->cardMapper->delete($this->cardMapper->find($id));
63
+	}
64
+
65
+	public function update($id, $title, $stackId, $type, $order, $description, $owner) {
66
+		$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
67
+		$card = $this->cardMapper->find($id);
68
+		if ($card->getArchived()) {
69
+			throw new CardArchivedException();
70
+		}
71
+		$card->setTitle($title);
72
+		$card->setStackId($stackId);
73
+		$card->setType($type);
74
+		$card->setOrder($order);
75
+		$card->setOwner($owner);
76
+		$card->setDescription($description);
77
+		return $this->cardMapper->update($card);
78
+	}
79
+
80
+	public function rename($id, $title) {
81
+		$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
82
+		$card = $this->cardMapper->find($id);
83
+		if ($card->getArchived()) {
84
+			throw new CardArchivedException();
85
+		}
86
+		$card->setTitle($title);
87
+		return $this->cardMapper->update($card);
88
+	}
89
+
90
+	public function reorder($id, $stackId, $order) {
91
+		$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
92
+		$cards = $this->cardMapper->findAll($stackId);
93
+		$result = [];
94
+		$i = 0;
95
+		foreach ($cards as $card) {
96
+			if ($card->getArchived()) {
97
+				throw new CardArchivedException();
98
+			}
99
+			if ($card->id === $id) {
100
+				$card->setOrder($order);
101
+				$card->setLastModified(time());
102
+			}
103
+
104
+			if ($i === $order) {
105
+							$i++;
106
+			}
107
+
108
+			if ($card->id !== $id) {
109
+				$card->setOrder($i++);
110
+			}
111
+			$this->cardMapper->update($card);
112
+			$result[$card->getOrder()] = $card;
113
+		}
114
+
115
+		return $result;
116
+	}
117
+
118
+	public function archive($id) {
119
+		$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
120
+		$card = $this->cardMapper->find($id);
121
+		$card->setArchived(true);
122
+		return $this->cardMapper->update($card);
123
+	}
124
+
125
+	public function unarchive($id) {
126
+		$this->permissionService->checkPermission($this->cardMapper, $id, Acl::PERMISSION_EDIT);
127
+		$card = $this->cardMapper->find($id);
128
+		$card->setArchived(false);
129
+		return $this->cardMapper->update($card);
130
+	}
131
+
132
+	public function assignLabel($cardId, $labelId) {
133
+		$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
134
+		$card = $this->cardMapper->find($cardId);
135
+		if ($card->getArchived()) {
136
+			throw new CardArchivedException();
137
+		}
138
+		$this->cardMapper->assignLabel($cardId, $labelId);
139
+	}
140
+
141
+	public function removeLabel($cardId, $labelId) {
142
+		$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
143
+		$card = $this->cardMapper->find($cardId);
144
+		if ($card->getArchived()) {
145
+			throw new CardArchivedException();
146
+		}
147
+		$this->cardMapper->removeLabel($cardId, $labelId);
148
+	}
149 149
 }
150 150
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Service/LabelService.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -30,38 +30,38 @@
 block discarded – undo
30 30
 
31 31
 class LabelService {
32 32
 
33
-    private $labelMapper;
33
+	private $labelMapper;
34 34
 
35
-    public function __construct(LabelMapper $labelMapper, PermissionService $permissionService) {
36
-        $this->labelMapper = $labelMapper;
37
-        $this->permissionService = $permissionService;
38
-    }
35
+	public function __construct(LabelMapper $labelMapper, PermissionService $permissionService) {
36
+		$this->labelMapper = $labelMapper;
37
+		$this->permissionService = $permissionService;
38
+	}
39 39
 
40
-    public function find($labelId) {
41
-        $this->permissionService->checkPermission($this->labelMapper, $labelId, Acl::PERMISSION_READ);
42
-        return $this->labelMapper->find($labelId);
43
-    }
40
+	public function find($labelId) {
41
+		$this->permissionService->checkPermission($this->labelMapper, $labelId, Acl::PERMISSION_READ);
42
+		return $this->labelMapper->find($labelId);
43
+	}
44 44
 
45
-    public function create($title, $color, $boardId) {
46
-        $this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE);
47
-        $label = new Label();
48
-        $label->setTitle($title);
49
-        $label->setColor($color);
50
-        $label->setBoardId($boardId);
51
-        return $this->labelMapper->insert($label);
52
-    }
45
+	public function create($title, $color, $boardId) {
46
+		$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE);
47
+		$label = new Label();
48
+		$label->setTitle($title);
49
+		$label->setColor($color);
50
+		$label->setBoardId($boardId);
51
+		return $this->labelMapper->insert($label);
52
+	}
53 53
 
54
-    public function delete($id) {
55
-        $this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE);
56
-        return $this->labelMapper->delete($this->find($id));
57
-    }
54
+	public function delete($id) {
55
+		$this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE);
56
+		return $this->labelMapper->delete($this->find($id));
57
+	}
58 58
 
59
-    public function update($id, $title, $color) {
60
-        $this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE);
61
-        $label = $this->find($id);
62
-        $label->setTitle($title);
63
-        $label->setColor($color);
64
-        return $this->labelMapper->update($label);
65
-    }
59
+	public function update($id, $title, $color) {
60
+		$this->permissionService->checkPermission($this->labelMapper, $id, Acl::PERMISSION_MANAGE);
61
+		$label = $this->find($id);
62
+		$label->setTitle($title);
63
+		$label->setColor($color);
64
+		return $this->labelMapper->update($label);
65
+	}
66 66
 
67 67
 }
68 68
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Service/StackService.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -35,71 +35,71 @@
 block discarded – undo
35 35
 
36 36
 class StackService {
37 37
 
38
-    private $stackMapper;
39
-    private $cardMapper;
40
-    private $labelMapper;
41
-    private $permissionService;
38
+	private $stackMapper;
39
+	private $cardMapper;
40
+	private $labelMapper;
41
+	private $permissionService;
42 42
 
43
-    public function __construct(StackMapper $stackMapper, CardMapper $cardMapper, LabelMapper $labelMapper, PermissionService $permissionService) {
44
-        $this->stackMapper = $stackMapper;
45
-        $this->cardMapper = $cardMapper;
46
-        $this->labelMapper = $labelMapper;
47
-        $this->permissionService = $permissionService;
48
-    }
43
+	public function __construct(StackMapper $stackMapper, CardMapper $cardMapper, LabelMapper $labelMapper, PermissionService $permissionService) {
44
+		$this->stackMapper = $stackMapper;
45
+		$this->cardMapper = $cardMapper;
46
+		$this->labelMapper = $labelMapper;
47
+		$this->permissionService = $permissionService;
48
+	}
49 49
 
50
-    public function findAll($boardId) {
51
-        $this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_READ);
52
-        $stacks = $this->stackMapper->findAll($boardId);
53
-        $labels = $this->labelMapper->getAssignedLabelsForBoard($boardId);
54
-        foreach ($stacks as $stackIndex => $stack) {
55
-            $cards = $this->cardMapper->findAll($stack->id);
56
-            foreach ($cards as $cardIndex => $card) {
57
-            	if (array_key_exists($card->id, $labels)) {
58
-                	$cards[$cardIndex]->setLabels($labels[$card->id]);
50
+	public function findAll($boardId) {
51
+		$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_READ);
52
+		$stacks = $this->stackMapper->findAll($boardId);
53
+		$labels = $this->labelMapper->getAssignedLabelsForBoard($boardId);
54
+		foreach ($stacks as $stackIndex => $stack) {
55
+			$cards = $this->cardMapper->findAll($stack->id);
56
+			foreach ($cards as $cardIndex => $card) {
57
+				if (array_key_exists($card->id, $labels)) {
58
+					$cards[$cardIndex]->setLabels($labels[$card->id]);
59 59
 				}
60
-            }
61
-            $stacks[$stackIndex]->setCards($cards);
62
-        }
63
-        return $stacks;
64
-    }
60
+			}
61
+			$stacks[$stackIndex]->setCards($cards);
62
+		}
63
+		return $stacks;
64
+	}
65 65
 
66
-    public function findAllArchived($boardId) {
67
-        $this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_READ);
68
-        $stacks = $this->stackMapper->findAll($boardId);
69
-        $labels = $this->labelMapper->getAssignedLabelsForBoard($boardId);
70
-        foreach ($stacks as $stackIndex => $stack) {
71
-            $cards = $this->cardMapper->findAllArchived($stack->id);
72
-            foreach ($cards as $cardIndex => $card) {
73
-            	if (array_key_exists($card->id, $labels)) {
66
+	public function findAllArchived($boardId) {
67
+		$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_READ);
68
+		$stacks = $this->stackMapper->findAll($boardId);
69
+		$labels = $this->labelMapper->getAssignedLabelsForBoard($boardId);
70
+		foreach ($stacks as $stackIndex => $stack) {
71
+			$cards = $this->cardMapper->findAllArchived($stack->id);
72
+			foreach ($cards as $cardIndex => $card) {
73
+				if (array_key_exists($card->id, $labels)) {
74 74
 					$cards[$cardIndex]->setLabels($labels[$card->id]);
75 75
 				}
76
-            }
77
-            $stacks[$stackIndex]->setCards($cards);
78
-        }
79
-        return $stacks;
80
-    }
76
+			}
77
+			$stacks[$stackIndex]->setCards($cards);
78
+		}
79
+		return $stacks;
80
+	}
81 81
 
82
-    public function create($title, $boardId, $order) {
83
-        $this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE);
84
-        $stack = new Stack();
85
-        $stack->setTitle($title);
86
-        $stack->setBoardId($boardId);
87
-        $stack->setOrder($order);
88
-        return $this->stackMapper->insert($stack);
82
+	public function create($title, $boardId, $order) {
83
+		$this->permissionService->checkPermission(null, $boardId, Acl::PERMISSION_MANAGE);
84
+		$stack = new Stack();
85
+		$stack->setTitle($title);
86
+		$stack->setBoardId($boardId);
87
+		$stack->setOrder($order);
88
+		return $this->stackMapper->insert($stack);
89 89
 
90
-    }
90
+	}
91 91
 
92
-    public function delete($id) {
93
-        $this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_MANAGE);
94
-        return $this->stackMapper->delete($this->stackMapper->find($id));
95
-    }
92
+	public function delete($id) {
93
+		$this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_MANAGE);
94
+		return $this->stackMapper->delete($this->stackMapper->find($id));
95
+	}
96 96
 
97
-    public function update($id, $title, $boardId, $order) {
98
-        $this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_MANAGE);
99
-        $stack = $this->stackMapper->find($id);
100
-        $stack->setTitle($title);
101
-        $stack->setBoardId($boardId);
102
-        $stack->setOrder($order);
103
-        return $this->stackMapper->update($stack);
104
-    }
97
+	public function update($id, $title, $boardId, $order) {
98
+		$this->permissionService->checkPermission($this->stackMapper, $id, Acl::PERMISSION_MANAGE);
99
+		$stack = $this->stackMapper->find($id);
100
+		$stack->setTitle($title);
101
+		$stack->setBoardId($boardId);
102
+		$stack->setOrder($order);
103
+		return $this->stackMapper->update($stack);
104
+	}
105 105
 }
106 106
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Db/Label.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -28,21 +28,21 @@
 block discarded – undo
28 28
 
29 29
 class Label extends Entity 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
Please login to merge, or discard this patch.
lib/Db/LabelMapper.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -28,44 +28,44 @@  discard block
 block discarded – undo
28 28
 
29 29
 class LabelMapper extends DeckMapper implements IPermissionMapper {
30 30
 
31
-    public function __construct(IDBConnection $db) {
32
-        parent::__construct($db, 'deck_labels', '\OCA\Deck\Db\Label');
33
-    }
31
+	public function __construct(IDBConnection $db) {
32
+		parent::__construct($db, 'deck_labels', '\OCA\Deck\Db\Label');
33
+	}
34 34
 
35
-    public function findAll($boardId, $limit = null, $offset = null) {
36
-        $sql = 'SELECT * FROM `*PREFIX*deck_labels` WHERE `board_id` = ? ORDER BY `id`';
37
-        return $this->findEntities($sql, [$boardId], $limit, $offset);
38
-    }
35
+	public function findAll($boardId, $limit = null, $offset = null) {
36
+		$sql = 'SELECT * FROM `*PREFIX*deck_labels` WHERE `board_id` = ? ORDER BY `id`';
37
+		return $this->findEntities($sql, [$boardId], $limit, $offset);
38
+	}
39 39
 
40
-    public function delete(\OCP\AppFramework\Db\Entity $entity) {
40
+	public function delete(\OCP\AppFramework\Db\Entity $entity) {
41 41
 		// delete assigned labels
42 42
 		$this->deleteLabelAssignments($entity->getId());
43 43
 		// delete label
44
-        return parent::delete($entity);
45
-    }
44
+		return parent::delete($entity);
45
+	}
46 46
 
47
-    public function findAssignedLabelsForCard($cardId, $limit = null, $offset = null) {
48
-        $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';
49
-        return $this->findEntities($sql, [$cardId], $limit, $offset);
50
-    }
51
-    public function findAssignedLabelsForBoard($boardId, $limit = null, $offset = null) {
52
-        $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 " .
53
-            " 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";
54
-        $entities = $this->findEntities($sql, [$boardId], $limit, $offset);
55
-        return $entities;
56
-    }
47
+	public function findAssignedLabelsForCard($cardId, $limit = null, $offset = null) {
48
+		$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';
49
+		return $this->findEntities($sql, [$cardId], $limit, $offset);
50
+	}
51
+	public function findAssignedLabelsForBoard($boardId, $limit = null, $offset = null) {
52
+		$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 " .
53
+			" 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";
54
+		$entities = $this->findEntities($sql, [$boardId], $limit, $offset);
55
+		return $entities;
56
+	}
57 57
 
58
-    public function getAssignedLabelsForBoard($boardId) {
59
-        $labels = $this->findAssignedLabelsForBoard($boardId);
60
-        $result = array();
61
-        foreach ($labels as $label) {
62
-            if (!array_key_exists($label->getCardId(), $result)) {
63
-                $result[$label->getCardId()] = array();
64
-            }
65
-            $result[$label->getCardId()][] = $label;
66
-        }
67
-        return $result;
68
-    }
58
+	public function getAssignedLabelsForBoard($boardId) {
59
+		$labels = $this->findAssignedLabelsForBoard($boardId);
60
+		$result = array();
61
+		foreach ($labels as $label) {
62
+			if (!array_key_exists($label->getCardId(), $result)) {
63
+				$result[$label->getCardId()] = array();
64
+			}
65
+			$result[$label->getCardId()][] = $label;
66
+		}
67
+		return $result;
68
+	}
69 69
 
70 70
 	public function deleteLabelAssignments($labelId) {
71 71
 		$sql = 'DELETE FROM `*PREFIX*deck_assigned_labels` WHERE label_id = ?';
@@ -81,15 +81,15 @@  discard block
 block discarded – undo
81 81
 		$stmt->execute();
82 82
 	}
83 83
 
84
-    public function isOwner($userId, $labelId) {
85
-        $sql = 'SELECT owner FROM `*PREFIX*deck_boards` WHERE `id` IN (SELECT board_id FROM `*PREFIX*deck_labels` WHERE id = ?)';
86
-        $stmt = $this->execute($sql, [$labelId]);
87
-        $row = $stmt->fetch();
88
-        return ($row['owner'] === $userId);
89
-    }
84
+	public function isOwner($userId, $labelId) {
85
+		$sql = 'SELECT owner FROM `*PREFIX*deck_boards` WHERE `id` IN (SELECT board_id FROM `*PREFIX*deck_labels` WHERE id = ?)';
86
+		$stmt = $this->execute($sql, [$labelId]);
87
+		$row = $stmt->fetch();
88
+		return ($row['owner'] === $userId);
89
+	}
90 90
 
91
-    public function findBoardId($labelId) {
92
-        $entity = $this->find($labelId);
93
-        return $entity->getBoardId();
94
-    }
91
+	public function findBoardId($labelId) {
92
+		$entity = $this->find($labelId);
93
+		return $entity->getBoardId();
94
+	}
95 95
 }
Please login to merge, or discard this patch.
lib/Db/AclMapper.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -28,25 +28,25 @@
 block discarded – undo
28 28
 
29 29
 class AclMapper extends DeckMapper implements IPermissionMapper {
30 30
 
31
-    public function __construct(IDBConnection $db) {
32
-        parent::__construct($db, 'deck_board_acl', '\OCA\Deck\Db\Acl');
33
-    }
34
-
35
-    public function findAll($boardId, $limit = null, $offset = null) {
36
-        $sql = 'SELECT id, board_id, type, participant, permission_edit, permission_share, permission_manage FROM `*PREFIX*deck_board_acl` WHERE `board_id` = ? ';
37
-        return $this->findEntities($sql, [$boardId], $limit, $offset);
38
-    }
39
-
40
-    public function isOwner($userId, $aclId) {
41
-        $sql = 'SELECT owner FROM `*PREFIX*deck_boards` WHERE `id` IN (SELECT board_id FROM `*PREFIX*deck_board_acl` WHERE id = ?)';
42
-        $stmt = $this->execute($sql, [$aclId]);
43
-        $row = $stmt->fetch();
44
-        return ($row['owner'] === $userId);
45
-    }
46
-
47
-    public function findBoardId($aclId) {
48
-        $entity = $this->find($aclId);
49
-        return $entity->getBoardId();
50
-    }
31
+	public function __construct(IDBConnection $db) {
32
+		parent::__construct($db, 'deck_board_acl', '\OCA\Deck\Db\Acl');
33
+	}
34
+
35
+	public function findAll($boardId, $limit = null, $offset = null) {
36
+		$sql = 'SELECT id, board_id, type, participant, permission_edit, permission_share, permission_manage FROM `*PREFIX*deck_board_acl` WHERE `board_id` = ? ';
37
+		return $this->findEntities($sql, [$boardId], $limit, $offset);
38
+	}
39
+
40
+	public function isOwner($userId, $aclId) {
41
+		$sql = 'SELECT owner FROM `*PREFIX*deck_boards` WHERE `id` IN (SELECT board_id FROM `*PREFIX*deck_board_acl` WHERE id = ?)';
42
+		$stmt = $this->execute($sql, [$aclId]);
43
+		$row = $stmt->fetch();
44
+		return ($row['owner'] === $userId);
45
+	}
46
+
47
+	public function findBoardId($aclId) {
48
+		$entity = $this->find($aclId);
49
+		return $entity->getBoardId();
50
+	}
51 51
 
52 52
 }
Please login to merge, or discard this patch.
lib/Db/StackMapper.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -29,46 +29,46 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
lib/Db/Card.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -28,41 +28,41 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.