summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-07-09 19:32:21 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-07-09 19:32:21 +0000
commit17ff1d5f0f60e29cf12509be663c6f7b2c97893a (patch)
tree26059e0676ee28cd87181334634869f5f3fff11e /lib
parentc5d6e04d114d3c4b3f31743ccd0d4a60c9ef9632 (diff)
downloadampache-17ff1d5f0f60e29cf12509be663c6f7b2c97893a.tar.gz
ampache-17ff1d5f0f60e29cf12509be663c6f7b2c97893a.tar.bz2
ampache-17ff1d5f0f60e29cf12509be663c6f7b2c97893a.zip
fixed song class
Diffstat (limited to 'lib')
-rw-r--r--lib/class/song.class.php11
-rw-r--r--lib/song.php34
2 files changed, 40 insertions, 5 deletions
diff --git a/lib/class/song.class.php b/lib/class/song.class.php
index 47600ee5..8349208d 100644
--- a/lib/class/song.class.php
+++ b/lib/class/song.class.php
@@ -44,6 +44,7 @@ class Song {
var $type;
var $mime;
var $played;
+ var $enabled;
var $addition_time;
var $update_time;
@@ -85,7 +86,7 @@ class Song {
$this->flaguser = $info->flaguser;
$this->flagtype = $info->flagtype;
$this->flagcomment = $info->flagcomment;
- $this->status = $info->status;
+ $this->enabled = $info->enabled;
// Format the Type of the song
$this->format_type();
@@ -105,7 +106,7 @@ class Song {
/* Grab the basic information from the catalog and return it */
$sql = "SELECT song.id,file,catalog,album,song.comment,year,artist,".
- "title,bitrate,rate,mode,size,time,track,genre,played,status,update_time,".
+ "title,bitrate,rate,mode,size,time,track,genre,played,song.enabled,update_time,".
"addition_time,flagged.id as flagid,flagged.user as flaguser,flagged.type ".
"as flagtype,flagged.date as flagdate,flagged.comment as flagcomment FROM ".
"song LEFT JOIN flagged ON song.id = flagged.song WHERE song.id = '$this->id'";
@@ -327,7 +328,7 @@ class Song {
$this->update_album($new_song->album,$song_id);
$this->update_year($new_song->year,$song_id);
$this->update_comment($new_song->comment,$song_id);
- $this->update_played('false',$song_id);
+ $this->update_played(0,$song_id);
$this->update_utime($song_id);
} // update_song
@@ -505,7 +506,7 @@ class Song {
function update_enabled($new_enabled,$song_id=0) {
if ($_SESSION['userdata']['access'] === 'admin' || $_SESSION['userdata']['access'] === '100') {
- $this->update_item('status',$new_enabled,$song_id);
+ $this->update_item('enabled',$new_enabled,$song_id);
}
} // update_enabled
@@ -575,7 +576,7 @@ class Song {
// Set style
if (preg_match("/id3/", $this->flagtype)) { $this->f_style = "style=\"color: #33c;\""; }
elseif (preg_match("/(mp3|del|sort|ren)/", $this->flagtype)) { $this->f_style = "style=\"color: #C00;\""; }
- if ($this->status === 'disabled') { $this->f_style = "style=\"text-decoration: line-through;\""; }
+ if (!$this->enabled) { $this->f_style = "style=\"text-decoration: line-through;\""; }
return true;
diff --git a/lib/song.php b/lib/song.php
index 0e847ad9..7c9a3282 100644
--- a/lib/song.php
+++ b/lib/song.php
@@ -53,5 +53,39 @@ function format_song($song) {
} // format_song
+/**
+ * get_popular_songs
+ * This returns the current popular songs
+ * @package Stream
+ * @catagory Get
+ */
+function get_popular_songs( $threshold, $type, $user_id = '' ) {
+
+ $dbh = dbh();
+
+ if ( $type == 'your' ) {
+ $sql = "SELECT object_id FROM object_count" .
+ " WHERE object_type = 'song'" .
+ " AND userid = '$user_id'" .
+ " ORDER BY count DESC LIMIT $threshold";
+ }
+ else {
+ $sql = "SELECT object_id FROM object_count" .
+ " WHERE object_type = 'song'" .
+ " ORDER BY count DESC LIMIT $threshold";
+ }
+
+ $db_result = mysql_query($sql, $dbh);
+ $songs = array();
+
+ while ( $id = mysql_fetch_array($db_result) ) {
+ $songs[] = $id[0];
+ }
+
+ return $songs;
+
+} // get_popular_songs()
+
+
?>