|
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 Morris Jobke <[email protected]> |
|
10
|
|
|
* @author Volkan Gezer <[email protected]> |
|
11
|
|
|
* @author Pauli Järvinen <[email protected]> |
|
12
|
|
|
* @copyright Morris Jobke 2014 |
|
13
|
|
|
* @copyright Volkan Gezer 2014 |
|
14
|
|
|
* @copyright Pauli Järvinen 2016 - 2020 |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
namespace OCA\Music\Db; |
|
18
|
|
|
|
|
19
|
|
|
use OCP\IDBConnection; |
|
|
|
|
|
|
20
|
|
|
|
|
21
|
|
|
class PlaylistMapper extends BaseMapper { |
|
22
|
|
|
public function __construct(IDBConnection $db) { |
|
23
|
|
|
parent::__construct($db, 'music_playlists', '\OCA\Music\Db\Playlist', 'name'); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @param string $condition |
|
28
|
|
|
*/ |
|
29
|
|
|
private function makeSelectQuery($condition=null) { |
|
30
|
|
|
return 'SELECT `name`, `id`, `track_ids` ' . |
|
31
|
|
|
'FROM `*PREFIX*music_playlists` ' . |
|
32
|
|
|
'WHERE `user_id` = ? ' . $condition; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @param string $userId |
|
37
|
|
|
* @param integer $sortBy sort order of the result set |
|
38
|
|
|
* @param integer $limit |
|
39
|
|
|
* @param integer $offset |
|
40
|
|
|
* @return Playlist[] |
|
41
|
|
|
*/ |
|
42
|
|
|
public function findAll($userId, $sortBy=SortBy::None, $limit=null, $offset=null) { |
|
43
|
|
|
$sql = $this->makeSelectQuery( |
|
44
|
|
|
$sortBy == SortBy::Name ? 'ORDER BY LOWER(`name`)' : null |
|
45
|
|
|
); |
|
46
|
|
|
return $this->findEntities($sql, [$userId], $limit, $offset); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param string $name |
|
51
|
|
|
* @param string $userId |
|
52
|
|
|
* @param bool $fuzzy |
|
53
|
|
|
* @param integer $limit |
|
54
|
|
|
* @param integer $offset |
|
55
|
|
|
* @return Playlist[] |
|
56
|
|
|
*/ |
|
57
|
|
|
public function findAllByName($name, $userId, $fuzzy = false, $limit=null, $offset=null) { |
|
58
|
|
|
if ($fuzzy) { |
|
59
|
|
|
$condition = 'AND LOWER(`name`) LIKE LOWER(?) '; |
|
60
|
|
|
$name = '%' . $name . '%'; |
|
61
|
|
|
} else { |
|
62
|
|
|
$condition = 'AND `name` = ? '; |
|
63
|
|
|
} |
|
64
|
|
|
$sql = $this->makeSelectQuery($condition . 'ORDER BY LOWER(`name`)'); |
|
65
|
|
|
return $this->findEntities($sql, [$userId, $name], $limit, $offset); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @param int $trackId |
|
70
|
|
|
* @return Playlist[] |
|
71
|
|
|
*/ |
|
72
|
|
|
public function findListsContainingTrack($trackId) { |
|
73
|
|
|
$sql = $this->selectEntities('`track_ids` LIKE ?'); |
|
74
|
|
|
$params = ['%|' . $trackId . '|%']; |
|
75
|
|
|
return $this->findEntities($sql, $params); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @see \OCA\Music\Db\BaseMapper::findUniqueEntity() |
|
80
|
|
|
* @param Playlist $playlist |
|
81
|
|
|
* @return Playlist |
|
82
|
|
|
*/ |
|
83
|
|
|
protected function findUniqueEntity($playlist) { |
|
84
|
|
|
// The playlist table has no unique constraints, and hence, this function |
|
85
|
|
|
// should never be called. |
|
86
|
|
|
throw new \BadMethodCallException('not supported'); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|
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