diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-05-22 02:29:05 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-05-22 02:29:05 +0000 |
commit | d4b700e2fe1eeb47fbea7b61c295eba16f30c41c (patch) | |
tree | e4c7f478d0b20d0cf7823953c67ba238a08b7527 /lib | |
parent | cebb21facc2e2219f1d498def8ee19bbb4b72f7e (diff) | |
download | ampache-d4b700e2fe1eeb47fbea7b61c295eba16f30c41c.tar.gz ampache-d4b700e2fe1eeb47fbea7b61c295eba16f30c41c.tar.bz2 ampache-d4b700e2fe1eeb47fbea7b61c295eba16f30c41c.zip |
added ability to prune empty playlists
Diffstat (limited to 'lib')
-rw-r--r-- | lib/playlist.lib.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/playlist.lib.php b/lib/playlist.lib.php index 253912e0..567391db 100644 --- a/lib/playlist.lib.php +++ b/lib/playlist.lib.php @@ -135,4 +135,33 @@ function get_playlists($type) { } // get_playlists +/** + * prune_empty_playlists + * This function goes through and deletes any playlists which have + * no songs in them. This can only be done by a full admin + */ +function prune_empty_playlists() { + + + $sql = "SELECT playlist.id FROM playlist LEFT JOIN playlist_data ON playlist.id=playlist_data.playlist " . + "WHERE playlist_data.id IS NULL"; + $db_results = mysql_query($sql, dbh()); + + $results = array(); + + while ($r = mysql_fetch_assoc($db_results)) { + $results[] = $r['id']; + } + + /* Delete the Playlists */ + foreach ($results as $playlist_id) { + $playlist = new Playlist($playlist_id); + $playlist->delete(); + } + + return true; + +} // prune_empty_playlists + + ?> |