From f89098d3ac6ea2045f34c586d1433ca40e6df9c7 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Sun, 9 Sep 2007 22:17:13 +0000 Subject: [PATCH] few more tweaks to localplay, added in the mpd table creation mojo, just need to finish install and then build the interface --- admin/modules.php | 10 ++++++++++ lib/class/localplay.class.php | 16 ++++++++++++++++ modules/localplay/httpq.controller.php | 2 -- modules/localplay/mpd.controller.php | 19 +++++++++++++++++++ templates/show_localplay_controllers.inc.php | 11 ++++++++++- 5 files changed, 55 insertions(+), 3 deletions(-) diff --git a/admin/modules.php b/admin/modules.php index 38466139..d5eb3db9 100644 --- a/admin/modules.php +++ b/admin/modules.php @@ -54,6 +54,16 @@ switch ($_REQUEST['action']) { $title = _('Module Deactivated'); $body = ''; show_confirmation($title,$body,$url); + break; + case 'install_localplay': + + + break; + case 'confirm_uninstall_localplay': + + break; + case 'uninstall_localplay': + break; case 'install_plugin': /* Verify that this plugin exists */ diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php index d9d19841..d2611609 100644 --- a/lib/class/localplay.class.php +++ b/lib/class/localplay.class.php @@ -57,6 +57,22 @@ class Localplay { } // _get_info + /** + * player_loaded + * This returns true / false if the player load + * failed / worked + */ + public function player_loaded() { + + if (is_object($this->_player)) { + return true; + } + else { + return false; + } + + } // player_loaded + /** * format * This makes the localplay/plugin information diff --git a/modules/localplay/httpq.controller.php b/modules/localplay/httpq.controller.php index 3ceb8c04..7e812792 100644 --- a/modules/localplay/httpq.controller.php +++ b/modules/localplay/httpq.controller.php @@ -107,7 +107,6 @@ class AmpacheHttpq extends localplay_controller { */ public function is_installed() { - } // is_installed /** @@ -117,7 +116,6 @@ class AmpacheHttpq extends localplay_controller { public function install() { - } // install /** diff --git a/modules/localplay/mpd.controller.php b/modules/localplay/mpd.controller.php index 8e067960..1ca7b4f5 100644 --- a/modules/localplay/mpd.controller.php +++ b/modules/localplay/mpd.controller.php @@ -109,6 +109,10 @@ class AmpacheMpd extends localplay_controller { */ public function is_installed() { + $sql = "DESCRIBE `localplay_mpd`"; + $db_results = Dba::query($sql); + + return Dba::num_rows($db_results); } // is_installed @@ -118,7 +122,18 @@ class AmpacheMpd extends localplay_controller { */ public function install() { + /* We need to create the MPD table */ + $sql = "CREATE TABLE `localplay_mpd` ( `id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , " . + "`name` VARCHAR( 128 ) NOT NULL , " . + "`owner` INT( 11 ) NOT NULL , " . + "`host` VARCHAR( 255 ) NOT NULL , " . + "`port` INT( 11 ) UNSIGNED NOT NULL DEFAULT '6600', " . + "`password` VARCHAR( 255 ) NOT NULL , " . + "`access` SMALLINT( 4 ) UNSIGNED NOT NULL DEFAULT '0' " . + ") ENGINE = MYISAM"; + $db_results = Dba::query($sql); + return true; } // install @@ -128,6 +143,10 @@ class AmpacheMpd extends localplay_controller { */ public function uninstall() { + $sql = "DROP TABLE `localplay_mpd`"; + $db_results = Dba::query($sql); + + return true; } // uninstall diff --git a/templates/show_localplay_controllers.inc.php b/templates/show_localplay_controllers.inc.php index 3a45b481..cfbe7e30 100644 --- a/templates/show_localplay_controllers.inc.php +++ b/templates/show_localplay_controllers.inc.php @@ -31,13 +31,22 @@ $web_path = Config::get('web_path'); player_loaded()) { continue; } $localplay->format(); + if ($localplay->is_enabled()) { + $action = 'confirm_uninstall_localplay'; + $action_txt = _('Disable'); + } + else { + $action = 'install_localplay'; + $action_txt = _('Activate'); + } ?> f_name); ?> f_description); ?> f_version); ?> - + type); ?>">