diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-01-18 07:23:39 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-01-18 07:23:39 +0000 |
commit | 1aebb301ed5b9b10cc3c14d5f7463f7be536e2f9 (patch) | |
tree | 25151dbf76bcb2f8e333c08e52f7b53a8e3eb125 /lib | |
parent | db17bc2c13b02caa2ce3e5be7ac2682f7ee1594d (diff) | |
download | ampache-1aebb301ed5b9b10cc3c14d5f7463f7be536e2f9.tar.gz ampache-1aebb301ed5b9b10cc3c14d5f7463f7be536e2f9.tar.bz2 ampache-1aebb301ed5b9b10cc3c14d5f7463f7be536e2f9.zip |
fixed catalog update bug
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/catalog.class.php | 8 | ||||
-rw-r--r-- | lib/class/song.class.php | 87 | ||||
-rw-r--r-- | lib/ui.lib.php | 80 |
3 files changed, 115 insertions, 60 deletions
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index ea04f86f..3d5a0cef 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -1093,8 +1093,6 @@ class Catalog { } // foreach new Songs - //FIXME: Delete Songs that were not updated (gone) - // now delete invalid entries $this->clean_albums(); $this->clean_stats(); @@ -1119,7 +1117,7 @@ class Catalog { if (!$catalog_id) { $catalog_id = $this->id; } - echo "Cleaning the <b>[" . $this->name . "]</b> Catalog...<br /><br />"; + echo "\nCleaning the <b>[" . $this->name . "]</b> Catalog...<br /><br />\n"; flush(); /* Get all songs in this catalog */ @@ -1135,7 +1133,7 @@ class Catalog { /* Stupid little cutesie thing */ $this->count++; if ( !($this->count%conf('catalog_echo_count')) ) { - echo _("Checking") . " $this->count. . . . <br />\n"; + echo _('Checking') . " $this->count. . . . <br />\n"; flush(); } //echos song count @@ -2053,7 +2051,7 @@ class Catalog { $stats_query = mysql_query($stats_qstring,dbh()); $oldstats = array(); //now collect needed data into a array - while ($stats_result = mysql_fetch_array($stats_query,MYSQL_ASSOC)) { + while ($stats_result = mysql_fetch_assoc($stats_query)) { $userid = $stats_result['userid']; $oldstats[$userid]['id'] = $stats_result['id']; $oldstats[$userid]['count'] = $stats_result['count']; diff --git a/lib/class/song.class.php b/lib/class/song.class.php index b722670c..57e1aa3a 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -396,9 +396,8 @@ class Song { */ function update_year($new_year,$song_id=0) { - if ($_SESSION['userdata']['access'] === 'admin') { - $this->update_item('year',$new_year,$song_id); - } + $this->_update_item('year',$new_year,$song_id,'100'); + } // update_year /*! @@ -407,9 +406,8 @@ class Song { */ function update_comment($new_comment,$song_id=0) { - if ($_SESSION['userdata']['access'] === 'admin') { - $this->update_item('comment',$new_comment,$song_id); - } + $this->_update_item('comment',$new_comment,$song_id,'100'); + } // update_comment /*! @@ -418,9 +416,8 @@ class Song { */ function update_title($new_title,$song_id=0) { - if ($_SESSION['userdata']['access'] === 'admin') { - $this->update_item('title',$new_title,$song_id); - } + $this->_update_item('title',$new_title,$song_id,'100'); + } // update_title /*! @@ -429,9 +426,7 @@ class Song { */ function update_bitrate($new_bitrate,$song_id=0) { - if ($_SESSION['userdata']['access'] === 'admin') { - $this->update_item('bitrate',$new_bitrate,$song_id); - } + $this->_update_item('bitrate',$new_bitrate,$song_id,'100'); } // update_bitrate @@ -441,9 +436,7 @@ class Song { */ function update_rate($new_rate,$song_id=0) { - if ($_SESSION['userdata']['access'] === 'admin') { - $this->update_item('rate',$new_rate,$song_id); - } + $this->_update_item('rate',$new_rate,$song_id,'100'); } // update_rate @@ -453,9 +446,7 @@ class Song { */ function update_mode($new_mode,$song_id=0) { - if ($_SESSION['userdata']['access'] === 'admin') { - $this->update_item('mode',$new_mode,$song_id); - } + $this->_update_item('mode',$new_mode,$song_id,'100'); } // update_mode @@ -465,9 +456,7 @@ class Song { */ function update_size($new_size,$song_id=0) { - if ($_SESSION['userdata']['access'] === 'admin') { - $this->update_item('size',$new_size,$song_id); - } + $this->_update_item('size',$new_size,$song_id,'100'); } // update_size @@ -477,9 +466,7 @@ class Song { */ function update_time($new_time,$song_id=0) { - if ($_SESSION['userdata']['access'] === 'admin') { - $this->update_item('time',$new_time,$song_id); - } + $this->_update_item('time',$new_time,$song_id,'100'); } // update_time @@ -489,9 +476,7 @@ class Song { */ function update_track($new_track,$song_id=0) { - if ($_SESSION['userdata']['access'] === 'admin') { - $this->update_item('track',$new_track,$song_id); - } + $this->_update_item('track',$new_track,$song_id,'100'); } // update_track @@ -501,9 +486,7 @@ class Song { */ function update_artist($new_artist,$song_id=0) { - if ($_SESSION['userdata']['access'] === 'admin') { - $this->update_item('artist',$new_artist,$song_id); - } + $this->_update_item('artist',$new_artist,$song_id,'100'); } // update_artist @@ -513,9 +496,7 @@ class Song { */ function update_genre($new_genre,$song_id=0) { - if ($_SESSION['userdata']['access'] === 'admin') { - $this->update_item('genre',$new_genre,$song_id); - } + $this->_update_item('genre',$new_genre,$song_id,'100'); } // update_genre @@ -525,9 +506,7 @@ class Song { */ function update_album($new_album,$song_id=0) { - if ($_SESSION['userdata']['access'] === 'admin') { - $this->update_item('album',$new_album,$song_id); - } + $this->_update_item('album',$new_album,$song_id,'100'); } // update_album @@ -539,9 +518,7 @@ class Song { if (!$time) { $time = time(); } - if ($_SESSION['userdata']['access'] === 'admin') { - $this->update_item('update_time',$time,$song_id); - } + $this->_update_item('update_time',$time,$song_id,'100'); } // update_utime @@ -551,7 +528,7 @@ class Song { */ function update_played($new_played,$song_id=0) { - $this->update_item('played',$new_played,$song_id); + $this->_update_item('played',$new_played,$song_id,'25'); } // update_played @@ -562,22 +539,21 @@ class Song { */ function update_enabled($new_enabled,$song_id=0) { - /* This should really be integrated into the update_item thing */ - if (!$GLOBALS['user']->has_access(100)) { return false; } - - $this->update_item('enabled',$new_enabled,$song_id); + $this->_update_item('enabled',$new_enabled,$song_id,'100'); } // update_enabled - /*! - @function update_item - @discussion this is a generic function that is called - by all the other update functions... - @param $field The field we are updating - @param $value The new value for said field - @param $song_id ID of the song, uses $this->id by default - */ - function update_item($field,$value,$song_id=0) { + /** + * _update_item + * This is a private function that should only be called from within the song class. + * It takes a field, value song id and level. first and foremost it checks the level + * against $GLOBALS['user'] to make sure they are allowed to update this record + * it then updates it and sets $this->{$field} to the new value + */ + function _update_item($field,$value,$song_id=0,$level) { + + /* Check them Rights! */ + if (!$GLOBALS['user']->has_access($level)) { return false; } if (!$song_id) { $song_id = $this->id; } @@ -585,10 +561,11 @@ class Song { $sql = "UPDATE song SET $field='$value' WHERE id='$song_id'"; $db_results = mysql_query($sql, dbh()); - $this->{$field} = $value; - } //update_item + return true; + + } // update_item /*! diff --git a/lib/ui.lib.php b/lib/ui.lib.php index 6b984a01..44a67710 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -1214,4 +1214,84 @@ function show_songs ($song_ids, $playlist, $album=0) { } // show_songs +/** + * show_album_select + * 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"; + + $sql = "SELECT id, name, prefix FROM album ORDER BY name"; + $db_results = mysql_query($sql, dbh()); + + while ($r = mysql_fetch_assoc($db_results)) { + $selected = ''; + $album_name = trim($r['prefix'] . " " . $r['name']); + if ($r['id'] == $album_id) { + $selected = "selected=\"selected\""; + } + + echo "\t<option value=\"" . $r['id'] . "\" $selected>" . scrub_out($album_name) . "</option>\n"; + + } // end while + + echo "</select>\n"; + +} // show_album_select + +/** + * show_artist_select + * This is the same as the album select except it's *gasp* for artists how inventive! + */ +function show_artist_select($name='artist', $artist_id=0) { + + echo "<select name=\"$name\">\n"; + + $sql = "SELECT id, name, prefix FROM artist ORDER BY name"; + $db_results = mysql_query($sql, dbh()); + + while ($r = mysql_fetch_assoc($db_results)) { + $selected = ''; + $artist_name = trim($r['prefix'] . " " . $r['name']); + if ($r['id'] == $artist_id) { + $selected = "selected=\"selected\""; + } + + echo "\t<option value=\"" . $r['id'] . "\" $selected>" . scrub_out($artist_name) . "</option>\n"; + + } // end while + + echo "</select>\n"; + +} // show_artist_select + +/** + * show_genre_select + * It's amazing we have three of these funtions now, this one shows a select of genres and take s name + * and a selected genre... Woot! + */ +function show_genre_select($name='genre',$genre_id=0) { + + echo "<select name=\"$name\">\n"; + + $sql = "SELECT id, name FROM genre ORDER BY name"; + $db_results = mysql_query($sql, dbh()); + + while ($r = mysql_fetch_assoc($db_results)) { + $selected = ''; + $genre_name = $r['name']; + if ($r['id'] == $genre_id) { + $selected = "selected=\"selected\""; + } + + echo "\t<option value=\"" . $r['id'] . "\" $selected>" . scrub_out($genre_name) . "</option>\n"; + + } // end while + + echo "</select>\n"; + +} // show_genre_select + ?> |