summaryrefslogtreecommitdiffstats
path: root/lib/class
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-07-29 18:49:29 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-07-29 18:49:29 +0000
commitf6121006313be194bc760e27e4af60828c69b38f (patch)
tree6eb5147d6993436e6c1a9de101380163e0c556f2 /lib/class
parent20b425c3ac56d24068f56cfa455e07d5fa26f13d (diff)
downloadampache-f6121006313be194bc760e27e4af60828c69b38f.tar.gz
ampache-f6121006313be194bc760e27e4af60828c69b38f.tar.bz2
ampache-f6121006313be194bc760e27e4af60828c69b38f.zip
fixed album per row update and some warnings on song updates
Diffstat (limited to 'lib/class')
-rw-r--r--lib/class/album.class.php82
-rw-r--r--lib/class/song.class.php38
2 files changed, 80 insertions, 40 deletions
diff --git a/lib/class/album.class.php b/lib/class/album.class.php
index 62e6ac8c..45e03bd9 100644
--- a/lib/class/album.class.php
+++ b/lib/class/album.class.php
@@ -66,19 +66,6 @@ class Album {
// Little bit of formating here
$this->f_name = trim($info['prefix'] . ' ' . $info['name']);
- // Additional data that we are going to need
-
- /*
- $this->songs = $info['song_count'];
- $this->artist_count = $info['artist_count'];
- $this->year = $info['year'];
- $this->artist = trim($info['artist_prefix'] . " " . $info['artist_name']);
- $this->artist_id = $info['art_id'];
- $this->album = $info['album_name'];
- $this->has_art = $info['has_art'];
- $this->prefix = $info['prefix'];
- */
-
return true;
} //constructor
@@ -485,7 +472,7 @@ class Album {
* This takes keywords and performs a search of the Amazon website
* for album art. It returns an array of found objects with mime/url keys
*/
- function get_amazon_art($keywords = '',$limit='') {
+ public function get_amazon_art($keywords = '',$limit='') {
$images = array();
$final_results = array();
@@ -612,7 +599,7 @@ class Album {
return $images;
- } // get_amazon_art()
+ } // get_amazon_art
/**
* get_random_songs
@@ -632,6 +619,55 @@ class Album {
} // get_random_songs
/**
+ * update
+ * This function takes a key'd array of data and updates this object
+ * as needed, and then throws down with a flag
+ */
+ public function update($data) {
+
+ // Sadly we need a catalog object here
+ $catalog = new Catalog();
+
+ $year = $data['year'];
+ $artist = $data['artist'];
+ $name = $data['name'];
+
+ $current_id = $this->id;
+
+ if ($artist != $this->artist_id AND $artist > 0) {
+ // Update every song
+ $songs = $this->get_songs();
+ foreach ($songs as $song_id) {
+ Song::update_artist($artist,$song_id);
+ }
+ $updated = 1;
+ }
+
+ $album_id = $catalog->check_album($name,$year);
+ if ($album_id != $this->id) {
+ if (!is_array($songs)) { $songs = $this->get_songs(); }
+ foreach ($songs as $song_id) {
+ Song::update_album($album_id,$song_id);
+ Song::update_year($year,$song_id);
+ }
+ $current_id = $album_id;
+ $updated = 1;
+ }
+
+ if ($updated) {
+ // Flag all songs
+ foreach ($songs as $song_id) {
+ Flag::add($song_id,'song','retag','Interface Album Update');
+ Song::update_utime($song_id);
+ } // foreach song of album
+ } // if updated
+
+
+ return $current_id;
+
+ } // update
+
+ /**
* clear_art
* clears the album art from the DB
*/
@@ -642,13 +678,12 @@ class Album {
} // clear_art
- /*!
- @function insert_art
- @discussion this takes a string representation of an image
- and inserts it into the database. You must pass the
- mime type as well
- */
- function insert_art($image, $mime) {
+ /**
+ * insert_art
+ * this takes a string representation of an image
+ * and inserts it into the database. You must pass the mime type as well
+ */
+ public function insert_art($image, $mime) {
/* Have to disable this for Demo because people suck and try to
* insert PORN :(
@@ -680,6 +715,9 @@ class Album {
*/
public static function save_resized_art($data,$mime,$album) {
+ // Make sure there's actually something to save
+ if (strlen($data) < '5') { return false; }
+
$data = Dba::escape($data);
$mime = Dba::escape($mime);
$album = Dba::escape($album);
diff --git a/lib/class/song.class.php b/lib/class/song.class.php
index ed1f4036..123d33ad 100644
--- a/lib/class/song.class.php
+++ b/lib/class/song.class.php
@@ -404,7 +404,7 @@ class Song {
$function = 'update_' . $key;
self::$function($value,$this->id);
$this->$key = $value;
- $updated=1;
+ $updated = 1;
}
break;
default:
@@ -414,7 +414,9 @@ class Song {
} // end foreach
// If a field was changed then we need to flag this mofo
- Flag::add($this->id,'song','retag','Interface Update');
+ if ($updated) {
+ Flag::add($this->id,'song','retag','Interface Update');
+ }
return true;
@@ -450,7 +452,7 @@ class Song {
* update_year
* update the year tag
*/
- public function update_year($new_year,$song_id) {
+ public static function update_year($new_year,$song_id) {
self::_update_item('year',$new_year,$song_id,'50');
@@ -460,7 +462,7 @@ class Song {
* update_comment
* updates the comment field
*/
- public function update_comment($new_comment,$song_id) {
+ public static function update_comment($new_comment,$song_id) {
self::_update_ext_item('comment',$new_comment,$song_id,'50');
@@ -470,7 +472,7 @@ class Song {
* update_lyrics
* updates the lyrics field
*/
- public function update_lyrics($new_lyrics,$song_id) {
+ public static function update_lyrics($new_lyrics,$song_id) {
self::_update_ext_item('lyrics',$new_lyrics,$song_id,'50');
@@ -480,7 +482,7 @@ class Song {
* update_title
* updates the title field
*/
- public function update_title($new_title,$song_id) {
+ public static function update_title($new_title,$song_id) {
self::_update_item('title',$new_title,$song_id,'50');
@@ -490,7 +492,7 @@ class Song {
* update_bitrate
* updates the bitrate field
*/
- public function update_bitrate($new_bitrate,$song_id) {
+ public static function update_bitrate($new_bitrate,$song_id) {
self::_update_item('bitrate',$new_bitrate,$song_id,'50');
@@ -500,7 +502,7 @@ class Song {
* update_rate
* updates the rate field
*/
- public function update_rate($new_rate,$song_id) {
+ public static function update_rate($new_rate,$song_id) {
self::_update_item('rate',$new_rate,$song_id,'50');
@@ -510,7 +512,7 @@ class Song {
* update_mode
* updates the mode field
*/
- public function update_mode($new_mode,$song_id) {
+ public static function update_mode($new_mode,$song_id) {
self::_update_item('mode',$new_mode,$song_id,'50');
@@ -520,7 +522,7 @@ class Song {
* update_size
* updates the size field
*/
- public function update_size($new_size,$song_id) {
+ public static function update_size($new_size,$song_id) {
self::_update_item('size',$new_size,$song_id,'50');
@@ -530,7 +532,7 @@ class Song {
* update_time
* updates the time field
*/
- public function update_time($new_time,$song_id) {
+ public static function update_time($new_time,$song_id) {
self::_update_item('time',$new_time,$song_id,'50');
@@ -540,7 +542,7 @@ class Song {
* update_track
* this updates the track field
*/
- public function update_track($new_track,$song_id) {
+ public static function update_track($new_track,$song_id) {
self::_update_item('track',$new_track,$song_id,'50');
@@ -550,7 +552,7 @@ class Song {
* update_artist
* updates the artist field
*/
- public function update_artist($new_artist,$song_id) {
+ public static function update_artist($new_artist,$song_id) {
self::_update_item('artist',$new_artist,$song_id,'50');
@@ -560,7 +562,7 @@ class Song {
* update_genre
* updates the genre field
*/
- public function update_genre($new_genre,$song_id) {
+ public static function update_genre($new_genre,$song_id) {
self::_update_item('genre',$new_genre,$song_id,'50');
@@ -570,7 +572,7 @@ class Song {
* update_album
* updates the album field
*/
- public function update_album($new_album,$song_id) {
+ public static function update_album($new_album,$song_id) {
self::_update_item('album',$new_album,$song_id,'50');
@@ -580,7 +582,7 @@ class Song {
* update_utime
* sets a new update time
*/
- public function update_utime($song_id,$time=0) {
+ public static function update_utime($song_id,$time=0) {
if (!$time) { $time = time(); }
@@ -592,7 +594,7 @@ class Song {
* update_played
* sets the played flag
*/
- public function update_played($new_played,$song_id) {
+ public static function update_played($new_played,$song_id) {
self::_update_item('played',$new_played,$song_id,'25');
@@ -602,7 +604,7 @@ class Song {
* update_enabled
* sets the enabled flag
*/
- public function update_enabled($new_enabled,$song_id) {
+ public static function update_enabled($new_enabled,$song_id) {
self::_update_item('enabled',$new_enabled,$song_id,'75');