mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-05 02:39:47 +02:00
fixed playlist name editing, cant change the type or the genre yet, tweaked lastfm so it recovers from errors a little better, fixed a stupid typo....
This commit is contained in:
parent
93e8513b5b
commit
e0811ddab0
8 changed files with 158 additions and 12 deletions
|
@ -252,13 +252,25 @@ class Playlist {
|
||||||
|
|
||||||
} // get_users
|
} // get_users
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update
|
||||||
|
* This function takes a key'd array of data and runs updates
|
||||||
|
*/
|
||||||
|
public function update($data) {
|
||||||
|
|
||||||
|
if ($data['name'] != $this->name) {
|
||||||
|
$this->update_name($data['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // update
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update_type
|
* update_type
|
||||||
* This updates the playlist type, it calls the generic update_item function
|
* This updates the playlist type, it calls the generic update_item function
|
||||||
*/
|
*/
|
||||||
function update_type($new_type) {
|
private function update_type($new_type) {
|
||||||
|
|
||||||
if ($this->_update_item('type',$new_type,'100')) {
|
if ($this->_update_item('type',$new_type,'50')) {
|
||||||
$this->type = $new_type;
|
$this->type = $new_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,9 +280,9 @@ class Playlist {
|
||||||
* update_name
|
* update_name
|
||||||
* This updates the playlist name, it calls the generic update_item function
|
* This updates the playlist name, it calls the generic update_item function
|
||||||
*/
|
*/
|
||||||
function update_name($new_name) {
|
private function update_name($new_name) {
|
||||||
|
|
||||||
if ($this->_update_item('name',$new_name,'100')) {
|
if ($this->_update_item('name',$new_name,'50')) {
|
||||||
$this->name = $new_name;
|
$this->name = $new_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,16 +292,16 @@ class Playlist {
|
||||||
* _update_item
|
* _update_item
|
||||||
* This is the generic update function, it does the escaping and error checking
|
* This is the generic update function, it does the escaping and error checking
|
||||||
*/
|
*/
|
||||||
function _update_item($field,$value,$level) {
|
private function _update_item($field,$value,$level) {
|
||||||
|
|
||||||
if ($GLOBALS['user']->id != $this->user AND !$GLOBALS['user']->has_access($level)) {
|
if ($GLOBALS['user']->id != $this->user AND !$GLOBALS['user']->has_access($level)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$value = sql_escape($value);
|
$value = Dba::escape($value);
|
||||||
|
|
||||||
$sql = "UPDATE playlist SET $field='$value' WHERE id='" . sql_escape($this->id) . "'";
|
$sql = "UPDATE `playlist` SET $field='$value' WHERE `id`='" . Dba::escape($this->id) . "'";
|
||||||
$db_results = mysql_query($sql, dbh());
|
$db_results = Dba::query($sql);
|
||||||
|
|
||||||
return $db_results;
|
return $db_results;
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ class scrobbler {
|
||||||
public $submit_port;
|
public $submit_port;
|
||||||
public $submit_url;
|
public $submit_url;
|
||||||
public $queued_tracks;
|
public $queued_tracks;
|
||||||
|
public $reset_handshake = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -206,16 +207,19 @@ class scrobbler {
|
||||||
$split_response = preg_split("/\r\n\r\n/", $buffer);
|
$split_response = preg_split("/\r\n\r\n/", $buffer);
|
||||||
if(!isset($split_response[1])) {
|
if(!isset($split_response[1])) {
|
||||||
$this->error_msg = 'Did not receive a valid response';
|
$this->error_msg = 'Did not receive a valid response';
|
||||||
|
$this->reset_handshake = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$response = explode("\n", $split_response[1]);
|
$response = explode("\n", $split_response[1]);
|
||||||
if(!isset($response[0])) {
|
if(!isset($response[0])) {
|
||||||
$this->error_msg = 'Unknown error submitting tracks'.
|
$this->error_msg = 'Unknown error submitting tracks'.
|
||||||
"\nDebug output:\n".$buffer;
|
"\nDebug output:\n".$buffer;
|
||||||
|
$this->reset_handshake = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(substr($response[0], 0, 6) == 'FAILED') {
|
if(substr($response[0], 0, 6) == 'FAILED') {
|
||||||
$this->error_msg = $response[0];
|
$this->error_msg = $response[0];
|
||||||
|
$this->reset_handshake = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(substr($response[0], 0, 7) == 'BADAUTH') {
|
if(substr($response[0], 0, 7) == 'BADAUTH') {
|
||||||
|
@ -224,11 +228,13 @@ class scrobbler {
|
||||||
}
|
}
|
||||||
if (substr($response[0],0,10) == 'BADSESSION') {
|
if (substr($response[0],0,10) == 'BADSESSION') {
|
||||||
$this->error_msg = 'Invalid Session passed (' . trim($response[0]) . ')';
|
$this->error_msg = 'Invalid Session passed (' . trim($response[0]) . ')';
|
||||||
|
$this->reset_handshake = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(substr($response[0], 0, 2) != 'OK') {
|
if(substr($response[0], 0, 2) != 'OK') {
|
||||||
$this->error_msg = 'Response Not ok, unknown error'.
|
$this->error_msg = 'Response Not ok, unknown error'.
|
||||||
"\nDebug output:\n".$buffer;
|
"\nDebug output:\n".$buffer;
|
||||||
|
$this->reset_handshake = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,13 +102,24 @@ class AmpacheLastfm {
|
||||||
|
|
||||||
// Create our scrobbler with everything this time and then queue it
|
// Create our scrobbler with everything this time and then queue it
|
||||||
$scrobbler = new scrobbler($this->username,$this->password,$this->hostname,$this->port,$this->path,$this->challenge);
|
$scrobbler = new scrobbler($this->username,$this->password,$this->hostname,$this->port,$this->path,$this->challenge);
|
||||||
|
|
||||||
|
// Check to see if the scrobbling works
|
||||||
if (!$scrobbler->queue_track($song->f_artist_full,$song->f_album_full,$song->title,time(),$song->time,$song->track)) {
|
if (!$scrobbler->queue_track($song->f_artist_full,$song->f_album_full,$song->title,time(),$song->time,$song->track)) {
|
||||||
|
// Depending on the error we might need to do soemthing here
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go ahead and submit it now
|
// Go ahead and submit it now
|
||||||
if (!$scrobbler->submit_tracks()) {
|
if (!$scrobbler->submit_tracks()) {
|
||||||
debug_event('LastFM','Error Submit Failed: ' . $scrobbler->error_msg,'3');
|
debug_event('LastFM','Error Submit Failed: ' . $scrobbler->error_msg,'3');
|
||||||
|
if ($scrobbler->reset_handshake) {
|
||||||
|
debug_event('LastFM','Re-running Handshake due to error','3');
|
||||||
|
$this->set_handshake($user_id);
|
||||||
|
// Try try again
|
||||||
|
if ($scrobbler->submit_tracks()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
define('NO_SESSION','1');
|
define('NO_SESSION','1');
|
||||||
require_once '../lib/init.php';
|
require_once '../lib/init.php';
|
||||||
require_once Config::get('prefix') . '/modules/horde/Browser.php';
|
require_once Config::get('prefix') . '/modules/horde/Browser.php';
|
||||||
|
ob_end_clean();
|
||||||
|
|
||||||
|
|
||||||
/* These parameters had better come in on the url. */
|
/* These parameters had better come in on the url. */
|
||||||
|
|
|
@ -62,9 +62,8 @@ switch ($_REQUEST['action']) {
|
||||||
/* Controls the editing of objects */
|
/* Controls the editing of objects */
|
||||||
case 'show_edit_object':
|
case 'show_edit_object':
|
||||||
|
|
||||||
if (!$GLOBALS['user']->has_access('50')) {
|
// Set the default required level
|
||||||
exit;
|
$level = '50';
|
||||||
}
|
|
||||||
|
|
||||||
switch ($_GET['type']) {
|
switch ($_GET['type']) {
|
||||||
case 'album':
|
case 'album':
|
||||||
|
@ -87,6 +86,15 @@ switch ($_REQUEST['action']) {
|
||||||
$radio = new Radio($_GET['id']);
|
$radio = new Radio($_GET['id']);
|
||||||
$radio->format();
|
$radio->format();
|
||||||
break;
|
break;
|
||||||
|
case 'playlist':
|
||||||
|
$key = 'playlist_row_' . $_GET['id'];
|
||||||
|
$playlist = new Playlist($_GET['id']);
|
||||||
|
$playlist->format();
|
||||||
|
// If the current user is the owner, only user is required
|
||||||
|
if ($playlist->user == $GLOBALS['user']->id) {
|
||||||
|
$level = '25';
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$key = 'rfc3514';
|
$key = 'rfc3514';
|
||||||
echo xml_from_array(array($key=>'0x1'));
|
echo xml_from_array(array($key=>'0x1'));
|
||||||
|
@ -94,6 +102,11 @@ switch ($_REQUEST['action']) {
|
||||||
break;
|
break;
|
||||||
} // end switch on type
|
} // end switch on type
|
||||||
|
|
||||||
|
// Make sure they got them rights
|
||||||
|
if (!$GLOBALS['user']->has_access($level)) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
require Config::get('prefix') . '/templates/show_edit_' . $_GET['type'] . '_row.inc.php';
|
require Config::get('prefix') . '/templates/show_edit_' . $_GET['type'] . '_row.inc.php';
|
||||||
$results[$key] = ob_get_contents();
|
$results[$key] = ob_get_contents();
|
||||||
|
@ -101,8 +114,18 @@ switch ($_REQUEST['action']) {
|
||||||
echo xml_from_array($results);
|
echo xml_from_array($results);
|
||||||
break;
|
break;
|
||||||
case 'edit_object':
|
case 'edit_object':
|
||||||
|
|
||||||
|
$level = '50';
|
||||||
|
|
||||||
|
if ($_POST['type'] = 'playlist') {
|
||||||
|
$playlist = new Playlist($_POST['id']);
|
||||||
|
if ($GLOBALS['user']->id == $playlist->user) {
|
||||||
|
$level = '25';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure we've got them rights
|
// Make sure we've got them rights
|
||||||
if (!$GLOBALS['user']->has_access('50')) {
|
if (!$GLOBALS['user']->has_access($level)) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,6 +154,11 @@ switch ($_REQUEST['action']) {
|
||||||
$song->update($_POST);
|
$song->update($_POST);
|
||||||
$song->format();
|
$song->format();
|
||||||
break;
|
break;
|
||||||
|
case 'playlist':
|
||||||
|
$key = 'playlist_row_' . $_POST['id'];
|
||||||
|
$playlist->update($_POST);
|
||||||
|
$playlist->format();
|
||||||
|
break;
|
||||||
case 'live_stream':
|
case 'live_stream':
|
||||||
$key = 'live_stream_' . $_POST['id'];
|
$key = 'live_stream_' . $_POST['id'];
|
||||||
Radio::update($_POST);
|
Radio::update($_POST);
|
||||||
|
|
36
templates/show_edit_playlist_row.inc.php
Normal file
36
templates/show_edit_playlist_row.inc.php
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?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 v2
|
||||||
|
as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
*/
|
||||||
|
?>
|
||||||
|
<td colspan="5">
|
||||||
|
<form method="post" id="edit_playlist_<?php echo $playlist->id; ?>" action="#">
|
||||||
|
<table border="0" cellpadding="0" cellspacing="0">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<input type="textbox" name="name" size="9" value="<?php echo scrub_out($playlist->name); ?>" />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="hidden" name="id" value="<?php echo $playlist->id; ?>" />
|
||||||
|
<input type="hidden" name="type" value="playlist" />
|
||||||
|
<?php echo Ajax::button('?action=edit_object&id=' . $playlist->id . '&type=playlist','download',_('Save Changes'),'save_playlist_' . $playlist->id,'edit_playlist_' . $playlist->id); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
49
templates/show_edit_playlist_song_row.inc.php
Normal file
49
templates/show_edit_playlist_song_row.inc.php
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<?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 v2
|
||||||
|
as published by the Free Software Foundation.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
*/
|
||||||
|
?>
|
||||||
|
<td colspan="8">
|
||||||
|
<form method="post" id="edit_song_<?php echo $song->id; ?>" action="#">
|
||||||
|
<table border="0" cellpadding="3" cellspacing="0">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<input type="textbox" name="name" value="<?php echo scrub_out($song->title); ?>" />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php show_artist_select('artist',$song->artist); ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php show_album_select('album',$song->album); ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php show_genre_select('genre',$song->genre); ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="textbox" name="track" size="3" value="<?php echo scrub_out($song->track); ?>" />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type="hidden" name="id" value="<?php echo $song->id; ?>" />
|
||||||
|
<input type="hidden" name="type" value="song" />
|
||||||
|
<?php echo Ajax::button('?action=edit_object&id=' . $song->id . '&type=song','download',_('Save Changes'),'save_song_' . $song->id,'edit_song_' . $song->id); ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
</td>
|
|
@ -32,4 +32,7 @@
|
||||||
<?php echo get_user_icon('batch_download',_('Batch Download')); ?>
|
<?php echo get_user_icon('batch_download',_('Batch Download')); ?>
|
||||||
</a>
|
</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
<?php if ($playlist->has_access()) { ?>
|
||||||
|
<?php echo Ajax::button('?action=show_edit_object&type=playlist&id=' . $playlist->id,'edit',_('Edit'),'edit_playlist_' . $playlist->id); ?>
|
||||||
|
<?php } ?>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue