diff options
Diffstat (limited to 'lib/class')
-rw-r--r-- | lib/class/localplay.class.php | 2 | ||||
-rw-r--r-- | lib/class/preference.class.php | 2 | ||||
-rw-r--r-- | lib/class/song.class.php | 34 |
3 files changed, 35 insertions, 3 deletions
diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php index 7d793fa1..f11f8089 100644 --- a/lib/class/localplay.class.php +++ b/lib/class/localplay.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 diff --git a/lib/class/preference.class.php b/lib/class/preference.class.php index a844d1b0..1c299a35 100644 --- a/lib/class/preference.class.php +++ b/lib/class/preference.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 diff --git a/lib/class/song.class.php b/lib/class/song.class.php index f53e39f6..454db4a2 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -831,7 +831,7 @@ class Song { * a stream URL taking into account the downsampling mojo and everything * else, this is used or will be used by _EVERYTHING_ */ - function get_url($session_id='',$force_http='') { + public function get_url($session_id='',$force_http='') { /* Define Variables we are going to need */ $user_id = $GLOBALS['user']->id ? scrub_out($GLOBALS['user']->id) : '-1'; @@ -873,6 +873,38 @@ class Song { } // get_url /** + * get_recently_played + * This function returns the last X songs that have been played + * it uses the popular threshold to figure out how many to pull + * it will only return unique object + */ + public static 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'$userlimit " . + "GROUP BY `object_count`.`object_id` " . + "ORDER BY `object_count`.`date` DESC " . + "LIMIT " . intval(Config::get('popular_threshold')); + $db_results = Dba::query($sql); + + $results = array(); + + while ($row = Dba::fetch_assoc($db_results)) { + $results[] = $row; + } + + return $results; + + } // get_recently_played + + /** * native_stream * This returns true/false if this can be nativly streamed */ |