diff options
-rwxr-xr-x | docs/CHANGELOG | 5 | ||||
-rw-r--r-- | lib/class/catalog.class.php | 3 | ||||
-rw-r--r-- | lib/class/song.class.php | 111 | ||||
-rw-r--r-- | lib/class/update.class.php | 12 | ||||
-rw-r--r-- | lib/class/vainfo.class.php | 2 | ||||
-rw-r--r-- | lib/general.lib.php | 6 | ||||
-rw-r--r-- | lib/search.php | 38 | ||||
-rw-r--r-- | server/random.ajax.php | 6 |
8 files changed, 95 insertions, 88 deletions
diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 86c17457..8212fe9b 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,11 @@ -------------------------------------------------------------------------- v.3.4-Beta2 + - Fixed search by stars so that it returns the correct results + (Thx alex2008) + - Fixed issue where random didn't end correctly when no results found + - Fixed mime type never being updated on verify and added language + and lyrics to gather from id3v2 - Implemented a semi-working write_tags.inc script limited by getid3() support (Thx tomatopi) - Added limit option to the XML API diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index 34747853..54a45273 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -1161,11 +1161,14 @@ class Catalog { $new_song->title = $results['title']; $new_song->year = $results['year']; $new_song->comment = $results['comment']; + $new_song->language = $results['language']; + $new_song->lyrics = $results['lyrics']; $new_song->bitrate = $results['bitrate']; $new_song->rate = $results['rate']; $new_song->mode = $results['mode']; $new_song->size = $results['size']; $new_song->time = $results['time']; + $new_song->mime = $results['mime']; $new_song->track = $results['track']; $artist = $results['artist']; $album = $results['album']; diff --git a/lib/class/song.class.php b/lib/class/song.class.php index 62054464..07ff73cf 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -326,59 +326,36 @@ class Song { */ public static function compare_song_information($song,$new_song) { - if ($song->title == "No Title Found") { $song->title = false; } - - if (trim($song->title) != trim(stripslashes($new_song->title)) && strlen($new_song->title) > 0) { - $array['change'] = true; - $array['text'] .= "<br />" . _("Title") . " [$song->title] " . _("updated to") . " [$new_song->title]\n"; - } // if title - if ($song->bitrate != $new_song->bitrate) { - $array['change'] = true; - $array['text'] .= "<br />" . _("Bitrate") . " [$song->bitrate] " . _("updated to") . " [$new_song->bitrate]\n"; - } // if bitrate - if ($song->rate != $new_song->rate) { - $array['change'] = true; - $array['text'] .= "<br />" . _("Rate") . " [$song->rate] " . _("updated to") . " [$new_song->rate]\n"; - } // if rate - if ($song->mode != $new_song->mode) { - $array['change'] = true; - $array['text'] .= "<br />" . _("Mode") . " [$song->mode] " . _("updated to") . " [$new_song->mode]\n"; - } // if mode - if ($song->time != $new_song->time) { - $array['change'] = true; - $array['text'] .= "<br />" . _("Time") . " [$song->time] " . _("updated to") . " [$new_song->time]\n"; - } // if time - if ($song->track != $new_song->track) { - $array['change'] = true; - $array['text'] .= "<br />" . _("Track") . " [$song->track] " . _("updated to") . " [$new_song->track]\n"; - } // if track - if ($song->size != $new_song->size) { - $array['change'] = true; - $array['text'] .= "<br />" . _("Filesize") . " [$song->size] " . _("updated to") . " [$new_song->size]\n"; - } // if artist - if ($song->artist != $new_song->artist) { - $array['change'] = true; - $name = $song->get_artist_name(); - $array['text'] .= "<br />" . _("Artist") . " [$name] " . _("updated to") . " [$new_song->f_artist]\n"; - } // if artist - if ($song->album != $new_song->album) { - $array['change'] = true; - $name = $song->get_album_name() . " - " . $song->year; - $array['text'] .= "<br />" . _("Album") . " [$name] " . _("updated to") . " [$new_song->f_album]\n"; - } // if album - if ($song->year != $new_song->year) { - $array['change'] = true; - $array['text'] .= "<br />" . _("Year") . " [$song->year] " . _("updated to") . " [$new_song->year]\n"; - } // if year - if (trim(stripslashes($song->comment)) != trim(stripslashes($new_song->comment))) { - $array['change'] = true; - $array['text'] .= "<br />" . _("Comment") . " [$song->comment] " . _("updated to") . " [$new_song->comment]\n"; - } // if comment - if ($song->genre != $new_song->genre) { - $array['change'] = true; - $name = $song->get_genre_name(); - $array['text'] .= "<br />" . _("Genre") . " [$name] " . _("updated to") . " [$new_song->f_genre]\n"; - } // if genre + // Remove some stuff we don't care about + unset($song->catalog,$song->played,$song->enabled,$song->addition_time,$song->update_time,$song->id,$song->type); + + $string_array = array('title','comment','lyrics'); + + // Pull out all the currently set vars + $fields = get_object_vars($song); + + // Foreach them + foreach ($fields as $key=>$value) { + // If it's a stringie thing + if (in_array($key,$string_array)) { + if (trim(stripslashes($song->$key)) != trim(stripslashes($new_song->$key))) { + $array['change'] = true; + $array['element'][$key] = 'OLD: ' . $song->$key . ' <---> ' . $new_song->$key; + } + } // in array of stringies + + else { + if ($song->$key != $new_song->$key) { + $array['change'] = true; + $array['element'][$key] = '' . $song->$key . ' <---> ' . $new_song->$key; + } + } // end else + + } // end foreach + + if ($array['change']) { + debug_event('song-diff',print_r($array['element'],1),'5','ampache-catalog'); + } return $array; @@ -457,6 +434,9 @@ class Song { self::update_album($new_song->album,$song_id); self::update_year($new_song->year,$song_id); self::update_comment($new_song->comment,$song_id); + self::update_language($new_song->language,$song_id); + self::update_lyrics($new_song->lyrics,$song_id); + self::update_mime($new_song->mime,$song_id); self::update_played(0,$song_id); self::update_utime($song_id); @@ -473,6 +453,26 @@ class Song { } // update_year /** + * update_mime + * This updates the mime type of the song object we're passed + */ + public static function update_mime($new_mime,$song_id) { + + self::_update_item('mime',$new_mime,$song_id,'50'); + + } // update_mime + + /** + * update_language + * This updates the language tag of the song + */ + public static function update_language($new_lang,$song_id) { + + self::_update_ext_item('language',$new_lang,$song_id,'50'); + + } // update_language + + /** * update_comment * updates the comment field */ @@ -634,7 +634,7 @@ class Song { private static function _update_item($field,$value,$song_id,$level) { /* Check them Rights! */ - if (!$GLOBALS['user']->has_access($level)) { return false; } + if (!Access::check('interface',$level)) { return false; } /* Can't update to blank */ if (!strlen(trim($value)) && $field != 'comment') { return false; } @@ -656,7 +656,7 @@ class Song { private static function _update_ext_item($field,$value,$song_id,$level) { /* Check them rights boy! */ - if (!$GLOBALS['user']->has_access($level)) { return false; } + if (!Access::check('interface',$level)) { return false; } $value = Dba::escape($value); @@ -964,7 +964,6 @@ class Song { } // get_genres - } // end of song class ?> diff --git a/lib/class/update.class.php b/lib/class/update.class.php index 75bc8fc3..5be760b4 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -258,6 +258,12 @@ class Update { $version[] = array('version' => '340014','description'=>$update_string); + $update_string = '- Alter Playlist Date Field to fix issues with some MySQL configurations.<br />' . + '- Add Index to Album_Data to improve album art random performance.<br />' . + '- Alter Rating type to correct AVG issue on searching.<br />'; + + //$version[] = array('version' => '340015','description'=>$update_string); + return $version; } // populate_version @@ -1119,9 +1125,13 @@ class Update { $sql = "ALTER TABLE `album_data` ADD INDEX `album_art` `album_id`,`art`(5)"; $db_results = Dba::query($sql); - $sql = "ALTER TABLE `playlist` CHANGE `date` `date` INT ( 11 ) UNSIGNED"; + $sql = "ALTER TABLE `playlist` CHANGE `date` `date` INT ( 11 ) UNSIGNED NOT NULL"; + $db_results = Dba::query($sql); + + $sql = "ALTER TABLE `rating` CHANGE `rating` TINYINT ( 11 ) NOT NULL"; $db_results = Dba::query($sql); + self::set_version('db_version','340015'); } // update_340015 diff --git a/lib/class/vainfo.class.php b/lib/class/vainfo.class.php index e83310e8..a68f90fe 100644 --- a/lib/class/vainfo.class.php +++ b/lib/class/vainfo.class.php @@ -373,8 +373,6 @@ class vainfo { case 'track_number': $array['track'] = $this->_clean_tag($data['0'],$this->_file_encoding); break; - //case 'content_type': - // $array['genre'] = $this->_clean_tag($data['0'],$this->_file_encoding); break; case 'comments': $array['comment'] = $this->_clean_tag($data['0'],$this->_file_encoding); diff --git a/lib/general.lib.php b/lib/general.lib.php index eb4d5ea3..f79153b7 100644 --- a/lib/general.lib.php +++ b/lib/general.lib.php @@ -167,6 +167,8 @@ function clean_tag_info($results,$key,$filename) { $info['track'] = intval($results[$key]['track']); $info['disk'] = intval($results[$key]['disk']); $info['comment'] = Dba::escape(str_replace($clean_array,$wipe_array,$results[$key]['comment'])); + $info['language'] = Dba::escape($results[$key]['language']); + $info['lyrics'] = Dba::escape($results[$key]['lyricist']); /* This are pulled from the info array */ $info['bitrate'] = intval($results['info']['bitrate']); @@ -304,10 +306,6 @@ function get_global_popular($type) { } // end if genre } // end foreach -/* if (count($items) == 0) { - $itemis[''] = "<li style=\"list-style-type: none\"><span class=\"error\">" . _('Not Enough Data') . "</span></li>\n"; - } - */ return $items; } // get_global_popular diff --git a/lib/search.php b/lib/search.php index 2d45018a..03042c10 100644 --- a/lib/search.php +++ b/lib/search.php @@ -102,8 +102,7 @@ function search_song($data,$operator,$method,$limit) { /* Generate BASE SQL */ $where_sql = ''; - $table_sql = ','; - $join_sql = ''; + $table_sql = ''; $group_sql = ' GROUP BY'; $select_sql = ','; @@ -137,26 +136,24 @@ function search_song($data,$operator,$method,$limit) { ) "; } $where_sql .= " ) $operator"; - $join_sql .= "song.album=album2.id AND song.artist=artist2.id AND song.genre=genre2.id AND "; - $table_sql .= "album as album2,artist as artist2, genre as genre2"; + $table_sql .= " LEFT JOIN `album` as `album2` ON `song`.`album`=`album2`.`id`"; + $table_sql .= " LEFT JOIN `artist` as `artist2` ON `song`.`artist`=`artist2`.`id`"; + $table_sql .= " LEFT JOIN `genre` as `genre2` ON `song`.`genre`=`genre2`.`id`"; break; case 'title': $where_sql .= " song.title $value_string $operator"; break; case 'album': $where_sql .= " album.name $value_string $operator"; - $join_sql .= "song.album=album.id AND "; - $table_sql .= "album,"; + $table_sql .= " LEFT JOIN `album` ON `song`.`album`=`album`.`id`"; break; case 'artist': $where_sql .= " artist.name $value_string $operator"; - $join_sql .= "song.artist=artist.id AND "; - $table_sql .= "artist,"; + $table_sql .= " LEFT JOIN `artist` ON `song`.`artist`=`artist`.`id` "; break; case 'genre': $where_sql .= " genre.name $value_string $operator"; - $join_sql .= "song.genre=genre.id AND "; - $table_sql .= "genre,"; + $table_sql .= " LEFT JOIN `genre` ON `song`.`genre`=`genre`.`id`"; break; case 'year': if (empty($data["year2"]) && is_numeric($data["year"])) { @@ -170,14 +167,13 @@ function search_song($data,$operator,$method,$limit) { $where_sql .= " song.file $value_string $operator"; break; case 'comment': - $join_sql .= 'song.id=song_data.song_id AND '; - $table_sql .= 'song_data,'; - $where_sql .= " song_data.comment $value_string $operator"; + $table_sql .= ' INNER JOIN `song_data` ON `song`.`id`=`song_data`.`song_id`'; + $where_sql .= " `song_data`.`comment` $value_string $operator"; break; case 'played': /* This is a 0/1 value so bool it */ $value = make_bool($value); - $where_sql .= " song.played = '$value' $operator"; + $where_sql .= " `song`.`played` = '$value' $operator"; break; case 'minbitrate': $value = intval($value); @@ -185,11 +181,10 @@ function search_song($data,$operator,$method,$limit) { break; case 'rating': $value = intval($value); - $select_sql .= "SUM(rating.rating)/(SELECT COUNT(song.id) FROM song,rating WHERE rating.object_id=song.id AND rating.object_type='song' AND rating.rating >= '$value') AS avgrating,"; - $group_sql .= " rating.rating,"; - $where_sql .= " (rating.rating >= '$value' AND rating.object_type='song')"; - $table_sql .= "rating,"; - $join_sql .= "rating.object_id=song.id AND"; + $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"; default: // Notzing! @@ -200,16 +195,15 @@ function search_song($data,$operator,$method,$limit) { } // foreach data /* Trim off the extra $method's and ,'s then combine the sucka! */ - $table_sql = rtrim($table_sql,','); $where_sql = rtrim($where_sql,$operator); $group_sql = rtrim($group_sql,','); $select_sql = rtrim($select_sql,','); if ($group_sql == ' GROUP BY') { $group_sql = ''; } - $base_sql = "SELECT DISTINCT(song.id) $select_sql FROM song"; + $base_sql = "SELECT DISTINCT(song.id) $select_sql FROM `song`"; - $sql = $base_sql . $table_sql . " WHERE " . $join_sql . " (" . $where_sql . ")" . $group_sql . $limit_sql; + $sql = $base_sql . $table_sql . " WHERE (" . $where_sql . ")" . $group_sql . $limit_sql; /** * Because we might need this for Dynamic Playlist Action diff --git a/server/random.ajax.php b/server/random.ajax.php index 269a6ec6..acc42539 100644 --- a/server/random.ajax.php +++ b/server/random.ajax.php @@ -29,7 +29,7 @@ switch ($_REQUEST['action']) { $album_id = Random::album(); // If we don't get anything stop - if (!$album_id) { break; } + if (!$album_id) { $results['rfc3514'] = '0x1'; break; } $album = new Album($album_id); $songs = $album->get_songs(); @@ -42,7 +42,7 @@ switch ($_REQUEST['action']) { $artist_id = Random::artist(); // If we don't get anything stop - if (!$artist_id) { break; } + if (!$artist_id) { $results['rfc3514'] = '0x1'; break; } $artist = new Artist($artist_id); $songs = $artist->get_songs(); @@ -55,7 +55,7 @@ switch ($_REQUEST['action']) { $playlist_id = Random::playlist(); // If we don't get any results stop right here! - if (!$playlist_id) { break; } + if (!$playlist_id) { $results['rfc3514'] = '0x1'; break; } $playlist = new Playlist($playlist_id); $items = $playlist->get_items(); |