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

fixed the page reloads once and for all, had to revert to iframe for democratic play and localplay, fixed an adding issue with democratic play if the songs were left in your active playlist

This commit is contained in:
Karl 'vollmerk' Vollmer 2007-11-25 07:21:45 +00:00
parent 608820577f
commit 4040d0623d
7 changed files with 16 additions and 18 deletions

View file

@ -142,8 +142,8 @@ class Democratic extends tmpPlaylist {
if ($this->base_playlist != '0') { if ($this->base_playlist != '0') {
/* We need to pull a random one from the base_playlist */ /* We need to pull a random one from the base_playlist */
$base_playlist = new Playlist($this->base_playlist); $base_playlist = new Playlist($this->base_playlist);
$data = $base_playlist->get_random_songs(1); $data = $base_playlist->get_random_items(1);
$results['object_id'] = $data['0']; $results['object_id'] = $data['0']['object_id'];
} }
else { else {
$sql = "SELECT `id` as `object_id` FROM `song` WHERE `enabled`='1' ORDER BY RAND() LIMIT 1"; $sql = "SELECT `id` as `object_id` FROM `song` WHERE `enabled`='1' ORDER BY RAND() LIMIT 1";
@ -168,7 +168,6 @@ class Democratic extends tmpPlaylist {
$sql = "SELECT `tmp_playlist_data`.`id` FROM `tmp_playlist_data` WHERE `object_type`='$object_type' AND " . $sql = "SELECT `tmp_playlist_data`.`id` FROM `tmp_playlist_data` WHERE `object_type`='$object_type' AND " .
"`tmp_playlist`='$tmp_id' AND `object_id`='$object_id'"; "`tmp_playlist`='$tmp_id' AND `object_id`='$object_id'";
debug_event('foo',$sql,'1');
$db_results = Dba::query($sql); $db_results = Dba::query($sql);
$row = Dba::fetch_assoc($db_results); $row = Dba::fetch_assoc($db_results);
@ -237,7 +236,7 @@ debug_event('foo',$sql,'1');
/* If it's on the playlist just vote */ /* If it's on the playlist just vote */
$sql = "SELECT `id` FROM `tmp_playlist_data` " . $sql = "SELECT `id` FROM `tmp_playlist_data` " .
"WHERE `tmp_playlist_data`.`object_id`='$object_id'"; "WHERE `tmp_playlist_data`.`object_id`='$object_id' AND `tmp_playlist_data`.`tmp_playlist`='$tmp_playlist'";
$db_results = Dba::query($sql); $db_results = Dba::query($sql);
/* If it's not there, add it and pull ID */ /* If it's not there, add it and pull ID */

View file

@ -146,12 +146,14 @@ class Playlist {
* get_random_items * get_random_items
* This is the same as before but we randomize the buggers! * This is the same as before but we randomize the buggers!
*/ */
public function get_random_items() { public function get_random_items($limit='') {
$results = array(); $results = array();
$limit_sql = $limit ? 'LIMIT ' . intval($limit) : '';
$sql = "SELECT `object_id`,`object_type`,`dynamic_song` FROM `playlist_data` " . $sql = "SELECT `object_id`,`object_type`,`dynamic_song` FROM `playlist_data` " .
"WHERE `playlist`='" . Dba::escape($this->id) . "' ORDER BY RAND()"; "WHERE `playlist`='" . Dba::escape($this->id) . "' ORDER BY RAND() $limit_sql";
$db_results = Dba::query($sql); $db_results = Dba::query($sql);
while ($row = Dba::fetch_assoc($db_results)) { while ($row = Dba::fetch_assoc($db_results)) {

View file

@ -473,7 +473,7 @@ class Stream {
$democratic = Democratic::get_current_playlist(); $democratic = Democratic::get_current_playlist();
$democratic->vote($this->songs); $democratic->vote($this->songs);
} // create_democratic } // create_democratic
/** /**
@ -660,7 +660,7 @@ class Stream {
// Load our javascript // Load our javascript
echo "<script type=\"text/javascript\">"; echo "<script type=\"text/javascript\">";
//echo "reload_util();"; //echo "reload_util();";
echo "reload_util2('".$_SESSION['iframe']['target']."');"; echo "reload_util('".$_SESSION['iframe']['target']."');";
echo "</script>"; echo "</script>";
} // run_playlist_method } // run_playlist_method

View file

@ -86,12 +86,10 @@ function update_txt(value,field) {
} }
// Reload our util frame // Reload our util frame
function reload_util() { // IE issue fixed by Spocky, we have to use the iframe for Democratic Play & Localplay
document.getElementById('util_iframe').contentWindow.location.reload(true); // which don't actually prompt for a new file
} function reload_util(target) {
function reload_util2(target) { document.getElementById('util_iframe').src = document.getElementById('util_iframe').src;
//document.getElementById('util_iframe').contentWindow.location.href = target;
document.location.href = target;
} }
function popup_art(url) { function popup_art(url) {

View file

@ -38,8 +38,7 @@ switch ($_REQUEST['action']) {
case 'basket': case 'basket':
// We need to set the basket up! // We need to set the basket up!
$_SESSION['iframe']['target'] = Config::get('web_path') . '/stream.php?action=basket&playlist_method=' . scrub_out($_REQUEST['playlist_method']); $_SESSION['iframe']['target'] = Config::get('web_path') . '/stream.php?action=basket&playlist_method=' . scrub_out($_REQUEST['playlist_method']);
//$results['rfc3514'] = '<script type="text/javascript">reload_util()</script>'; $results['rfc3514'] = '<script type="text/javascript">reload_util("'.$_SESSION['iframe']['target'].'")</script>';
$results['rfc3514'] = '<script type="text/javascript">reload_util2("'.$_SESSION['iframe']['target'].'")</script>';
break; break;
default: default:
$results['rfc3514'] = '0x1'; $results['rfc3514'] = '0x1';

View file

@ -82,7 +82,7 @@ if (Config::get('use_rss')) { ?>
<table class="smeg-ie" width="100%"><tr><td> --> <table class="smeg-ie" width="100%"><tr><td> -->
<!-- Tiny little iframe, used to cheat the system --> <!-- Tiny little iframe, used to cheat the system -->
<div id="ajax-loading">Loading . . .</div> <div id="ajax-loading">Loading . . .</div>
<iframe id="util_iframe" style="display:none;" src="<?php echo Config::get('web_path'); ?>/util.php"></iframe> <iframe name="util_iframe" id="util_iframe" style="display:none;" src="<?php echo Config::get('web_path'); ?>/util.php"></iframe>
<div id="content"> <div id="content">
<?php if (Config::get('int_config_version') != Config::get('config_version') AND $GLOBALS['user']->has_access(100)) { ?> <?php if (Config::get('int_config_version') != Config::get('config_version') AND $GLOBALS['user']->has_access(100)) { ?>
<div class="fatalerror"> <div class="fatalerror">

View file

@ -27,6 +27,6 @@ require_once 'lib/init.php';
if (isset($_SESSION['iframe']['target'])) { if (isset($_SESSION['iframe']['target'])) {
$target = $_SESSION['iframe']['target']; $target = $_SESSION['iframe']['target'];
unset($_SESSION['iframe']['target']); unset($_SESSION['iframe']['target']);
//header("Location: " . $target); header("Location: " . $target);
} }
?> ?>