mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-03 17:59:21 +02:00
added abilty to display and delete localplay instances
This commit is contained in:
parent
f5a47635bd
commit
ba62ca14b9
7 changed files with 114 additions and 3 deletions
|
@ -129,6 +129,22 @@ class Dba {
|
||||||
return $result;
|
return $result;
|
||||||
} // num_rows
|
} // 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
|
* _connect
|
||||||
* This connects to the database, used by the DBH function
|
* This connects to the database, used by the DBH function
|
||||||
|
|
|
@ -565,6 +565,18 @@ class Localplay {
|
||||||
|
|
||||||
} // current_instance
|
} // 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
|
* add_instance
|
||||||
* This adds a new instance for the current controller type
|
* This adds a new instance for the current controller type
|
||||||
|
@ -575,6 +587,16 @@ class Localplay {
|
||||||
|
|
||||||
} // add_instance
|
} // 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
|
* set_active_instance
|
||||||
* This sets the active instance of the localplay controller
|
* This sets the active instance of the localplay controller
|
||||||
|
|
|
@ -47,7 +47,15 @@ switch ($_REQUEST['action']) {
|
||||||
$localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']);
|
$localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']);
|
||||||
$localplay->add_instance($_POST);
|
$localplay->add_instance($_POST);
|
||||||
break;
|
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':
|
case 'show_songs':
|
||||||
|
$localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'delete_song':
|
case 'delete_song':
|
||||||
|
|
|
@ -127,7 +127,7 @@ class AmpacheMpd extends localplay_controller {
|
||||||
foreach ($data as $key=>$value) {
|
foreach ($data as $key=>$value) {
|
||||||
switch ($key) {
|
switch ($key) {
|
||||||
case 'name':
|
case 'name':
|
||||||
case 'hostname':
|
case 'host':
|
||||||
case 'port':
|
case 'port':
|
||||||
case 'password':
|
case 'password':
|
||||||
${$key} = Dba::escape($value);
|
${$key} = Dba::escape($value);
|
||||||
|
@ -141,7 +141,7 @@ class AmpacheMpd extends localplay_controller {
|
||||||
$user_id = Dba::escape($GLOBALS['user']->id);
|
$user_id = Dba::escape($GLOBALS['user']->id);
|
||||||
|
|
||||||
$sql = "INSERT INTO `localplay_mpd` (`name`,`host`,`port`,`password`,`owner`) " .
|
$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);
|
$db_results = Dba::query($sql);
|
||||||
|
|
||||||
return $db_results;
|
return $db_results;
|
||||||
|
@ -154,6 +154,13 @@ class AmpacheMpd extends localplay_controller {
|
||||||
*/
|
*/
|
||||||
public function delete_instance($uid) {
|
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
|
} // delete_instance
|
||||||
|
|
||||||
|
@ -204,7 +211,7 @@ class AmpacheMpd extends localplay_controller {
|
||||||
public function instance_fields() {
|
public function instance_fields() {
|
||||||
|
|
||||||
$fields['name'] = array('description'=>_('Instance Name'),'type'=>'textbox');
|
$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['port'] = array('description'=>_('Port'),'type'=>'textbox');
|
||||||
$fields['password'] = array('description'=>_('Password'),'type'=>'textbox');
|
$fields['password'] = array('description'=>_('Password'),'type'=>'textbox');
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,18 @@ switch ($_REQUEST['action']) {
|
||||||
} // end whitelist
|
} // end whitelist
|
||||||
|
|
||||||
break;
|
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:
|
default:
|
||||||
$results['rfc3514'] = '0x1';
|
$results['rfc3514'] = '0x1';
|
||||||
break;
|
break;
|
||||||
|
|
45
templates/show_localplay_instances.inc.php
Normal file
45
templates/show_localplay_instances.inc.php
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2001 - 2007 Ampache.org
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; version 2
|
||||||
|
of the License.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
*/
|
||||||
|
?>
|
||||||
|
<?php show_box_top(_('Show Localplay Instances')); ?>
|
||||||
|
<table cellpadding="3" cellspacing="0" class="tabledata">
|
||||||
|
<tr>
|
||||||
|
<?php foreach ($fields as $key=>$field) { ?>
|
||||||
|
<th><?php echo $field['description']; ?></th>
|
||||||
|
<?php } ?>
|
||||||
|
<th><?php echo _('Action'); ?></th>
|
||||||
|
</tr>
|
||||||
|
<?php foreach ($instances as $uid=>$name) {
|
||||||
|
$instance = $localplay->get_instance($uid);
|
||||||
|
?>
|
||||||
|
<tr class="<?php echo flip_class(); ?>" id="localplay_instance_<?php echo $uid; ?>">
|
||||||
|
<?php foreach ($fields as $key=>$field) { ?>
|
||||||
|
<td><?php echo $instance[$key]; ?></td>
|
||||||
|
<?php } ?>
|
||||||
|
<td>
|
||||||
|
<?php echo Ajax::button('?page=localplay&action=delete_instance&instance=' . $uid,'delete',_('Delete'),'delete_instance_' . $uid); ?>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php } ?>
|
||||||
|
</table>
|
||||||
|
<?php show_box_bottom(); ?>
|
|
@ -10,6 +10,7 @@
|
||||||
<li><h4><?php echo _('Localplay'); ?></h4>
|
<li><h4><?php echo _('Localplay'); ?></h4>
|
||||||
<ul class="sb3" id="sb_localplay_info">
|
<ul class="sb3" id="sb_localplay_info">
|
||||||
<li id="sb_localplay_info_add_instance"><a href="<?php echo $web_path; ?>/localplay.php?action=show_add_instance"><?php echo _('Add Instance'); ?></a></li>
|
<li id="sb_localplay_info_add_instance"><a href="<?php echo $web_path; ?>/localplay.php?action=show_add_instance"><?php echo _('Add Instance'); ?></a></li>
|
||||||
|
<li id="sb_localplay_info_show_instances"><a href="<?php echo $web_path; ?>/localplay.php?action=show_instances"><?php echo _('Show instances'); ?></a></li>
|
||||||
<li id="sb_localplay_info_show"><a href="<?php echo $web_path; ?>/localplay.php?action=show_songs"><?php echo _('Show Playlist'); ?></a></li>
|
<li id="sb_localplay_info_show"><a href="<?php echo $web_path; ?>/localplay.php?action=show_songs"><?php echo _('Show Playlist'); ?></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue