From 84420db434e5b3afe08d4626c38d7cfacc62fb68 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Mon, 21 Apr 2008 01:20:07 +0000 Subject: fixed rating display and rating advanced search, also allow new genre when adding radio station --- docs/CHANGELOG | 2 ++ lib/class/radio.class.php | 7 ++++++- lib/class/random.class.php | 4 ++-- lib/class/rating.class.php | 4 ++-- lib/search.php | 25 +++++++++++++++++++------ radio.php | 6 +++--- search.php | 2 +- server/localplay.ajax.php | 2 +- templates/show_add_live_stream.inc.php | 8 +++++--- templates/show_random.inc.php | 2 +- 10 files changed, 42 insertions(+), 20 deletions(-) diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 76dd2444..ca001da1 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,8 @@ -------------------------------------------------------------------------- v.3.4-Beta3 + - Fixed Rating display and Rating Advanced Search + - Added ability to specify new Genre when adding a Radio Station - Fixed Recently Played to do Distinct over last X rather then distinct over all time - Added update the attempts to correct the charset on the db 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 @@ 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 @@ 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 @@ = '$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; diff --git a/radio.php b/radio.php index 720a81b8..b5eae474 100644 --- a/radio.php +++ b/radio.php @@ -1,7 +1,7 @@ has_access('25')) { + if (!Access::check('interface','25')) { access_denied(); exit; } @@ -35,7 +35,7 @@ switch ($_REQUEST['action']) { break; case 'create': - if (!$GLOBALS['user']->has_access('25') || Config::get('demo_mode')) { + if (!Access::check('interface','25') || Config::get('demo_mode')) { access_denied(); exit; } diff --git a/search.php b/search.php index bc65b8bb..62165041 100644 --- a/search.php +++ b/search.php @@ -1,7 +1,7 @@ - + - + +

+ diff --git a/templates/show_random.inc.php b/templates/show_random.inc.php index 4abae8d2..92c47049 100644 --- a/templates/show_random.inc.php +++ b/templates/show_random.inc.php @@ -1,7 +1,7 @@