diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2008-03-21 04:43:48 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2008-03-21 04:43:48 +0000 |
commit | 260b62361e031b3a0d4261e892170f294825ed61 (patch) | |
tree | 9ba79b0c5ac498c4cfd1caf896baa1d1caab7a84 /lib | |
parent | 06652fe0406b45732ad80a3ab08c7d97bae4b47c (diff) | |
download | ampache-260b62361e031b3a0d4261e892170f294825ed61.tar.gz ampache-260b62361e031b3a0d4261e892170f294825ed61.tar.bz2 ampache-260b62361e031b3a0d4261e892170f294825ed61.zip |
fixed recently played, removed a bunch of useless files, added new methods to api as requested by dev, fixed some minor issues with enabling of localplay methods
Diffstat (limited to 'lib')
-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 | ||||
-rw-r--r-- | lib/init.php | 2 | ||||
-rw-r--r-- | lib/rss.php | 2 | ||||
-rw-r--r-- | lib/song.php | 77 |
6 files changed, 36 insertions, 83 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 */ diff --git a/lib/init.php b/lib/init.php index fb0f1d9e..58d846db 100644 --- a/lib/init.php +++ b/lib/init.php @@ -119,7 +119,6 @@ define('INIT_LOADED','1'); // Library and module includes we can't do with the autoloader require_once $prefix . '/lib/album.lib.php'; require_once $prefix . '/lib/artist.lib.php'; -require_once $prefix . '/lib/song.php'; require_once $prefix . '/lib/search.php'; require_once $prefix . '/lib/preferences.php'; require_once $prefix . '/lib/rss.php'; @@ -132,7 +131,6 @@ require_once $prefix . '/lib/stream.lib.php'; require_once $prefix . '/lib/xmlrpc.php'; require_once $prefix . '/lib/class/localplay.abstract.php'; require_once $prefix . '/modules/xmlrpc/xmlrpc.inc'; -require_once $prefix . '/modules/catalog.php'; require_once $prefix . '/modules/getid3/getid3.php'; require_once $prefix . '/modules/infotools/Snoopy.class.php'; require_once $prefix . '/modules/infotools/AmazonSearchEngine.class.php'; diff --git a/lib/rss.php b/lib/rss.php index 99c7ebaf..fb72022f 100644 --- a/lib/rss.php +++ b/lib/rss.php @@ -178,7 +178,7 @@ switch ($type) { case "recentlyplayed": $time_unit = array('',_('seconds ago'),_('minutes ago'),_('hours ago'),_('days ago'),_('weeks ago'),_('months ago'),_('years ago')); - $recent = get_recently_played(); + $recent = Song::get_recently_played(); echo " <channel>\n <title>$rss_recentlyplayed_title</title>\n"; echo " <link>$web_path</link>\n <description>$rss_main_description</description>\n"; diff --git a/lib/song.php b/lib/song.php deleted file mode 100644 index c9262e56..00000000 --- a/lib/song.php +++ /dev/null @@ -1,77 +0,0 @@ -<?php -/* - - Copyright (c) 2001 - 2006 Ampache.org - All Rights Reserved - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License v2 - as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -/** - * Song Library - * This is for functions that don't make sense in the class because we aren't looking - * at a specific song... these should be general function that return arrays of songs - * and the like - */ - -/** - * get_recently_played - * 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($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'$user_limit " . - "ORDER by object_count.date DESC " . - "LIMIT " . Config::get('popular_threshold'); - $db_results = Dba::query($sql); - - $results = array(); - - while ($r = Dba::fetch_assoc($db_results)) { - $results[] = $r; - } - - return $results; - -} // get_recently_played - - -/** - * get_song_id_from_file - * This function takes a filename and returns it's best guess for a song id - * It is used by some of the localplay methods to go from filename to ampache - * song record for items that are manualy entered into the clients - */ -function get_song_id_from_file($filename) { - - $filename = Dba::escape($filename); - - $sql = "SELECT `id` FROM `song` WHERE `file` LIKE '%$filename'"; - $db_results = Dba::query($sql); - - $results = Dba::fetch_assoc($db_results); - - return $results['id']; - -} // get_song_id_from_file - -?> |