From d6003655a9b266eeb20c15d53d77da873e9a6642 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Tue, 25 Dec 2007 07:47:52 +0000 Subject: added new album option on song edit (Thx Picasso) --- docs/CHANGELOG | 1 + lib/class/song.class.php | 15 ++++++++++++++- lib/javascript-base.js | 10 ++++++++++ lib/ui.lib.php | 24 +++++++++++++++++++++--- templates/show_edit_song_row.inc.php | 4 +++- 5 files changed, 49 insertions(+), 5 deletions(-) diff --git a/docs/CHANGELOG b/docs/CHANGELOG index c2304789..0f8d16bc 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,7 @@ -------------------------------------------------------------------------- v.3.4-Beta1 + - Added 'Add New...' option to Album on Song Edit (Thx picasso) - Fixed multiple login check - Fixed filters applying incorrectly to non-browse displays - Fixed Flash Player issue when Playlist Method wasn't default diff --git a/lib/class/song.class.php b/lib/class/song.class.php index 61ee2b93..19c5c0cf 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -395,7 +395,7 @@ class Song { foreach ($data as $key=>$value) { switch ($key) { case 'title': - case 'album': + #case 'album': case 'artist': case 'genre': case 'track': @@ -407,6 +407,19 @@ class Song { $updated = 1; } break; + case 'album': + if ($value != $this->$key) { + if ($value == -1) { + // Add new album based on album_name + $value = Catalog::check_album($data['album_name']); + } + if ($value) { + self::update_album($value, $this->id); + $this->$key = $value; + $updated = 1; + } + } + break; default: // Rien a faire break; diff --git a/lib/javascript-base.js b/lib/javascript-base.js index 0e9296ba..a51f7323 100644 --- a/lib/javascript-base.js +++ b/lib/javascript-base.js @@ -76,3 +76,13 @@ function popup_art(url) { newwindow=window.open(url, "ampache_art", "menubar=no,toolbar=no,location=no,directories=no"); if (window.focus) {newwindow.focus()} } + +// In-line album editing helper function +function checkAlbum(song) { + if ($('album_select_'+song).options[$('album_select_'+song).selectedIndex].value == -1) { + $('album_select_song_'+song).innerHTML = ''; + } else { + $('album_select_song_'+song).innerHTML = ''; + } +} + diff --git a/lib/ui.lib.php b/lib/ui.lib.php index e932aaae..aa28af36 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -613,9 +613,22 @@ function show_playlist_import() { * This displays a select of every album that we've got in Ampache, (it can be hella long) it's used * by the Edit page, it takes a $name and a $album_id */ -function show_album_select($name='album',$album_id=0) { - - echo "\n"; $sql = "SELECT `id`, `name`, `prefix` FROM `album` ORDER BY `name`"; $db_results = Dba::query($sql); @@ -631,6 +644,11 @@ function show_album_select($name='album',$album_id=0) { } // end while + if ($allow_add) { + // Append additional option to the end with value=-1 + echo "\t\n"; + } + echo "\n"; } // show_album_select diff --git a/templates/show_edit_song_row.inc.php b/templates/show_edit_song_row.inc.php index e3d1a89e..dcd41750 100644 --- a/templates/show_edit_song_row.inc.php +++ b/templates/show_edit_song_row.inc.php @@ -29,7 +29,9 @@ artist); ?> - album); ?> + album,true,$song->id); ?> +
+id,'change','checkAlbum('.$song->id.')'); ?> genre); ?> -- cgit