1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 09:49:30 +02:00

fixed multi-genre random play

This commit is contained in:
Karl 'vollmerk' Vollmer 2007-11-05 02:52:57 +00:00
parent d3840c7de0
commit ab0e89b8dd
5 changed files with 30 additions and 25 deletions

View file

@ -4,6 +4,7 @@
-------------------------------------------------------------------------- --------------------------------------------------------------------------
v.3.4-Alpha3 v.3.4-Alpha3
- Fixed multi-genre Random Play
- New Version of Flash player fixes playlist repeat bug (Thx hugoh) - New Version of Flash player fixes playlist repeat bug (Thx hugoh)
- Fixed catalog update and album art dump command line tools - Fixed catalog update and album art dump command line tools
- Removed dead link for renaming an Artist - Removed dead link for renaming an Artist

View file

@ -266,15 +266,13 @@ class Random {
if (is_array($matchlist)) { if (is_array($matchlist)) {
foreach ($matchlist as $type => $value) { foreach ($matchlist as $type => $value) {
if (is_array($value)) { if (is_array($value)) {
$where .= "(";
foreach ($value as $v) { foreach ($value as $v) {
if (!strlen($v)) { continue; } if (!strlen($v)) { continue; }
$v = Dba::escape($v); $v = Dba::escape($v);
if ($v != $value[0]) { $where .= " OR $type='$v' "; } if ($v != $value[0]) { $where .= " OR $type='$v' "; }
else { $where .= " AND ( $type='$v'"; } else { $where .= " AND ( $type='$v'"; }
} }
$where .= ")"; $where .= ")";
$where = rtrim($where,"()");
} }
elseif (strlen($value)) { elseif (strlen($value)) {
$value = Dba::escape($value); $value = Dba::escape($value);
@ -283,7 +281,6 @@ class Random {
} // end foreach } // end foreach
} // end if matchlist } // end if matchlist
if ($data['random_type'] == 'full_album') { if ($data['random_type'] == 'full_album') {
$query = "SELECT `album`.`id` FROM `song` INNER JOIN `album` ON `song`.`album`=`album`.`id` " . $query = "SELECT `album`.`id` FROM `song` INNER JOIN `album` ON `song`.`album`=`album`.`id` " .
"WHERE $where GROUP BY `song`.`album` ORDER BY RAND() $limit_sql"; "WHERE $where GROUP BY `song`.`album` ORDER BY RAND() $limit_sql";

View file

@ -25,8 +25,17 @@ require_once 'lib/init.php';
show_header(); show_header();
switch ($_REQUEST['action']) { switch ($_REQUEST['action']) {
default: case 'get_advanced':
$object_ids = Random::advanced($_POST);
// We need to add them to the active playlist
foreach ($object_ids as $object_id) {
$GLOBALS['user']->playlist->add_object($object_id,'song');
}
// We need to refresh the playlist
case 'advanced': case 'advanced':
default:
require_once Config::get('prefix') . '/templates/show_random.inc.php'; require_once Config::get('prefix') . '/templates/show_random.inc.php';
break; break;
} // end switch } // end switch

View file

@ -67,6 +67,9 @@ switch ($_REQUEST['page']) {
} // end switch on page } // end switch on page
switch ($_REQUEST['action']) { switch ($_REQUEST['action']) {
case 'refresh_rightbar':
$results['rightbar'] = ajax_include('rightbar.inc.php');
break;
/* Controls the editing of objects */ /* Controls the editing of objects */
case 'show_edit_object': case 'show_edit_object':
@ -119,7 +122,6 @@ switch ($_REQUEST['action']) {
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();
ob_end_clean(); ob_end_clean();
echo xml_from_array($results);
break; break;
case 'edit_object': case 'edit_object':
@ -184,7 +186,6 @@ switch ($_REQUEST['action']) {
require Config::get('prefix') . '/templates/show_' . $_POST['type'] . '_row.inc.php'; require Config::get('prefix') . '/templates/show_' . $_POST['type'] . '_row.inc.php';
$results[$key] = ob_get_contents(); $results[$key] = ob_get_contents();
ob_end_clean(); ob_end_clean();
echo xml_from_array($results);
break; break;
/* Controls Localplay */ /* Controls Localplay */
case 'localplay': case 'localplay':
@ -219,8 +220,6 @@ switch ($_REQUEST['action']) {
$results['3514'] = '0x1'; $results['3514'] = '0x1';
break; break;
} // end switch on cmd } // end switch on cmd
$xml_doc = xml_from_array($results);
echo $xml_doc;
break; break;
case 'current_playlist': case 'current_playlist':
switch ($_REQUEST['type']) { switch ($_REQUEST['type']) {
@ -230,7 +229,6 @@ switch ($_REQUEST['action']) {
} // end switch } // end switch
$results['rightbar'] = ajax_include('rightbar.inc.php'); $results['rightbar'] = ajax_include('rightbar.inc.php');
echo xml_from_array($results);
break; break;
// Handle the users basketcases... // Handle the users basketcases...
case 'basket': case 'basket':
@ -290,7 +288,6 @@ switch ($_REQUEST['action']) {
} // end switch } // end switch
$results['rightbar'] = ajax_include('rightbar.inc.php'); $results['rightbar'] = ajax_include('rightbar.inc.php');
echo xml_from_array($results);
break; break;
/* For changing the current play type FIXME:: need to allow select of any type */ /* For changing the current play type FIXME:: need to allow select of any type */
case 'change_play_type': case 'change_play_type':
@ -299,8 +296,6 @@ switch ($_REQUEST['action']) {
/* Uses a drop down, no need to replace text */ /* Uses a drop down, no need to replace text */
$results['play_type'] = ''; $results['play_type'] = '';
$xml_doc = xml_from_array($results);
echo $xml_doc;
break; break;
/* reloading the now playing information */ /* reloading the now playing information */
case 'reloadnp': case 'reloadnp':
@ -316,7 +311,6 @@ switch ($_REQUEST['action']) {
} }
$results['recently_played'] = ob_get_contents(); $results['recently_played'] = ob_get_contents();
ob_end_clean(); ob_end_clean();
echo xml_from_array($results);
break; break;
/* Setting ratings */ /* Setting ratings */
case 'set_rating': case 'set_rating':
@ -327,7 +321,6 @@ switch ($_REQUEST['action']) {
$key = "rating_" . $_GET['object_id'] . "_" . $_GET['rating_type']; $key = "rating_" . $_GET['object_id'] . "_" . $_GET['rating_type'];
$results[$key] = ob_get_contents(); $results[$key] = ob_get_contents();
ob_end_clean(); ob_end_clean();
echo xml_from_array($results);
break; break;
/* This can be a positve (1) or negative (-1) vote */ /* This can be a positve (1) or negative (-1) vote */
case 'vote': case 'vote':
@ -347,8 +340,6 @@ switch ($_REQUEST['action']) {
require_once(conf('prefix') . '/templates/show_tv_playlist.inc.php'); require_once(conf('prefix') . '/templates/show_tv_playlist.inc.php');
$results['tv_playlist'] = ob_get_contents(); $results['tv_playlist'] = ob_get_contents();
ob_end_clean(); ob_end_clean();
$xml_doc = xml_from_array($results);
echo $xml_doc;
break; break;
// Used to change filter/settings on browse // Used to change filter/settings on browse
case 'browse': case 'browse':
@ -368,8 +359,6 @@ switch ($_REQUEST['action']) {
Browse::show_objects($object_ids); Browse::show_objects($object_ids);
$results['browse_content'] = ob_get_contents(); $results['browse_content'] = ob_get_contents();
ob_end_clean(); ob_end_clean();
$xml_doc = xml_from_array($results);
echo $xml_doc;
break; break;
case 'page': case 'page':
Browse::set_start($_REQUEST['start']); Browse::set_start($_REQUEST['start']);
@ -378,7 +367,6 @@ switch ($_REQUEST['action']) {
Browse::show_objects(); Browse::show_objects();
$results['browse_content'] = ob_get_contents(); $results['browse_content'] = ob_get_contents();
ob_end_clean(); ob_end_clean();
echo xml_from_array($results);
break; break;
case 'sidebar': case 'sidebar':
switch ($_REQUEST['button']) { switch ($_REQUEST['button']) {
@ -403,11 +391,13 @@ switch ($_REQUEST['action']) {
require_once Config::get('prefix') . '/templates/sidebar.inc.php'; require_once Config::get('prefix') . '/templates/sidebar.inc.php';
$results['sidebar'] = ob_get_contents(); $results['sidebar'] = ob_get_contents();
ob_end_clean(); ob_end_clean();
echo xml_from_array($results);
break; break;
default: default:
$results['rfc3514'] = '0x1'; $results['rfc3514'] = '0x1';
echo xml_from_array($results);
break; break;
} // end switch action } // end switch action
// Go ahead and do the echo
echo xml_from_array($results);
?> ?>

View file

@ -19,7 +19,7 @@
*/ */
?> ?>
<form id="random" method="post" enctype="multipart/form-data" action="<?php echo Config::get('web_path'); ?>/random.php"> <form id="random" method="post" enctype="multipart/form-data" action="<?php echo Config::get('web_path'); ?>/random.php?action=get_advanced">
<?php show_box_top(_('Play Random Selection')); ?> <?php show_box_top(_('Play Random Selection')); ?>
<table class="table-data" cellspacing="0" cellpadding="3"> <table class="table-data" cellspacing="0" cellpadding="3">
<tr> <tr>
@ -76,12 +76,20 @@
</tr> </tr>
<tr> <tr>
<td colspan="4"> <td colspan="4">
<?php echo Ajax::text("?page=random&action=advanced_random",_('Enqueue'),'advanced_random_enqueue','random','button'); ?> <input type="submit" value="<?php echo _('Enqueue'); ?>" />
</td> </td>
</tr> </tr>
</table> </table>
<?php show_box_bottom(); ?> <?php show_box_bottom(); ?>
</form> </form>
<div id="browse"> <div id="browse">
<?php
if (is_array($object_ids)) {
Browse::reset_filters();
Browse::set_type('song');
Browse::save_objects($object_ids);
Browse::show_objects();
echo Ajax::observe('window','load',Ajax::action('?action=refresh_rightbar','playlist_refresh_load'));
}
?>
</div> </div>