From 41db2472342bd0cdcd572f9f37bca698db6f6d2f Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Mon, 21 Apr 2008 00:28:18 +0000 Subject: fixed shoutbox typo so albums add correctly, can now edit playlist tracks and change their track in the playlist, added batch download link to single playlist view --- docs/CHANGELOG | 4 +++ lib/class/playlist.class.php | 52 +++++++++++---------------- lib/class/song.class.php | 8 ++--- server/browse.ajax.php | 2 +- server/playlist.ajax.php | 39 +++++++++++++++++--- templates/show_edit_playlist_song_row.inc.php | 26 ++++++-------- templates/show_playlist.inc.php | 5 +++ templates/show_playlist_song_row.inc.php | 5 +-- templates/show_playlist_songs.inc.php | 4 +-- templates/show_shoutbox.inc.php | 2 +- 10 files changed, 83 insertions(+), 64 deletions(-) diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 394846bb..76dd2444 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,10 @@ -------------------------------------------------------------------------- v.3.4-Beta3 + - Fixed Recently Played to do Distinct over last X rather then + distinct over all time + - Added update the attempts to correct the charset on the db + columns - Added prompt for input charset to fix_filenames.inc - Updated Links in Readme - Fixed Show Art filter on browse by albums diff --git a/lib/class/playlist.class.php b/lib/class/playlist.class.php index b5cb8f71..02c7d5be 100644 --- a/lib/class/playlist.class.php +++ b/lib/class/playlist.class.php @@ -1,7 +1,7 @@ id); + + $sql = "SELECT * FROM `playlist_data` WHERE `id`='$track_id' AND `playlist`='$playlist_id'"; + $db_results = Dba::query($sql); - $result = mysql_fetch_assoc($db_results); + $row = Dba::fetch_assoc($db_results); - return $result['track']; + return $row; } // get_track @@ -315,23 +319,19 @@ class Playlist { } // update_item /** - * update_track_numbers - * This function takes an array of $array['song_id'] $array['track'] where song_id is really the - * playlist_data.id and updates them + * update_track_number + * This takes a playlist_data.id and a track (int) and updates the track value */ - function update_track_numbers($data) { + public function update_track_number($track_id,$track) { - foreach ($data as $change) { - - $track = sql_escape($change['track']); - $id = sql_escape($change['song_id']); + $playlist_id = Dba::escape($this->id); + $track_id = Dba::escape($track_id); + $track = Dba::escape($track); - $sql = "UPDATE playlist_data SET track='$track' WHERE id='$id'"; - $db_results = mysql_query($sql, dbh()); - - } // end foreach + $sql = "UPDATE `playlist_data` SET `track`='$track' WHERE `id`='$track_id' AND `playlist`='$playlist_id'"; + $db_results = Dba::query($sql); - } // update_track_numbers + } // update_track_number /** * add_songs @@ -461,18 +461,6 @@ class Playlist { } // normalize_tracks - /** - * check_type - * This validates a type to make sure it's legit - */ - function check_type($type) { - - if ($type == 'public' || $type == 'private') { return true; } - - return false; - - } // check_type - /** * delete_track * this deletes a single track, you specify the playlist_data.id here diff --git a/lib/class/song.class.php b/lib/class/song.class.php index 82cb521d..ae3e8c08 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -907,20 +907,18 @@ class Song { $user_limit = " AND `object_count`.`user`='" . Dba::escape($user_id) . "'"; } - $sql = "SELECT `object_count`.`object_id`,`object_count`.`user`,`object_count`.`object_type`, " . "`object_count`.`date` " . "FROM `object_count` " . "WHERE `object_type`='song'$userlimit " . - "GROUP BY `object_count`.`object_id` " . - "ORDER BY `object_count`.`date` DESC " . - "LIMIT " . intval(Config::get('popular_threshold')); + "ORDER BY `object_count`.`date` DESC "; $db_results = Dba::query($sql); $results = array(); while ($row = Dba::fetch_assoc($db_results)) { - $results[] = $row; + $results[$row['object_id']] = $row; + if (count($results) > Config::get('popular_threshold')) { break; } } return $results; diff --git a/server/browse.ajax.php b/server/browse.ajax.php index a3673173..02d6126c 100644 --- a/server/browse.ajax.php +++ b/server/browse.ajax.php @@ -1,7 +1,7 @@ format(); if ($playlist->has_access()) { - $playlist->delete_track($_REQUEST['track']); + $playlist->delete_track($_REQUEST['track_id']); } $object_ids = $playlist->get_items(); @@ -39,9 +39,39 @@ switch ($_REQUEST['action']) { Browse::add_supplemental_object('playlist',$playlist->id); Browse::save_objects($object_ids); Browse::show_objects($object_ids); - $results['browse_content'] = ob_get_contents(); - ob_end_clean(); + $results['browse_content'] = ob_get_clean(); break; + case 'edit_track': + $playlist = new Playlist($_REQUEST['playlist_id']); + if (!$playlist->has_access()) { + $results['rfc3514'] = '0x1'; + break; + } + + // They've got access, show the edit page + $track = $playlist->get_track($_REQUEST['track_id']); + $song = new Song($track['object_id']); + $song->format(); + require_once Config::get('prefix') . '/templates/show_edit_playlist_song_row.inc.php'; + $results['track_' . $track['id']] = ob_get_clean(); + break; + case 'save_track': + $playlist = new Playlist($_REQUEST['playlist_id']); + if (!$playlist->has_access()) { + $results['rfc3514'] = '0x1'; + break; + } + $playlist->format(); + + // They've got access, save this guy and re-display row + $playlist->update_track_number($_GET['track_id'],$_POST['track']); + $track = $playlist->get_track($_GET['track_id']); + $song = new Song($track['object_id']); + $song->format(); + $playlist_track = $track['track']; + require Config::get('prefix') . '/templates/show_playlist_song_row.inc.php'; + $results['track_' . $track['id']] = ob_get_clean(); + break; case 'create': // Pull the current active playlist items $objects = $GLOBALS['user']->playlist->get_items(); @@ -66,8 +96,7 @@ switch ($_REQUEST['action']) { $playlist->format(); ob_start(); require_once Config::get('prefix') . '/templates/show_playlist.inc.php'; - $results['content'] = ob_get_contents(); - ob_end_clean(); + $results['content'] = ob_get_clean(); break; case 'append': // Pull the current active playlist items diff --git a/templates/show_edit_playlist_song_row.inc.php b/templates/show_edit_playlist_song_row.inc.php index 520b2fb6..8a8d612c 100644 --- a/templates/show_edit_playlist_song_row.inc.php +++ b/templates/show_edit_playlist_song_row.inc.php @@ -19,29 +19,23 @@ */ ?> - -
+ + - - - - + + + + + +
- - - artist); ?> - - album); ?> - - genre); ?> - - + f_link; ?>f_artist_link; ?>f_album_link; ?>f_genre_link; ?>f_track; ?>f_time; ?> - id . '&type=song','download',_('Save Changes'),'save_song_' . $song->id,'edit_song_' . $song->id); ?> + id . '&track_id=' . $track['id'],'download',_('Save Changes'),'save_track_' . $track['id'],'edit_track_' . $track['id']); ?>
diff --git a/templates/show_playlist.inc.php b/templates/show_playlist.inc.php index 190ea033..f04326fd 100644 --- a/templates/show_playlist.inc.php +++ b/templates/show_playlist.inc.php @@ -27,6 +27,11 @@
  • + +
  • + +
  • +
  • id,_('Add All'),'play_playlist'); ?>
  • id,_('Add Random'),'play_playlist_random'); ?>
