From b3950d0c942364ce9ab2e99c6914977158b2a09c Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Sun, 9 Sep 2007 06:13:32 +0000 Subject: new db update, moved prefs around removed useless one and fixed some defaults, also fixed some potential issues with lastfm --- docs/CHANGELOG | 3 +++ lib/class/localplay.class.php | 5 +++- lib/class/scrobbler.class.php | 8 +++++- lib/class/update.class.php | 49 +++++++++++++++++++++++++++++++--- lib/preferences.php | 13 --------- modules/localplay/httpq.controller.php | 2 +- modules/localplay/mpd.controller.php | 2 +- modules/plugins/Lastfm.plugin.php | 6 +++-- modules/plugins/OpenStrands.plugin.php | 4 +-- templates/show_catalogs.inc.php | 2 +- 10 files changed, 68 insertions(+), 26 deletions(-) diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 9fe98eba..0927d824 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,9 @@ -------------------------------------------------------------------------- v.3.4-Alpha3 + - Cleaned up Preferences, moved Plugin Preferences into their own + section + - Fixed potential LastFM issue if invalid data is passed - Added Abstract class for localplay and started work on next generation of localplay support - Moved Catalog functions out of sidebar, back into the content diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php index 3f8dbb8a..e048dd17 100644 --- a/lib/class/localplay.class.php +++ b/lib/class/localplay.class.php @@ -224,6 +224,9 @@ class Localplay { // Load the controller and then check for its preferences $localplay = new Localplay($controller); + // If we can't even load it no sense in going on + if (!isset($localplay->_player)) { return false; } + $preferences = $localplay->get_preferences(); foreach ($preferences as $preference) { @@ -575,7 +578,7 @@ class Localplay { */ public function get_preferences() { - $preferences = $this->_player->preferences(); + $preferences = $this->_player->get_preferences(); return $preferences; diff --git a/lib/class/scrobbler.class.php b/lib/class/scrobbler.class.php index 78c5f36e..dd9775c3 100644 --- a/lib/class/scrobbler.class.php +++ b/lib/class/scrobbler.class.php @@ -181,10 +181,16 @@ class scrobbler { $i++; } - $as_socket = @fsockopen($this->submit_host, $this->submit_port, $errno, $errstr, 5); + if (!trim($this->submit_host) || !$this->submit_port) { + $this->reset_handshake = true; + return false; + } + + $as_socket = @fsockopen($this->submit_host, intval($this->submit_port), $errno, $errstr, 5); if(!$as_socket) { $this->error_msg = $errstr; + $this->reset_handshake = true; return false; } diff --git a/lib/class/update.class.php b/lib/class/update.class.php index 30a8440b..e7b3a03c 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -21,7 +21,7 @@ /** * Update Class * this class handles updating from one version of - * maintain to the next. Versions are a 6 digit number + * ampache to the next. Versions are a 6 digit number * 220000 * ^ * Major Revision @@ -82,8 +82,8 @@ class Update { // If no table if (!Dba::num_rows($db_results)) { - - $version = '310000'; + // They can't upgrade, they are too old + header("Location: test.php"); } // if table isn't found @@ -115,7 +115,7 @@ class Update { /** * need_update * checks to see if we need to update - * maintain at all + * ampache at all */ public static function need_update() { @@ -232,6 +232,12 @@ class Update { $version[] = array('version' => '340009','description' => $update_string); + $update_string = '- Removed Playlist Add preference.
' . + '- Moved Localplay* preferences to options.
' . + '- Tweaked Default Playlist Method.
' . + '- Change wording on Localplay preferences.
'; + $version[] = array('version' => '340010','description'=>$update_string); + return $version; } // populate_version @@ -938,5 +944,40 @@ class Update { } // update_340009 + /** + * update_340010 + * Bunch of minor tweaks to the preference table + */ + public static function update_340010() { + + $sql = "UPDATE `preference` SET `catagory`='options' WHERE `name` LIKE 'localplay_%'"; + $db_results = Dba::query($sql); + + $sql = "DELETE FROM `preference` WHERE `name`='playlist_add'"; + $db_results = Dba::query($sql); + + $sql = "UPDATE `preference` SET `catagory`='plugins' WHERE (`name` LIKE 'mystrands_%' OR `name` LIKE 'lastfm_%') AND `catagory`='options'"; + $db_results = Dba::query($sql); + + $sql = "UPDATE `preference` SET `value`='default' WHERE `name`='playlist_method'"; + $db_results = Dba::query($sql); + + $sql = "UPDATE `preference` SET `description`='Localplay Config' WHERE `name`='localplay_level'"; + $db_results = Dba::query($sql); + + /* Fix every users preferences */ + $sql = "SELECT `id` FROM `user`"; + $db_results = Dba::query($sql); + + User::fix_preferences('-1'); + + while ($r = Dba::fetch_assoc($db_results)) { + User::fix_preferences($r['id']); + } // while results + + self::set_version('db_version','340010'); + + } // update_340010 + } // end update class ?> diff --git a/lib/preferences.php b/lib/preferences.php index b7efc09d..b017803f 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -322,23 +322,10 @@ function create_preference_input($name,$value) { } // foreach themes echo "\n"; break; - case 'random_method': - echo "\n"; - break; case 'mystrands_pass': case 'lastfm_pass': echo ""; break; - case 'playlist_add': - echo "\n"; - break; case 'playlist_method': ${$value} = ' selected="selected"'; echo "