summaryrefslogtreecommitdiffstats
path: root/lib/class
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-01-13 21:34:56 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-01-13 21:34:56 +0000
commit7e154abae9113055bb935e7b95c55119bfaff208 (patch)
tree97f885a6fc2ad55cc97a5f155dbc243605aac824 /lib/class
parentcba4a991c0f554c2b5e3dec7e882476ff73760bb (diff)
downloadampache-7e154abae9113055bb935e7b95c55119bfaff208.tar.gz
ampache-7e154abae9113055bb935e7b95c55119bfaff208.tar.bz2
ampache-7e154abae9113055bb935e7b95c55119bfaff208.zip
- Fixed search by rating (Thx alex2008)
- Fixed no result return on random methods - Added mime,language & lyrics to catalog updating functions
Diffstat (limited to 'lib/class')
-rw-r--r--lib/class/catalog.class.php3
-rw-r--r--lib/class/song.class.php111
-rw-r--r--lib/class/update.class.php12
-rw-r--r--lib/class/vainfo.class.php2
4 files changed, 69 insertions, 59 deletions
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);