From bcad40a05ab2dc2a341a3227e30b96668bce4500 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Thu, 9 Jun 2005 16:34:40 +0000 Subject: New Import --- playlist.php | 299 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 299 insertions(+) create mode 100644 playlist.php (limited to 'playlist.php') diff --git a/playlist.php b/playlist.php new file mode 100644 index 00000000..c92cdb0e --- /dev/null +++ b/playlist.php @@ -0,0 +1,299 @@ +owner); + + if (! isset($playlist->id)) { + show_playlist_access_error($playlist_id, $pluser->username); + } + + echo "
\n"; + echo "$playlist->name
"; + echo "   " . _("owned by") . " $pluser->fullname ($pluser->username)
"; + echo ""; + echo "
"; +} + + +switch($action) { + // Add to a playlist + case 'Add to': + case 'add_to': + if ($playlist_id == 0) { + // Creating a new playlist + $playlist_name = _("New Playlist") . " - " . date("m/j/y, g:i a"); + $playlist->create_playlist($playlist_name, $user->id, 'private'); + } + + if ($type === 'album') { + if ($song_ids = get_songs_from_type($type, $results, $artist_id)) { + $playlist->add_songs($song_ids); + } + } + else { + if (isset($song_ids) && is_array($song_ids)) { + $playlist->add_songs($song_ids); + } + } + show_playlist($playlist->id); + break; + + case 'Create': + $playlist->create_playlist($playlist_name, $user->id, $type); + show_playlists(); + break; + + case 'delete_playlist': + if ($_REQUEST['confirm'] === 'Yes') { + + $playlist->playlist($_REQUEST['playlist_id']); + $playlist->delete(); + show_confirmation("Playlist Deleted","The $playlist->name Playlist has been deleted","playlist.php"); + } + elseif ($_REQUEST['confirm'] === 'No') { + show_songs($playlist->get_songs(), $_REQUEST['playlist_id']); + } + else { + show_confirm_action("Are you sure you want to delete '$playlist->name' playlist?", + "playlist.php", + "action=delete_playlist&playlist_id=$playlist_id"); + } + break; + + case 'edit': + case 'Edit': + show_playlist_edit($playlist); + break; + + case 'new': + show_playlist_create(); + break; + + case 'remove_song': + case 'Remove Selected Tracks': + $playlist->remove_songs($song_ids); + show_songs($playlist->get_songs(), $playlist_id); + break; + + case 'Update': + $playlist->update_type($type); + $playlist->update_name($new_playlist_name); + echo _("Playlist updated."); + break; + + case 'Update Selected': + pl_update_selected(); + break; + case 'import_playlist': + $filename = scrub_in($_REQUEST['filename']); + $catalog = new Catalog(); + if ($catalog->import_m3u($filename)) { + show_confirmation($_REQUEST['playlist_type'] . " Imported",$filename . " was imported as a playlist","playlist.php"); + } // it worked + else { + show_confirmation("Import Failure",$filename . " failed to import correctly, this can be because the file wasn't found or no songs were matched","playlist.php"); + } // it didnt' work + break; + case 'view_list': + case 'view': + case 'View': + show_playlist($playlist->id); + break; + case 'show_import_playlist': + $playlist->show_import(); + break; + case 'set_track_numbers': + case 'Set Track Numbers': + $song_ids = scrub_in($_REQUEST['song']); + foreach ($song_ids as $song_id) { + $track = scrub_in($_REQUEST['tr_' . $song_id]); + $changes[] = array('song_id' => $song_id, 'track' => $track); + } + + $playlist->update_track_numbers($changes); + show_playlist($playlist->id); + break; + + default: + show_playlists(); + +} //switch($action) + +echo "

"; +show_menu_items('Playlists'); + +?> + + + + +has_access(100)) { + // we have to update the current numbers for the artist these were + // for and who they will become + $artists_to_update = array(); + $artists_to_update[] = $artist; + + while ( list($index, $s) = each($song) ) { + $info = get_song_info($s); + $artists_to_update[] = $info->artist; + + if ( $update_artist ) { + $info->artist = $artist; + } + + if ( $update_album ) { + $info->album = $album; + } + + if ( $update_genre ) { + $info->genre = $genre; + } + + // now just update the song in the db and you're good to go + update_song($info->id, $info->title, + $info->artist, $info->album, $info->genre); + + // let's update the local file (if we can) + if ( is_writable($info->file) ) { + $id3 = new id3( $info->file ); + $id3->artists = get_artist_name($info->artist); + $id3->album = get_album_name($info->album); + $genre_info = get_genre($info->genre); + $id3->genre = $genre_info->name; + $id3->genreno = $genre_info->id; + $id3->write(); + } + } + + $artists_to_update = array_unique($artists_to_update); + + foreach ($artists_to_update as $art) { + update_artist_info($art); + } + + header("Location:" . $HTTP_REFERER ); + }//admin access + else { + header("Location:" . conf('web_path') . "/index.php?access=denied" ); + } +} //function pl_update_selected +?> -- cgit