summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-12-27 00:18:59 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-12-27 00:18:59 +0000
commit6b0b77f12b6873204bfd73a250621115b1f539a0 (patch)
tree36aa24da3e984a3b38e0f1f11fc4a8a2ffdd1973 /lib
parent380a8615ae97295f650699e8ecdf478e54f75d74 (diff)
downloadampache-6b0b77f12b6873204bfd73a250621115b1f539a0.tar.gz
ampache-6b0b77f12b6873204bfd73a250621115b1f539a0.tar.bz2
ampache-6b0b77f12b6873204bfd73a250621115b1f539a0.zip
new coolness from sigger
Diffstat (limited to 'lib')
-rw-r--r--lib/class/rating.class.php10
-rw-r--r--lib/class/update.class.php2
-rw-r--r--lib/ui.lib.php17
3 files changed, 21 insertions, 8 deletions
diff --git a/lib/class/rating.class.php b/lib/class/rating.class.php
index f69e2585..4a513421 100644
--- a/lib/class/rating.class.php
+++ b/lib/class/rating.class.php
@@ -78,17 +78,19 @@ class Rating {
*/
function get_average() {
- $sql = "SELECT rating FROM ratings WHERE object_id='$this->id' AND object_type='$this->type'";
- $db_results = mysql_fetch_assoc($db_results);
+ $sql = "SELECT user_rating as rating FROM ratings WHERE object_id='$this->id' AND object_type='$this->type'";
+ $db_results = mysql_query($sql, dbh());
$i = 0;
while ($r = mysql_fetch_assoc($db_results)) {
$i++;
- $total = $r['rating'];
+ $total += $r['rating'];
} // while we're pulling results
- $average = floor($total/$i);
+ if ($total > 0) {
+ $average = floor($total/$i);
+ }
$this->rating = $average;
diff --git a/lib/class/update.class.php b/lib/class/update.class.php
index 10532321..4d8e59c3 100644
--- a/lib/class/update.class.php
+++ b/lib/class/update.class.php
@@ -1239,7 +1239,7 @@ class Update {
" `user` varchar(128) NOT NULL default ''," .
" `object_type` enum('artist','album','song') NOT NULL default 'artist'," .
" `object_id` int(11) unsigned NOT NULL default '0'," .
- " `rating` enum('00','0','1','2','3','4','5') NOT NULL default '0'," .
+ " `user_rating` enum('00','0','1','2','3','4','5') NOT NULL default '0'," .
" PRIMARY KEY (`id`))";
$db_results = mysql_query($sql, dbh());
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index 81db6419..de906ed3 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -1067,19 +1067,30 @@ function show_preference_box($preferences) {
*
*/
-function show_genre_pulldown ($name,$selected='',$size=1) {
+function show_genre_pulldown ($name,$selected='',$size=1,$width=0,$style='') {
/* Get them genre hippies */
$sql = "SELECT genre.id,genre.name FROM genre ORDER BY genre.name";
$db_result = mysql_query($sql, dbh());
- echo "<select name=\"" . $name . "[]\" multiple=\"multiple\" size=\"$size\">\n";
+ if ($size > 0) {
+ $multiple_txt = "multiple=\"multiple\" size=\"$size\"";
+ }
+ if ($style) {
+ $style_txt = "style=\"$style\"";
+ }
+
+ echo "<select name=\"" . $name . "[]\" $multiple_txt $style_txt>\n";
echo "\t<option value=\"-1\">" . _("All") . "</option>\n";
while ($r = mysql_fetch_assoc($db_result)) {
-
+
$r['name'] = scrub_out($r['name']);
+ if ($width > 0) {
+ $r['name'] = truncate_with_ellipsis($r['name'],$width);
+ }
+
if ( $selected == $r['id'] ) {
echo "\t<option value=\"" . $r['id'] . "\" selected=\"selected\">" . $r['name'] . "</option>\n";
}