diff --git a/templates/show_playlist_song_row.inc.php b/templates/show_playlist_song_row.inc.php index dd92f0fb..f3345dd7 100644 --- a/templates/show_playlist_song_row.inc.php +++ b/templates/show_playlist_song_row.inc.php @@ -1,7 +1,7 @@ has_access()) { ?> - id . '&track=' . $object['track_id'],'delete',_('Delete'),'track_del_' . $object['track_id']); ?> + id . '&track_id=' . $object['track_id'],'edit',_('Edit'),'track_edit_' . $object['track_id']); ?> + id . '&track_id=' . $object['track_id'],'delete',_('Delete'),'track_del_' . $object['track_id']); ?> diff --git a/templates/show_playlist_songs.inc.php b/templates/show_playlist_songs.inc.php index b0ba1e95..a2ee62f3 100644 --- a/templates/show_playlist_songs.inc.php +++ b/templates/show_playlist_songs.inc.php @@ -1,7 +1,7 @@ format(); $playlist_track = $object['track']; ?> - + diff --git a/templates/show_shoutbox.inc.php b/templates/show_shoutbox.inc.php index 9a9c149c..cdb53f03 100644 --- a/templates/show_shoutbox.inc.php +++ b/templates/show_shoutbox.inc.php @@ -31,7 +31,7 @@ ?>
get_image(); ?> - object_type .' &id=' . $shout->object_id,'add',_('Add'),'add_' . $shout->object_type . '_' . $shout->object_id); ?> + object_type .'&id=' . $shout->object_id,'add',_('Add'),'add_' . $shout->object_type . '_' . $shout->object_id); ?> f_link; ?> f_link; ?> date); ?> text); ?> -- cgit