diff --git a/lib/class/dba.class.php b/lib/class/dba.class.php index c2c60fce..3facabd3 100644 --- a/lib/class/dba.class.php +++ b/lib/class/dba.class.php @@ -129,6 +129,22 @@ class Dba { return $result; } // num_rows + /** + * affected_rows + * This emulates the mysql_affected_rows function + */ + public static function affected_rows($resource) { + + $result = mysql_affected_rows($resource); + + if (!$result) { + return '0'; + } + + return $result; + + } // affected_rows + /** * _connect * This connects to the database, used by the DBH function diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php index 6e01bfe0..6f996e3f 100644 --- a/lib/class/localplay.class.php +++ b/lib/class/localplay.class.php @@ -565,6 +565,18 @@ class Localplay { } // current_instance + /** + * get_instance + * This returns the specified instance + */ + public function get_instance($uid) { + + $data = $this->_player->get_instance($uid); + + return $data; + + } // get_instance + /** * add_instance * This adds a new instance for the current controller type @@ -575,6 +587,16 @@ class Localplay { } // add_instance + /** + * delete_instance + * This removes an instance (it actually calls the players function) + */ + public function delete_instance($instance_uid) { + + $this->_player->delete_instance($instance_uid); + + } // delete_instance + /** * set_active_instance * This sets the active instance of the localplay controller diff --git a/localplay.php b/localplay.php index 8ab9ca1c..f43abb26 100644 --- a/localplay.php +++ b/localplay.php @@ -47,7 +47,15 @@ switch ($_REQUEST['action']) { $localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']); $localplay->add_instance($_POST); break; + case 'show_instances': + // First build the localplay object and then get the instances + $localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']); + $instances = $localplay->get_instances(); + $fields = $localplay->get_instance_fields(); + require_once Config::get('prefix') . '/templates/show_localplay_instances.inc.php'; + break; case 'show_songs': + $localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']); break; case 'delete_song': diff --git a/modules/localplay/mpd.controller.php b/modules/localplay/mpd.controller.php index 117c4c33..a35678ae 100644 --- a/modules/localplay/mpd.controller.php +++ b/modules/localplay/mpd.controller.php @@ -127,7 +127,7 @@ class AmpacheMpd extends localplay_controller { foreach ($data as $key=>$value) { switch ($key) { case 'name': - case 'hostname': + case 'host': case 'port': case 'password': ${$key} = Dba::escape($value); @@ -141,7 +141,7 @@ class AmpacheMpd extends localplay_controller { $user_id = Dba::escape($GLOBALS['user']->id); $sql = "INSERT INTO `localplay_mpd` (`name`,`host`,`port`,`password`,`owner`) " . - "VALUES ('$name','$hostname','$port','$password','$user_id')"; + "VALUES ('$name','$host','$port','$password','$user_id')"; $db_results = Dba::query($sql); return $db_results; @@ -153,7 +153,14 @@ class AmpacheMpd extends localplay_controller { * This takes a UID and deletes the instance in question */ public function delete_instance($uid) { + + $uid = Dba::escape($uid); + // Go ahead and delete this mofo! + $sql = "DELETE FROM `localplay_mpd` WHERE `id`='$uid'"; + $db_results = Dba::query($sql); + + return true; } // delete_instance @@ -204,7 +211,7 @@ class AmpacheMpd extends localplay_controller { public function instance_fields() { $fields['name'] = array('description'=>_('Instance Name'),'type'=>'textbox'); - $fields['hostname'] = array('description'=>_('Hostname'),'type'=>'textbox'); + $fields['host'] = array('description'=>_('Hostname'),'type'=>'textbox'); $fields['port'] = array('description'=>_('Port'),'type'=>'textbox'); $fields['password'] = array('description'=>_('Password'),'type'=>'textbox'); diff --git a/server/localplay.ajax.php b/server/localplay.ajax.php index 49212bfd..cefa8009 100644 --- a/server/localplay.ajax.php +++ b/server/localplay.ajax.php @@ -67,6 +67,18 @@ switch ($_REQUEST['action']) { } // end whitelist break; + case 'delete_instance': + // Make sure that you have access to do this... again I really + // don't know what that means so I'm just going to do nothing fo now + + + // Scrub it in + $localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']); + $localplay->delete_instance($_REQUEST['instance']); + + $key = 'localplay_instance_' . $_REQUEST['instance']; + $results[$key] = ''; + break; default: $results['rfc3514'] = '0x1'; break; diff --git a/templates/show_localplay_instances.inc.php b/templates/show_localplay_instances.inc.php new file mode 100644 index 00000000..4c519392 --- /dev/null +++ b/templates/show_localplay_instances.inc.php @@ -0,0 +1,45 @@ + + +
+ + | + |
---|---|
+ + | + + + | +