summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-04-21 01:20:07 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-04-21 01:20:07 +0000
commit84420db434e5b3afe08d4626c38d7cfacc62fb68 (patch)
tree7b898af106878b65be5b86856714258c23008dd2 /lib
parent41db2472342bd0cdcd572f9f37bca698db6f6d2f (diff)
downloadampache-84420db434e5b3afe08d4626c38d7cfacc62fb68.tar.gz
ampache-84420db434e5b3afe08d4626c38d7cfacc62fb68.tar.bz2
ampache-84420db434e5b3afe08d4626c38d7cfacc62fb68.zip
fixed rating display and rating advanced search, also allow new genre when adding radio station
Diffstat (limited to 'lib')
-rw-r--r--lib/class/radio.class.php7
-rw-r--r--lib/class/random.class.php4
-rw-r--r--lib/class/rating.class.php4
-rw-r--r--lib/search.php25
4 files changed, 29 insertions, 11 deletions
diff --git a/lib/class/radio.class.php b/lib/class/radio.class.php
index 7665c887..99232944 100644
--- a/lib/class/radio.class.php
+++ b/lib/class/radio.class.php
@@ -1,7 +1,7 @@
<?php
/*
- Copyright 2001 - 2007 Ampache.org
+ Copyright Ampache.org
All Rights Reserved
This program is free software; you can redistribute it and/or
@@ -168,6 +168,11 @@ class Radio {
Error::add('url','Invalid URL must be http:// or https://');
}
+ // If they specified other try to use that
+ if (strlen($data['other_genre'])) {
+ $data['genre'] = Catalog::check_genre($data['other_genre']);
+ }
+
// Make sure it's a real genre
$genre = new Genre($data['genre']);
if (!$genre->name) {
diff --git a/lib/class/random.class.php b/lib/class/random.class.php
index 8a042bad..0865f23f 100644
--- a/lib/class/random.class.php
+++ b/lib/class/random.class.php
@@ -1,7 +1,7 @@
<?php
/*
- Copyright 2001 - 2007 Ampache.org
+ Copyright Ampache.org
All Rights Reserved
This program is free software; you can redistribute it and/or
@@ -281,7 +281,7 @@ class Random {
} // end if matchlist
switch ($data['random_type']) {
- case 'full_aldum':
+ case 'full_album':
$query = "SELECT `album`.`id` FROM `song` INNER JOIN `album` ON `song`.`album`=`album`.`id` " .
"WHERE $where GROUP BY `song`.`album` ORDER BY RAND() $limit_sql";
$db_results = Dba::query($query);
diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php
index d844cea1..51555c10 100644
--- a/lib/class/rating.class.php
+++ b/lib/class/rating.class.php
@@ -1,7 +1,7 @@
<?php
/*
- Copyright (c) 2001 - 2008 Ampache.org
+ Copyright (c) Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
@@ -45,7 +45,7 @@ class Rating {
$this->type = Dba::escape($type);
// Check for the users rating
- if ($rating == $this->get_user($GLOBALS['user']->id)) {
+ if ($rating = $this->get_user($GLOBALS['user']->id)) {
$this->rating = $rating;
$this->preciserating = $rating;
}
diff --git a/lib/search.php b/lib/search.php
index 03042c10..b5d300a0 100644
--- a/lib/search.php
+++ b/lib/search.php
@@ -1,7 +1,7 @@
<?php
/*
- Copyright (c) 2001 - 2006 ampache.org
+ Copyright (c) Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
@@ -181,11 +181,24 @@ function search_song($data,$operator,$method,$limit) {
break;
case 'rating':
$value = intval($value);
- $select_sql .= "AVG(`rating`.`rating`) AS avgrating,";
- $group_sql .= " rating.object_id,";
- $where_sql .= " (`rating`.`rating` >= '$value' AND `rating`.`object_type`='song')";
- $table_sql .= " RIGHT JOIN `rating` ON `rating`.`object_id`=`song`.`id`";
- $limit_sql .= " ORDER BY avgrating DESC";
+
+ // This is a little more complext, pull a list of IDs that have this average rating
+ $rating_sql = "SELECT `object_id`,AVG(`rating`.`rating`) AS avgrating FROM `rating` " .
+ "WHERE `object_type`='song' GROUP BY `object_id`";
+ $db_results = Dba::query($rating_sql);
+
+ $where_sql .= " `song`.`id` IN (";
+ $end_rating = '';
+
+ while ($row = Dba::fetch_assoc($db_results)) {
+ if ($row['avgrating'] < $value) { continue; }
+ $where_sql .= $row['object_id'] . ',';
+ $end_rating = ") $operator";
+ }
+
+ $where_sql = rtrim($where_sql,"`song`.`id` IN (");
+ $where_sql = rtrim($where_sql,",") . $end_rating;
+
default:
// Notzing!
break;