summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--browse.php6
-rwxr-xr-xdocs/CHANGELOG6
-rw-r--r--lib/class/ajax.class.php6
-rw-r--r--lib/class/browse.class.php14
-rw-r--r--lib/class/localplay.abstract.php2
-rw-r--r--lib/class/localplay.class.php45
-rw-r--r--lib/ui.lib.php10
-rw-r--r--localplay.php7
-rw-r--r--modules/localplay/mpd.controller.php44
-rw-r--r--modules/mpd/mpd.class.php16
-rw-r--r--modules/plugins/Lastfm.plugin.php3
-rw-r--r--preferences.php4
-rw-r--r--server/localplay.ajax.php15
-rw-r--r--templates/show_catalogs.inc.php12
-rw-r--r--templates/show_localplay_playlist.inc.php25
-rw-r--r--templates/sidebar_admin.inc.php1
-rw-r--r--templates/sidebar_localplay.inc.php2
17 files changed, 119 insertions, 99 deletions
diff --git a/browse.php b/browse.php
index 9497eaf7..00ba8aae 100644
--- a/browse.php
+++ b/browse.php
@@ -41,30 +41,35 @@ echo '<div id="browse_content">';
switch($_REQUEST['action']) {
case 'file':
case 'album':
+ Browse::reset_filters();
Browse::set_type('album');
Browse::set_sort('name','ASC');
$album_ids = Browse::get_objects();
Browse::show_objects($album_ids);
break;
case 'artist':
+ Browse::reset_filters();
Browse::set_type('artist');
Browse::set_sort('name','ASC');
$artist_ids = Browse::get_objects();
Browse::show_objects($artist_ids);
break;
case 'genre':
+ Browse::reset_filters();
Browse::set_type('genre');
Browse::set_sort('name','ASC');
$genre_ids = Browse::get_objects();
Browse::show_objects($genre_ids);
break;
case 'song':
+ Browse::reset_filters();
Browse::set_type('song');
Browse::set_sort('title','ASC');
$song_ids = Browse::get_objects();
Browse::show_objects($song_ids);
break;
case 'live_stream':
+ Browse::reset_filters();
Browse::set_type('live_stream');
Browse::set_sort('name','ASC');
$live_stream_ids = Browse::get_objects();
@@ -74,6 +79,7 @@ switch($_REQUEST['action']) {
break;
case 'playlist':
+ Browse::reset_filters();
Browse::set_type('playlist');
Browse::set_sort('name','ASC');
$playlist_ids = Browse::get_objects();
diff --git a/docs/CHANGELOG b/docs/CHANGELOG
index c88feed8..04b77f1e 100755
--- a/docs/CHANGELOG
+++ b/docs/CHANGELOG
@@ -4,6 +4,12 @@
--------------------------------------------------------------------------
v.3.4-Alpha3
+ - Added reset of filters when switching between browse types this
+ may be removed in the future...
+ - Fixed LastFM submitting even when there was no username/password
+ - Put Catalog 'All' Functions back onto catalog view
+ - Fixed Admin Preferences reverting to user after first update
+ - Fixed Localplay playlist
- Updated Ajax Load icon (Thx Spocky)
- Replaced Flash Player with Lacy Morrow's (http://blog.lacymorrow.com/)
(Thx Hugoh)
diff --git a/lib/class/ajax.class.php b/lib/class/ajax.class.php
index f5984912..e4e4baf8 100644
--- a/lib/class/ajax.class.php
+++ b/lib/class/ajax.class.php
@@ -82,12 +82,6 @@ class Ajax {
$source_txt = "'$source'";
}
- /*
- Replaces ampersand with &amp; for w3c conformance.
- Fixme: ajax doesn't seem to work anymore with this...
- */
- //$url = htmlspecialchars($url);
-
if ($post) {
$ajax_string = "ajaxPost('$url','$post',$source_txt)";
}
diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php
index fbcc2948..cb8acbb7 100644
--- a/lib/class/browse.class.php
+++ b/lib/class/browse.class.php
@@ -78,6 +78,20 @@ class Browse {
} // set_filter
/**
+ * reset_filter
+ * This is a wrapper function that resets the filters
+ */
+ public static function reset_filters() {
+
+ if (!is_array($_SESSION['browse']['filter'])) { return true; }
+
+ foreach ($_SESSION['browse']['filter'] AS $key=>$value) {
+ self::set_filter($key,'');
+ }
+
+ } // reset_filters
+
+ /**
* get_filter
* returns the specified filter value
*/
diff --git a/lib/class/localplay.abstract.php b/lib/class/localplay.abstract.php
index 12df43cb..0d870b05 100644
--- a/lib/class/localplay.abstract.php
+++ b/lib/class/localplay.abstract.php
@@ -26,7 +26,7 @@ abstract class localplay_controller {
// Required Functions
abstract public function add($objects); // Takes an array of song_ids
- abstract public function delete($objects); // Takes an array of song_ids
+ abstract public function delete_track($object_id); // Takes a single object_id and removes it from the playlist
abstract public function play();
abstract public function stop();
abstract public function get();
diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php
index 6f996e3f..7b2ffbd6 100644
--- a/lib/class/localplay.class.php
+++ b/lib/class/localplay.class.php
@@ -120,22 +120,6 @@ class Localplay {
} // _load_player
/**
- * has_function
- * This is used to check the function map and see if the current
- * player type supports the indicated function.
- */
- public function has_function($function_name) {
-
- /* Check the function map, if it's got a value it must
- * be possible
- */
- if (strlen($this->_function_map[$function_name]) > 0) { return true; }
-
- return false;
-
- } // has_function
-
- /**
* format_name
* This function takes the track name and checks to see if 'skip'
* is supported in the current player, if so it returns a 'skip to'
@@ -144,13 +128,7 @@ class Localplay {
public function format_name($name,$id) {
$name = scrub_out($name);
-
- if ($this->has_function('skip')) {
- $url = conf('ajax_url') . "?action=localplay&amp;cmd=skip&amp;value=$id" . conf('ajax_info');
-
- $name = "<span style=\"cursor:pointer;text-decoration:underline;\" onclick=\"ajaxPut('$url');return true;\">$name</span>";
- }
-
+ $name = Ajax::text('?page=localplay&action=command&command=skip&id=' . $id,$name,'localplay_skip_' . $id);
return $name;
} // format_name
@@ -385,10 +363,8 @@ class Localplay {
*/
public function get() {
- $function = $this->_function_map['get'];
-
- $data = $this->_player->$function();
-
+ $data = $this->_player->get();
+
if (!count($data) OR !is_array($data)) {
debug_event('localplay','Error Unable to get song info, check ' . $this->type . ' controller','1');
return array();
@@ -481,9 +457,9 @@ class Localplay {
* skip
* This isn't a required function, it tells the daemon to skip to the specified song
*/
- public function skip($song_id) {
+ public function skip($track_id) {
- if (!$this->_player->$function($song_id)) {
+ if (!$this->_player->skip($track_id)) {
debug_event('localplay','Error: Unable to skip to next song, check ' . $this->type . ' controller','1');
return false;
}
@@ -608,14 +584,13 @@ class Localplay {
} // set_active_instance
/**
- * delete
- * This removes songs from the players playlist as defined get function
+ * delete_track
+ * This removes songs from the players playlist it takes a single ID as provided
+ * by the get command
*/
- public function delete($songs) {
+ public function delete_track($object_id) {
- $function = $this->_function_map['delete'];
-
- if (!$this->_player->$function($songs)) {
+ if (!$this->_player->delete_track($object_id)) {
debug_event('localplay','Error: Unable to remove songs, check ' . $this->type . ' controller','1');
return false;
}
diff --git a/lib/ui.lib.php b/lib/ui.lib.php
index d785431f..cbfb0fc1 100644
--- a/lib/ui.lib.php
+++ b/lib/ui.lib.php
@@ -1004,8 +1004,12 @@ function get_user_icon($name,$title='',$id='') {
* primarly by the ajax mojo
*/
function xml_from_array($array,$callback=0,$type='') {
+
+ // If we weren't passed an array then return a blank string
+ if (!is_array($array)) { return ''; }
+
+ // The type is used for the different XML docs we pass
switch ($type) {
-
case 'itunes':
foreach ($array as $key=>$value) {
if (is_array($value)) {
@@ -1025,7 +1029,7 @@ function xml_from_array($array,$callback=0,$type='') {
}
}
- }
+ } // end foreach
return $string;
break;
@@ -1046,7 +1050,7 @@ function xml_from_array($array,$callback=0,$type='') {
}
}
- }
+ } // end foreach
return $string;
break;
diff --git a/localplay.php b/localplay.php
index f43abb26..2855d0c3 100644
--- a/localplay.php
+++ b/localplay.php
@@ -54,9 +54,14 @@ switch ($_REQUEST['action']) {
$fields = $localplay->get_instance_fields();
require_once Config::get('prefix') . '/templates/show_localplay_instances.inc.php';
break;
- case 'show_songs':
+ case 'show_playlist':
+ // Init and then connect to our localplay instance
$localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']);
+ $localplay->connect();
+ // Pull the current playlist and require the template
+ $objects = $localplay->get();
+ require_once Config::get('prefix') . '/templates/show_localplay_playlist.inc.php';
break;
case 'delete_song':
$song_id = scrub_in($_REQUEST['song_id']);
diff --git a/modules/localplay/mpd.controller.php b/modules/localplay/mpd.controller.php
index a35678ae..e442c6f8 100644
--- a/modules/localplay/mpd.controller.php
+++ b/modules/localplay/mpd.controller.php
@@ -277,30 +277,17 @@ class AmpacheMpd extends localplay_controller {
} // add_songs
/**
- * delete_songs
- * This must take an array of ID's (as passed by get function) from Ampache
- * and delete them from MPD
+ * delete_track
+ * This must take a single ID (as passed by get function) from Ampache
+ * and delete it from the current playlist
*/
- public function delete($objects) {
+ public function delete_track($object_id) {
- /* Default to true */
- $return = true;
+ if (is_null($this->_mpd->PLRemove($object_id))) { return false; }
- /* This should be an array of UID's as returned by
- * the get function so that we can just call the class based
- * functions to remove them or if there isn't a uid for
- * the songs, then however ya'll have stored them
- * in this controller
- */
- foreach ($songs as $uid) {
-
- if (is_null($this->_mpd->PLRemove($uid))) { $return = false; }
-
- } // foreach of songs
-
- return $return;
+ return true;
- } // delete_songs
+ } // delete_track
/**
* clear_playlist
@@ -456,6 +443,11 @@ class AmpacheMpd extends localplay_controller {
*/
public function get() {
+ // If we don't have the playlist yet, pull it
+ if (!isset($this->_mpd->playlist)) {
+ $this->_mpd->GetPlaylist();
+ }
+
/* Get the Current Playlist */
$playlist = $this->_mpd->playlist;
@@ -474,10 +466,10 @@ class AmpacheMpd extends localplay_controller {
/* If we don't know it, look up by filename */
if (!$song->title) {
- $filename = sql_escape($entry['file']);
- $sql = "SELECT id FROM song WHERE file LIKE '%$filename'";
- $db_results = mysql_query($sql, dbh());
- if ($r = mysql_fetch_assoc($db_results)) {
+ $filename = Dba::escape($entry['file']);
+ $sql = "SELECT `id` FROM `song` WHERE `file` LIKE '%$filename'";
+ $db_results = Dba::query($sql);
+ if ($r = Dba::fetch_assoc($db_results)) {
$song = new Song($r['id']);
}
else {
@@ -486,7 +478,7 @@ class AmpacheMpd extends localplay_controller {
}
/* Make the name pretty */
- $song->format_song();
+ $song->format();
$data['name'] = $song->f_title . ' - ' . $song->f_album . ' - ' . $song->f_artist;
/* Optional Elements */
@@ -499,7 +491,7 @@ class AmpacheMpd extends localplay_controller {
return $results;
- } // get_songs
+ } // get
/**
* get_status
diff --git a/modules/mpd/mpd.class.php b/modules/mpd/mpd.class.php
index 529465fa..dc7d22ac 100644
--- a/modules/mpd/mpd.class.php
+++ b/modules/mpd/mpd.class.php
@@ -467,16 +467,15 @@ class mpd {
*
* Removes track <id> from the playlist.
*/
- function PLRemove($id) {
- if ( $this->debugging ) echo "mpd->PLRemove()\n";
+ public function PLRemove($id) {
if ( ! is_numeric($id) ) {
$this->errStr = "PLRemove() : argument 1 must be a numeric value";
return NULL;
}
if ( ! is_null($resp = $this->SendCommand(MPD_CMD_PLREMOVE,$id))) $this->RefreshInfo();
- if ( $this->debugging ) echo "mpd->PLRemove() / return\n";
+ debug_event('MPD',"mpd->PLRemove() / return",'5');
return $resp;
- }
+ } // PLRemove
/* SetRepeat()
*
@@ -970,13 +969,14 @@ class mpd {
* NOTE: This function really should not be used. Instead, use $this->playlist. The function
* will most likely be deprecated in future releases.
*/
- function GetPlaylist() {
- if ( $this->debugging ) echo "mpd->GetPlaylist()\n";
+ public function GetPlaylist() {
+
$resp = $this->SendCommand(MPD_CMD_PLLIST);
$playlist = $this->_parseFileListResponse($resp);
- if ( $this->debugging ) echo "mpd->GetPlaylist() / return ".print_r($playlist)."\n";
+ debug_event('MPD',"mpd->GetPlaylist() / return ".print_r($playlist,1),'5');
return $playlist;
- }
+
+ } // GetPlaylist
/* ClearPLIfStopped()
*
diff --git a/modules/plugins/Lastfm.plugin.php b/modules/plugins/Lastfm.plugin.php
index 0d9c4b18..0804bb26 100644
--- a/modules/plugins/Lastfm.plugin.php
+++ b/modules/plugins/Lastfm.plugin.php
@@ -101,6 +101,9 @@ class AmpacheLastfm {
debug_event('LastFM','Song less then 30 seconds not queueing','3');
return false;
}
+
+ // Make sure there's actually a username and password before we keep going
+ if (!$this->username || !$this->password) { return false; }
// 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);
diff --git a/preferences.php b/preferences.php
index ed843b4d..fde2f491 100644
--- a/preferences.php
+++ b/preferences.php
@@ -21,9 +21,6 @@
require 'lib/init.php';
-/* Scrub in the needed mojo */
-if (!$_REQUEST['tab']) { $_REQUEST['tab'] = 'interface'; }
-
// Switch on the action
switch($_REQUEST['action']) {
case 'update_preferences':
@@ -36,6 +33,7 @@ switch($_REQUEST['action']) {
if ($_REQUEST['method'] == 'admin') {
$user_id = '-1';
$fullname = _('Server');
+ $_REQUEST['action'] = 'admin';
}
elseif ($_REQUEST['method'] == 'user') {
$user_id = $_REQUEST['user_id'];
diff --git a/server/localplay.ajax.php b/server/localplay.ajax.php
index cefa8009..eb7923b1 100644
--- a/server/localplay.ajax.php
+++ b/server/localplay.ajax.php
@@ -61,12 +61,27 @@ switch ($_REQUEST['action']) {
$command = scrub_in($_REQUEST['command']);
$localplay->$command();
break;
+ case 'skip':
+ $localplay->skip(intval($_REQUEST['id']));
+ break;
default:
// Nothing
break;
} // end whitelist
break;
+ case 'delete_track':
+ // Load Connect... yada yada
+ $localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']);
+ $localplay->connect();
+
+ // Scrub in the delete request
+ $id = intval($_REQUEST['id']);
+
+ $localplay->delete_track($id);
+
+ $results['localplay_playlist_' . $id] = '';
+ 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
diff --git a/templates/show_catalogs.inc.php b/templates/show_catalogs.inc.php
index 7a0a48cd..b8b6173e 100644
--- a/templates/show_catalogs.inc.php
+++ b/templates/show_catalogs.inc.php
@@ -51,5 +51,17 @@
<th><?php echo _('Last Add'); ?></th>
<th><?php echo _('Actions'); ?></th>
</tr>
+<tr class="<?php echo flip_class(); ?>">
+ <td colspan="3">
+ &nbsp;
+ </td>
+ <td align="right" colspan="2">
+ <a href="<?php echo Config::get('web_path'); ?>/admin/catalog.php?action=gather_album_art"><?php echo _('Gather All Art'); ?></a>
+ | <a href="<?php echo Config::get('web_path'); ?>/admin/catalog.php?action=add_to_all_catalogs"><?php echo _('Add to All'); ?></a>
+ | <a href="<?php echo Config::get('web_path'); ?>/admin/catalog.php?action=update_all_catalogs"><?php echo _('Verify All'); ?></a>
+ | <a href="<?php echo Config::get('web_path'); ?>/admin/catalog.php?action=clean_all_catalogs"><?php echo _('Clean All'); ?></a>
+ | <a href="<?php echo Config::get('web_path'); ?>/admin/catalog.php?action=full_service"><?php echo _('Update All'); ?></a>
+ </td>
+</tr>
</table>
<?php require Config::get('prefix') . '/templates/list_header.inc.php'; ?>
diff --git a/templates/show_localplay_playlist.inc.php b/templates/show_localplay_playlist.inc.php
index 7932f419..216f1523 100644
--- a/templates/show_localplay_playlist.inc.php
+++ b/templates/show_localplay_playlist.inc.php
@@ -1,7 +1,7 @@
<?php
/*
- Copyright (c) 2001 - 2006 Ampache.org
+ Copyright (c) 2001 - 2007 Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
@@ -18,37 +18,34 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-
-$songs = $localplay->get();
-$status = $localplay->status();
?>
-<table cellspacing="0">
+<?php show_box_top(_('Current Playlist')); ?>
+<table class="table-data" cellspacing="0">
<tr class="table-header">
<th><?php echo _('Track'); ?></th>
<th><?php echo _('Name'); ?></th>
<th><?php echo _('Action'); ?></th>
</tr>
<?php
-foreach ($songs as $song) {
+foreach ($objects as $object) {
$class = '';
- if ($status['track'] == $song['track']) { $class=' class="lp_current"'; }
+ if ($status['track'] == $object['track']) { $class=' class="lp_current"'; }
?>
-<tr class="<?php echo flip_class(); ?>">
+<tr class="<?php echo flip_class(); ?>" id="localplay_playlist_<?php echo $object['id']; ?>">
<td>
- <?php echo scrub_out($song['track']); ?>
+ <?php echo scrub_out($object['track']); ?>
</td>
<td<?php echo $class; ?>>
- <?php echo $localplay->format_name($song['name'],$song['id']); ?>
+ <?php echo $localplay->format_name($object['name'],$object['id']); ?>
</td>
<td>
- <a href="<?php echo $web_path; ?>/localplay.php?action=delete_song&amp;song_id=<?php echo scrub_out($song['id']); ?>">
- <?php echo get_user_icon('delete'); ?>
- </a>
+ <?php echo Ajax::button('?page=localplay&action=delete_track&id=' . intval($object['id']),'delete',_('Delete'),'localplay_delete_' . intval($object['id'])); ?>
</td>
</tr>
-<?php } if (!count($songs)) { ?>
+<?php } if (!count($objects)) { ?>
<tr class="<?php echo flip_class(); ?>">
<td colspan="3"><span class="error"><?php echo _('No Records Found'); ?></span></td>
</tr>
<?php } ?>
</table>
+<?php show_box_bottom(); ?>
diff --git a/templates/sidebar_admin.inc.php b/templates/sidebar_admin.inc.php
index dc04b797..c34de6bd 100644
--- a/templates/sidebar_admin.inc.php
+++ b/templates/sidebar_admin.inc.php
@@ -22,7 +22,6 @@
<ul class="sb3" id="sb_admin_ot">
<li id="sb_admin_ot_ClearNowPlaying"><a href="<?php echo $web_path; ?>/admin/catalog.php?action=clear_now_playing"><?php echo _('Clear Now Playing'); ?></a></li>
<li id="sb_admin_ot_ClearCatStats"><a href="<?php echo $web_path; ?>/admin/catalog.php?action=clear_stats"><?php echo _('Clear Catalog Stats'); ?></a></li>
- <li id="sb_admin_ot_GatherArt"><a href="<?php echo $web_path; ?>/admin/catalog.php?action=gather_album_art"><?php echo _('Gather Album Art'); ?></a></li>
</ul>
</li>
diff --git a/templates/sidebar_localplay.inc.php b/templates/sidebar_localplay.inc.php
index 3bede2cc..073dad9e 100644
--- a/templates/sidebar_localplay.inc.php
+++ b/templates/sidebar_localplay.inc.php
@@ -11,7 +11,7 @@
<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_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_playlist"><?php echo _('Show Playlist'); ?></a></li>
</ul>
</li>
<?php } ?>