function send_list_updates($artist_created, $album_created, $ttid, $send = true) { global $mysqlc, $returninfo, $prefs; if (!array_key_exists('inserts', $returninfo)) { $returninfo['inserts'] = array(); } if ($artist_created !== false && $prefs['sortcollectionby'] == "artist") { debuglog("Artist " . $artist_created . " was created", "USER RATING", 8); // We had to create a new albumartist, so we send back the artist HTML header // We need to know the artist details and where in the list it is supposed to go. array_push($returninfo['inserts'], do_artists_from_database('a', $prefs['sortcollectionby'], $artist_created)); } else { if ($album_created !== false) { debuglog("Album " . $album_created . " was created", "USER RATING", 8); // Find the artist $artistid = find_artist_from_album($album_created); if ($artistid === null) { debuglog("ERROR - no artistID found!", "USER RATING", 1); } else { array_push($returninfo['inserts'], do_albums_from_database('a', 'album', $artistid, $album_created, false)); } } else { if ($ttid !== null) { debuglog("Track " . $ttid . " was modified", "USER RATING", 8); $albumid = find_album_from_track($ttid); if ($albumid === null) { debuglog("ERROR - no albumID found!", "USER RATING", 1); } else { array_push($returninfo['inserts'], array('type' => 'insertInto', 'where' => 'aalbum' . $albumid, 'html' => do_tracks_from_database('a', 'album', $albumid, true))); } } } } if ($send) { $returninfo['stats'] = alistheader(get_stat('ArtistCount'), get_stat('AlbumCount'), get_stat('TrackCount'), format_time(get_stat('TotalTime'))); if ($ttid) { $returninfo['metadata'] = get_all_data($ttid); } print json_encode($returninfo); } }
function delete_track($ttid) { global $returninfo; if (remove_ttid($ttid)) { checkAlbumsAndArtists(); remove_cruft(); update_track_stats(); $returninfo['stats'] = alistheader(get_stat('ArtistCount'), get_stat('AlbumCount'), get_stat('TrackCount'), format_time(get_stat('TotalTime'))); print json_encode($returninfo); } else { header('HTTP/1.1 400 Bad Request'); } }