summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-12-25 07:47:52 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-12-25 07:47:52 +0000
commitd6003655a9b266eeb20c15d53d77da873e9a6642 (patch)
tree60849827334171ebf4d50601416e91c3dd2e9f7b /lib
parent15f3664049d962820140bdf359a52dae5d143a0c (diff)
downloadampache-d6003655a9b266eeb20c15d53d77da873e9a6642.tar.gz
ampache-d6003655a9b266eeb20c15d53d77da873e9a6642.tar.bz2
ampache-d6003655a9b266eeb20c15d53d77da873e9a6642.zip
added new album option on song edit (Thx Picasso)
Diffstat (limited to 'lib')
-rw-r--r--lib/class/song.class.php15
-rw-r--r--lib/javascript-base.js10
-rw-r--r--lib/ui.lib.php24
3 files changed, 45 insertions, 4 deletions
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 = '<input type="textbox" name="album_name" value="New Album" />';
+ } 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 "<select name=\"$name\">\n";
+function show_album_select($name='album',$album_id=0,$allow_add=0,$song_id=0) {
+ // Probably superfluous code to ensure we never generate two album_select
+ // elements with the same ID on the same page.
+ static $id_inc;
+ static $keys;
+ if (!isset($keys)) $keys = array();
+ if (!isset($id_inc)) $id_inc = 1;
+ else $id_inc++;
+ $key = "album_select_$song_id";
+ if (!empty($keys[$key])) $key = "album_select_$name";
+ if (!empty($keys[$key])) $key = "album_select_x$id_inc";
+ if (!empty($keys[$key])) $key = "album_select_{$name}_x{$id_inc}";
+ $keys[$key] = true;
+
+ // Added ID field so we can easily observe this element
+ echo "<select name=\"$name\" id=\"$key\">\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<option value=\"-1\">Add New...</option>\n";
+ }
+
echo "</select>\n";
} // show_album_select