summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-04-21 00:28:18 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-04-21 00:28:18 +0000
commit41db2472342bd0cdcd572f9f37bca698db6f6d2f (patch)
tree742102e58f80f1e8b715efb9ac34a4d8e8a589cf
parentd642b02e2d03c920ce8fa77cff33f24e1f407021 (diff)
downloadampache-41db2472342bd0cdcd572f9f37bca698db6f6d2f.tar.gz
ampache-41db2472342bd0cdcd572f9f37bca698db6f6d2f.tar.bz2
ampache-41db2472342bd0cdcd572f9f37bca698db6f6d2f.zip
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
-rwxr-xr-xdocs/CHANGELOG4
-rw-r--r--lib/class/playlist.class.php52
-rw-r--r--lib/class/song.class.php8
-rw-r--r--server/browse.ajax.php2
-rw-r--r--server/playlist.ajax.php39
-rw-r--r--templates/show_edit_playlist_song_row.inc.php26
-rw-r--r--templates/show_playlist.inc.php5
-rw-r--r--templates/show_playlist_song_row.inc.php5
-rw-r--r--templates/show_playlist_songs.inc.php4
-rw-r--r--templates/show_shoutbox.inc.php2
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 @@
<?php
/*
- Copyright (c) 2001 - 2007 Ampache.org
+ Copyright (c) Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
@@ -106,16 +106,20 @@ class Playlist {
/**
* get_track
- * Takes a playlist_data.id and returns the current track value for said entry
+ * Returns the single item on the playlist and all of it's information, restrict
+ * it to this Playlist
*/
- function get_track($id) {
+ public function get_track($track_id) {
- $sql = "SELECT track FROM playlist_data WHERE id='" . sql_escape($id) . "'";
- $db_results = mysql_query($sql, dbh());
+ $track_id = Dba::escape($track_id);
+ $playlist_id = Dba::escape($this->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
@@ -462,18 +462,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 @@
<?php
/*
- Copyright (c) 2001 - 2007 Ampache.org
+ Copyright (c) Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
diff --git a/server/playlist.ajax.php b/server/playlist.ajax.php
index bfd32967..12cd7a70 100644
--- a/server/playlist.ajax.php
+++ b/server/playlist.ajax.php
@@ -30,7 +30,7 @@ switch ($_REQUEST['action']) {
$playlist = new Playlist($_REQUEST['playlist_id']);
$playlist->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 @@
*/
?>
-<td colspan="8">
-<form method="post" id="edit_song_<?php echo $song->id; ?>" action="#">
+<td colspan="9">
+<form method="post" id="edit_track_<?php echo $track['id']; ?>" action="javascript:void(0);">
<table class="inline-edit" cellpadding="3" cellspacing="0">
<tr>
<td>
- <input type="textbox" name="name" value="<?php echo scrub_out($song->title); ?>" />
-</td>
-<td>
- <?php show_artist_select('artist',$song->artist); ?>
-</td>
-<td>
- <?php show_album_select('album',$song->album); ?>
-</td>
-<td>
- <?php show_genre_select('genre',$song->genre); ?>
-</td>
-<td>
- <input type="textbox" name="track" size="3" value="<?php echo scrub_out($song->track); ?>" />
+ <input type="textbox" name="track" size="3" maxlength="4" value="<?php echo intval($track['track']); ?>" />
</td>
+<td class="cel_song"><?php echo $song->f_link; ?></td>
+<td class="cel_artist"><?php echo $song->f_artist_link; ?></td>
+<td class="cel_album"><?php echo $song->f_album_link; ?></td>
+<td class="cel_genre"><?php echo $song->f_genre_link; ?></td>
+<td class="cel_track"><?php echo $song->f_track; ?></td>
+<td class="cel_time"><?php echo $song->f_time; ?></td>
<td>
<input type="hidden" name="id" value="<?php echo $song->id; ?>" />
<input type="hidden" name="type" value="song" />
- <?php echo Ajax::button('?action=edit_object&id=' . $song->id . '&type=song','download',_('Save Changes'),'save_song_' . $song->id,'edit_song_' . $song->id); ?>
+ <?php echo Ajax::button('?page=playlist&action=save_track&playlist_id=' . $playlist->id . '&track_id=' . $track['id'],'download',_('Save Changes'),'save_track_' . $track['id'],'edit_track_' . $track['id']); ?>
</td>
</tr>
</table>
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 @@
<div id="information_actions">
<ul>
<li><a href="<?php echo Config::get('web_path'); ?>/playlist.php?action=normalize_tracks&amp;playlist_id=<?php echo $playlist->id; ?>"><?php echo _('Normalize Tracks'); ?></a></li>
+ <?php if (Access::check_function('batch_download')) { ?>
+ <li><a href="<?php echo Config::get('web_path'); ?>/batch.php?action=playlist&amp;id=<?php echo $playlist->id; ?>">
+ <?php echo get_user_icon('batch_download',_('Batch Download')); ?>
+ </a></li>
+ <?php } ?>
<li><?php echo Ajax::text('?action=basket&type=playlist&id=' . $playlist->id,_('Add All'),'play_playlist'); ?></li>
<li><?php echo Ajax::text('?action=basket&type=playlist_random&id=' . $playlist->id,_('Add Random'),'play_playlist_random'); ?></li>
</ul>
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 @@
<?php
/*
- Copyright (c) 2001 - 2007 Ampache.org
+ Copyright (c) Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
@@ -34,6 +34,7 @@
</a>
<?php } ?>
<?php if ($playlist->has_access()) { ?>
- <?php echo Ajax::button('?page=playlist&action=delete_track&playlist_id=' . $playlist->id . '&track=' . $object['track_id'],'delete',_('Delete'),'track_del_' . $object['track_id']); ?>
+ <?php echo Ajax::button('?page=playlist&action=edit_track&playlist_id=' . $playlist->id . '&track_id=' . $object['track_id'],'edit',_('Edit'),'track_edit_' . $object['track_id']); ?>
+ <?php echo Ajax::button('?page=playlist&action=delete_track&playlist_id=' . $playlist->id . '&track_id=' . $object['track_id'],'delete',_('Delete'),'track_del_' . $object['track_id']); ?>
<?php } ?>
</td>
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 @@
<?php
/*
- Copyright (c) 2001 - 2007 Ampache.org
+ Copyright (c) Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
@@ -53,7 +53,7 @@ $ajax_url = Config::get('ajax_url');
$song->format();
$playlist_track = $object['track'];
?>
-<tr class="<?php echo flip_class(); ?>" id="song_<?php echo $song->id; ?>">
+<tr class="<?php echo flip_class(); ?>" id="track_<?php echo $object['track_id']; ?>">
<?php require Config::get('prefix') . '/templates/show_playlist_song_row.inc.php'; ?>
</tr>
<?php } ?>
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 @@
?>
<div class="shout <?php echo flip_class(); ?>">
<?php echo $shout->get_image(); ?>
- <?php echo Ajax::button('?action=basket&type=' . $shout->object_type .' &id=' . $shout->object_id,'add',_('Add'),'add_' . $shout->object_type . '_' . $shout->object_id); ?>
+ <?php echo Ajax::button('?action=basket&type=' . $shout->object_type .'&id=' . $shout->object_id,'add',_('Add'),'add_' . $shout->object_type . '_' . $shout->object_id); ?>
<?php echo $object->f_link; ?>
<span class="information"><?php echo $client->f_link; ?> <?php echo date("d/m H:i",$shout->date); ?></span>
<span class="shouttext"><?php echo scrub_out($shout->text); ?></span>