diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-11-25 07:21:45 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-11-25 07:21:45 +0000 |
commit | 4040d0623dc6c88ee7119dd00244b8800c8e4684 (patch) | |
tree | 0babd4abef3d49cfd64c796a69094e53f1919775 | |
parent | 608820577f6c5b7cf81860b8bf082285ec01e7f8 (diff) | |
download | ampache-4040d0623dc6c88ee7119dd00244b8800c8e4684.tar.gz ampache-4040d0623dc6c88ee7119dd00244b8800c8e4684.tar.bz2 ampache-4040d0623dc6c88ee7119dd00244b8800c8e4684.zip |
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
-rw-r--r-- | lib/class/democratic.class.php | 7 | ||||
-rw-r--r-- | lib/class/playlist.class.php | 6 | ||||
-rw-r--r-- | lib/class/stream.class.php | 4 | ||||
-rw-r--r-- | lib/javascript-base.js | 10 | ||||
-rw-r--r-- | server/stream.ajax.php | 3 | ||||
-rw-r--r-- | templates/header.inc.php | 2 | ||||
-rw-r--r-- | util.php | 2 |
7 files changed, 16 insertions, 18 deletions
diff --git a/lib/class/democratic.class.php b/lib/class/democratic.class.php index 296ceab9..5b477f80 100644 --- a/lib/class/democratic.class.php +++ b/lib/class/democratic.class.php @@ -142,8 +142,8 @@ class Democratic extends tmpPlaylist { if ($this->base_playlist != '0') { /* We need to pull a random one from the base_playlist */ $base_playlist = new Playlist($this->base_playlist); - $data = $base_playlist->get_random_songs(1); - $results['object_id'] = $data['0']; + $data = $base_playlist->get_random_items(1); + $results['object_id'] = $data['0']['object_id']; } else { $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 " . "`tmp_playlist`='$tmp_id' AND `object_id`='$object_id'"; -debug_event('foo',$sql,'1'); $db_results = Dba::query($sql); $row = Dba::fetch_assoc($db_results); @@ -237,7 +236,7 @@ debug_event('foo',$sql,'1'); /* If it's on the playlist just vote */ $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); /* If it's not there, add it and pull ID */ diff --git a/lib/class/playlist.class.php b/lib/class/playlist.class.php index f186785f..eb74b163 100644 --- a/lib/class/playlist.class.php +++ b/lib/class/playlist.class.php @@ -146,12 +146,14 @@ class Playlist { * get_random_items * This is the same as before but we randomize the buggers! */ - public function get_random_items() { + public function get_random_items($limit='') { $results = array(); + $limit_sql = $limit ? 'LIMIT ' . intval($limit) : ''; + $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); while ($row = Dba::fetch_assoc($db_results)) { diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php index 09f3cf8a..1b44a492 100644 --- a/lib/class/stream.class.php +++ b/lib/class/stream.class.php @@ -473,7 +473,7 @@ class Stream { $democratic = Democratic::get_current_playlist(); $democratic->vote($this->songs); - + } // create_democratic /** @@ -660,7 +660,7 @@ class Stream { // Load our javascript echo "<script type=\"text/javascript\">"; //echo "reload_util();"; - echo "reload_util2('".$_SESSION['iframe']['target']."');"; + echo "reload_util('".$_SESSION['iframe']['target']."');"; echo "</script>"; } // run_playlist_method diff --git a/lib/javascript-base.js b/lib/javascript-base.js index 4f7ef55d..8d4bb1e1 100644 --- a/lib/javascript-base.js +++ b/lib/javascript-base.js @@ -86,12 +86,10 @@ function update_txt(value,field) { } // Reload our util frame -function reload_util() { - document.getElementById('util_iframe').contentWindow.location.reload(true); -} -function reload_util2(target) { - //document.getElementById('util_iframe').contentWindow.location.href = target; - document.location.href = target; +// IE issue fixed by Spocky, we have to use the iframe for Democratic Play & Localplay +// which don't actually prompt for a new file +function reload_util(target) { + document.getElementById('util_iframe').src = document.getElementById('util_iframe').src; } function popup_art(url) { diff --git a/server/stream.ajax.php b/server/stream.ajax.php index fc39f957..30513b43 100644 --- a/server/stream.ajax.php +++ b/server/stream.ajax.php @@ -38,8 +38,7 @@ switch ($_REQUEST['action']) { case 'basket': // 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']); - //$results['rfc3514'] = '<script type="text/javascript">reload_util()</script>'; - $results['rfc3514'] = '<script type="text/javascript">reload_util2("'.$_SESSION['iframe']['target'].'")</script>'; + $results['rfc3514'] = '<script type="text/javascript">reload_util("'.$_SESSION['iframe']['target'].'")</script>'; break; default: $results['rfc3514'] = '0x1'; diff --git a/templates/header.inc.php b/templates/header.inc.php index 50453437..706c2f20 100644 --- a/templates/header.inc.php +++ b/templates/header.inc.php @@ -82,7 +82,7 @@ if (Config::get('use_rss')) { ?> <table class="smeg-ie" width="100%"><tr><td> --> <!-- Tiny little iframe, used to cheat the system --> <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"> <?php if (Config::get('int_config_version') != Config::get('config_version') AND $GLOBALS['user']->has_access(100)) { ?> <div class="fatalerror"> @@ -27,6 +27,6 @@ require_once 'lib/init.php'; if (isset($_SESSION['iframe']['target'])) { $target = $_SESSION['iframe']['target']; unset($_SESSION['iframe']['target']); - //header("Location: " . $target); + header("Location: " . $target); } ?> |