summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-06-11 08:24:05 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-06-11 08:24:05 +0000
commit05c406e1f751ece06a7d54bc636275837f9f0169 (patch)
tree4bb73b8d560c1ad0d0ff6c14f2607251280ce79b /lib
parent689517e332c874ac09bb41398602622a1fc36af8 (diff)
downloadampache-05c406e1f751ece06a7d54bc636275837f9f0169.tar.gz
ampache-05c406e1f751ece06a7d54bc636275837f9f0169.tar.bz2
ampache-05c406e1f751ece06a7d54bc636275837f9f0169.zip
added in user profile, did a little work on the preferences and session, something is fishy with session and tmp_playlist stuff will look into it tomorrow
Diffstat (limited to 'lib')
-rw-r--r--lib/class/tmpplaylist.class.php22
-rw-r--r--lib/song.php8
2 files changed, 28 insertions, 2 deletions
diff --git a/lib/class/tmpplaylist.class.php b/lib/class/tmpplaylist.class.php
index b59417d5..a9110098 100644
--- a/lib/class/tmpplaylist.class.php
+++ b/lib/class/tmpplaylist.class.php
@@ -98,6 +98,28 @@ class tmpPlaylist {
} // get_from_session
/**
+ * get_from_userid
+ * This returns a tmp playlist object based on a userid passed
+ * this is used for the user profiles page
+ */
+ public static function get_from_userid($user_id) {
+
+ // This is a little stupid, because we don't have the user_id in the session or
+ // in the tmp_playlist table we have to do it this way.
+ $client = new User($user_id);
+ $username = Dba::escape($client->username);
+
+ $sql = "SELECT `tmp_playlist`.`id` FROM `tmp_playlist` LEFT JOIN `session` ON `session`.`id`=`tmp_playlist`.`session` " .
+ " WHERE `session`.`username`='$username' ORDER BY `session`.`expire` DESC";
+ $db_results = Dba::query($sql);
+
+ $data = Dba::fetch_assoc($db_results);
+
+ return $data['id'];
+
+ } // get_from_userid
+
+ /**
* get_items
* This returns an array of all object_ids currently in this tmpPlaylist
*/
diff --git a/lib/song.php b/lib/song.php
index 5a26d183..fc987943 100644
--- a/lib/song.php
+++ b/lib/song.php
@@ -82,11 +82,15 @@ function get_songs_from_type($type,$results,$artist_id='') {
* This function returns the last X songs that have been played
* It uses the 'popular' threshold to determine how many to pull
*/
-function get_recently_played() {
+function get_recently_played($user_id='') {
+
+ if ($user_id) {
+ $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' " .
+ "WHERE object_type='song'$user_limit " .
"ORDER by object_count.date DESC " .
"LIMIT " . Config::get('popular_threshold');
$db_results = Dba::query($sql);