Skip to content
Snippets Groups Projects
Commit 344b7f54 authored by Robin Appelman's avatar Robin Appelman
Browse files

only show songs for which the current user has songs indexed

parent d6d38ac3
Branches
No related tags found
No related merge requests found
...@@ -67,10 +67,12 @@ if($arguments['action']){ ...@@ -67,10 +67,12 @@ if($arguments['action']){
$artists=OC_MEDIA_COLLECTION::getArtists(); $artists=OC_MEDIA_COLLECTION::getArtists();
foreach($artists as &$artist){ foreach($artists as &$artist){
$artist['albums']=OC_MEDIA_COLLECTION::getAlbums($artist['artist_id']); $artist['albums']=OC_MEDIA_COLLECTION::getAlbums($artist['artist_id']);
$artistHasSongs=false;
foreach($artist['albums'] as &$album){ foreach($artist['albums'] as &$album){
$album['songs']=OC_MEDIA_COLLECTION::getSongs($artist['artist_id'],$album['album_id']); $album['songs']=OC_MEDIA_COLLECTION::getSongs($artist['artist_id'],$album['album_id']);
} }
} }
echo json_encode($artists); echo json_encode($artists);
break; break;
case 'scan': case 'scan':
......
...@@ -123,13 +123,14 @@ class OC_MEDIA_COLLECTION{ ...@@ -123,13 +123,14 @@ class OC_MEDIA_COLLECTION{
if(!$exact and $search!='%'){ if(!$exact and $search!='%'){
$search="%$search%"; $search="%$search%";
} }
$query=OC_DB::prepare("SELECT * FROM *PREFIX*media_artists WHERE artist_name LIKE ?"); $query=OC_DB::prepare("SELECT DISTINCT *PREFIX*media_artists.artist_name AS name , *PREFIX*media_artists.artist_id AS id FROM *PREFIX*media_artists
$artists=$query->execute(array($search))->fetchAll(); INNER JOIN *PREFIX*media_songs ON *PREFIX*media_artists.artist_id=*PREFIX*media_songs.song_artist WHERE artist_name LIKE ? AND *PREFIX*media_songs.song_user=?");
if(is_array($artists)){ $artists=$query->execute(array($search,OC_USER::getUser()))->fetchAll();
return $artists; $result=array();
}else{ foreach($artists as $artist){
return array(); $result[$artist['id']]=array('artist_name'=>$artist['name'],'artist_id'=>$artist['id']);
} }
return $result;
} }
/** /**
...@@ -175,11 +176,13 @@ class OC_MEDIA_COLLECTION{ ...@@ -175,11 +176,13 @@ class OC_MEDIA_COLLECTION{
} }
$query=OC_DB::prepare($cmd); $query=OC_DB::prepare($cmd);
$albums=$query->execute($params)->fetchAll(); $albums=$query->execute($params)->fetchAll();
if(is_array($albums)){ $result=array();
return $albums; foreach($albums as $album){
}else{ if(count(self::getSongs($album['album_artist'],$album['album_id']))){
return array(); $result[$album['album_id']]=$album;
}
} }
return $result;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment