|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* ownCloud - Music app |
|
5
|
|
|
* |
|
6
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
7
|
|
|
* later. See the COPYING file. |
|
8
|
|
|
* |
|
9
|
|
|
* @author Gavin E <[email protected]> |
|
10
|
|
|
* @copyright Gavin E 2020 |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace OCA\Music\Db; |
|
14
|
|
|
|
|
15
|
|
|
use OCP\IDBConnection; |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
class BookmarkMapper extends BaseMapper { |
|
18
|
|
|
public function __construct(IDBConnection $db) { |
|
19
|
|
|
parent::__construct($db, 'music_bookmarks', '\OCA\Music\Db\Bookmark', 'comment'); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @param string $condition |
|
24
|
|
|
*/ |
|
25
|
|
|
private function makeSelectQuery($condition=null) { |
|
26
|
|
|
return 'SELECT * ' . |
|
27
|
|
|
'FROM `*PREFIX*music_bookmarks` ' . |
|
28
|
|
|
'WHERE `user_id` = ? ' . $condition; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @param string $userId |
|
33
|
|
|
* @param integer $limit |
|
34
|
|
|
* @param integer $offset |
|
35
|
|
|
* @return Bookmark[] |
|
36
|
|
|
*/ |
|
37
|
|
|
public function findAll($userId, $limit=null, $offset=null) { |
|
38
|
|
|
return $this->findEntities($this->makeSelectQuery(), [ $userId ], $limit, $offset); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param string $userId |
|
43
|
|
|
* @param string $trackId |
|
44
|
|
|
* @param string $position |
|
45
|
|
|
* @param string $comment |
|
46
|
|
|
* @return Bookmark[] |
|
47
|
|
|
*/ |
|
48
|
|
|
public function create($userId, $trackId, $position, $comment) { |
|
49
|
|
|
// ensure no existing record exists |
|
50
|
|
|
$this->remove($userId, $trackId); |
|
51
|
|
|
|
|
52
|
|
|
$bookmark = new Bookmark(); |
|
53
|
|
|
$bookmark->setUserId($userId); |
|
54
|
|
|
$bookmark->setTrackId($trackId); |
|
55
|
|
|
$bookmark->setPosition($position); |
|
56
|
|
|
$bookmark->setComment($comment); |
|
57
|
|
|
|
|
58
|
|
|
return $this->insertOrUpdate($bookmark); |
|
|
|
|
|
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param string $userId |
|
63
|
|
|
* @param string $trackId |
|
64
|
|
|
* @return Bookmark[] |
|
65
|
|
|
*/ |
|
66
|
|
|
public function remove($userId, $trackId) { |
|
67
|
|
|
$sql = 'DELETE FROM `' . $this->getTableName() . '` WHERE `user_id` = ? AND `track_id` = ?'; |
|
68
|
|
|
$this->execute($sql, [ $userId, $trackId ]); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function findPlayQueueBookmark($userId) { |
|
72
|
|
|
$retVal = \array_shift($this->findEntities( |
|
|
|
|
|
|
73
|
|
|
'SELECT * FROM `' . $this->getTableName() . '` WHERE `user_id` = ? AND `track_id` < 0', |
|
74
|
|
|
[ $userId ] |
|
75
|
|
|
)); |
|
76
|
|
|
|
|
77
|
|
|
// remove negative value |
|
78
|
|
|
if ($retVal !== null) { |
|
79
|
|
|
$retVal->trackId = -$retVal->trackId; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
return $retVal; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
public function removePlayQueueBookmarks($userId) { |
|
86
|
|
|
return $this->execute( |
|
87
|
|
|
'DELETE FROM `' . $this->getTableName() . '` WHERE `user_id` = ? AND `track_id` < 0', |
|
88
|
|
|
[ $userId ]); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
protected function findUniqueEntity($entity) { |
|
92
|
|
|
return $this->findEntity( |
|
93
|
|
|
'SELECT * FROM `' . $this->getTableName() . '` WHERE `user_id` = ? AND `track_id` < 0', |
|
94
|
|
|
[ $entity->getUserId(), $entity->getTrackId() ] |
|
95
|
|
|
); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths