This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * @copyright Copyright (c) 2016 Julius Härtl <[email protected]> |
||
4 | * |
||
5 | * @author Julius Härtl <[email protected]> |
||
6 | * |
||
7 | * @license GNU AGPL version 3 or any later version |
||
8 | * |
||
9 | * This program is free software: you can redistribute it and/or modify |
||
10 | * it under the terms of the GNU Affero General Public License as |
||
11 | * published by the Free Software Foundation, either version 3 of the |
||
12 | * License, or (at your option) any later version. |
||
13 | * |
||
14 | * This program is distributed in the hope that it will be useful, |
||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
17 | * GNU Affero General Public License for more details. |
||
18 | * |
||
19 | * You should have received a copy of the GNU Affero General Public License |
||
20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
21 | * |
||
22 | */ |
||
23 | |||
24 | namespace OCA\Deck\Db; |
||
25 | |||
26 | use OCP\AppFramework\Db\Entity; |
||
27 | use OCP\IDBConnection; |
||
28 | |||
29 | |||
30 | class LabelMapper extends DeckMapper implements IPermissionMapper { |
||
31 | |||
32 | public function __construct(IDBConnection $db) { |
||
33 | parent::__construct($db, 'deck_labels', Label::class); |
||
0 ignored issues
–
show
|
|||
34 | } |
||
35 | |||
36 | public function findAll($boardId, $limit = null, $offset = null) { |
||
37 | $sql = 'SELECT * FROM `*PREFIX*deck_labels` WHERE `board_id` = ? ORDER BY `id`'; |
||
38 | return $this->findEntities($sql, [$boardId], $limit, $offset); |
||
0 ignored issues
–
show
The method
OCP\AppFramework\Db\Mapper::findEntities() has been deprecated with message: 14.0.0 Move over to QBMapper
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead. ![]() |
|||
39 | } |
||
40 | |||
41 | public function delete(\OCP\AppFramework\Db\Entity $entity) { |
||
42 | // delete assigned labels |
||
43 | $this->deleteLabelAssignments($entity->getId()); |
||
44 | // delete label |
||
45 | return parent::delete($entity); |
||
0 ignored issues
–
show
The method
OCP\AppFramework\Db\Mapper::delete() has been deprecated with message: 14.0.0 Move over to QBMapper
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead. ![]() |
|||
46 | } |
||
47 | |||
48 | public function findAssignedLabelsForCard($cardId, $limit = null, $offset = null) { |
||
49 | $sql = 'SELECT l.*,card_id 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'; |
||
50 | return $this->findEntities($sql, [$cardId], $limit, $offset); |
||
0 ignored issues
–
show
The method
OCP\AppFramework\Db\Mapper::findEntities() has been deprecated with message: 14.0.0 Move over to QBMapper
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead. ![]() |
|||
51 | } |
||
52 | public function findAssignedLabelsForBoard($boardId, $limit = null, $offset = null) { |
||
53 | $sql = 'SELECT c.id as card_id, l.id as id, l.title as title, l.color as color FROM `*PREFIX*deck_cards` as c ' . |
||
54 | ' INNER JOIN `*PREFIX*deck_assigned_labels` as al ON al.card_id = c.id INNER JOIN `*PREFIX*deck_labels` as l ON al.label_id = l.id WHERE board_id=? ORDER BY l.id'; |
||
55 | return $this->findEntities($sql, [$boardId], $limit, $offset); |
||
0 ignored issues
–
show
The method
OCP\AppFramework\Db\Mapper::findEntities() has been deprecated with message: 14.0.0 Move over to QBMapper
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead. ![]() |
|||
56 | } |
||
57 | |||
58 | public function insert(Entity $entity) { |
||
59 | $entity->setLastModified(time()); |
||
60 | return parent::insert($entity); |
||
0 ignored issues
–
show
The method
OCP\AppFramework\Db\Mapper::insert() has been deprecated with message: 14.0.0 Move over to QBMapper
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead. ![]() |
|||
61 | } |
||
62 | |||
63 | public function update(Entity $entity, $updateModified = true) { |
||
64 | if ($updateModified) { |
||
65 | $entity->setLastModified(time()); |
||
66 | } |
||
67 | return parent::update($entity); |
||
0 ignored issues
–
show
The method
OCP\AppFramework\Db\Mapper::update() has been deprecated with message: 14.0.0 Move over to QBMapper
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead. ![]() |
|||
68 | } |
||
69 | |||
70 | |||
71 | public function getAssignedLabelsForBoard($boardId) { |
||
72 | $labels = $this->findAssignedLabelsForBoard($boardId); |
||
73 | $result = array(); |
||
74 | foreach ($labels as $label) { |
||
75 | if (!array_key_exists($label->getCardId(), $result)) { |
||
76 | $result[$label->getCardId()] = array(); |
||
77 | } |
||
78 | $result[$label->getCardId()][] = $label; |
||
79 | } |
||
80 | return $result; |
||
81 | } |
||
82 | |||
83 | View Code Duplication | public function deleteLabelAssignments($labelId) { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
84 | $sql = 'DELETE FROM `*PREFIX*deck_assigned_labels` WHERE label_id = ?'; |
||
85 | $stmt = $this->db->prepare($sql); |
||
86 | $stmt->bindParam(1, $labelId, \PDO::PARAM_INT); |
||
87 | $stmt->execute(); |
||
88 | } |
||
89 | |||
90 | View Code Duplication | public function deleteLabelAssignmentsForCard($cardId) { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
91 | $sql = 'DELETE FROM `*PREFIX*deck_assigned_labels` WHERE card_id = ?'; |
||
92 | $stmt = $this->db->prepare($sql); |
||
93 | $stmt->bindParam(1, $cardId, \PDO::PARAM_INT); |
||
94 | $stmt->execute(); |
||
95 | } |
||
96 | |||
97 | View Code Duplication | public function isOwner($userId, $labelId) { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
98 | $sql = 'SELECT owner FROM `*PREFIX*deck_boards` WHERE `id` IN (SELECT board_id FROM `*PREFIX*deck_labels` WHERE id = ?)'; |
||
99 | $stmt = $this->execute($sql, [$labelId]); |
||
100 | $row = $stmt->fetch(); |
||
101 | return ($row['owner'] === $userId); |
||
102 | } |
||
103 | |||
104 | public function findBoardId($labelId) { |
||
105 | $entity = $this->find($labelId); |
||
106 | return $entity->getBoardId(); |
||
107 | } |
||
108 | } |
||
109 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.