summaryrefslogtreecommitdiffstats
path: root/lib
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 /lib
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
Diffstat (limited to 'lib')
-rw-r--r--lib/class/playlist.class.php52
-rw-r--r--lib/class/song.class.php8
2 files changed, 23 insertions, 37 deletions
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;