diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-11-12 20:10:22 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-11-12 20:10:22 +0000 |
commit | 85a3474424ec5ea06be2f0f27198c9ba7f739af9 (patch) | |
tree | 6c33ccb31e1baff46c83ccbe393382e55c5cbcb6 /server | |
parent | 229ae80fc9b3ae7157ff216330575efae5ec80b5 (diff) | |
download | ampache-85a3474424ec5ea06be2f0f27198c9ba7f739af9.tar.gz ampache-85a3474424ec5ea06be2f0f27198c9ba7f739af9.tar.bz2 ampache-85a3474424ec5ea06be2f0f27198c9ba7f739af9.zip |
added ability to vote songs up and down in democratic play and fixed a problem with ajax not resetting the gettext() and not having a user or session
Diffstat (limited to 'server')
-rw-r--r-- | server/ajax.server.php | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/server/ajax.server.php b/server/ajax.server.php index 5c173b10..7787fac1 100644 --- a/server/ajax.server.php +++ b/server/ajax.server.php @@ -41,7 +41,6 @@ header("Cache-Control: no-cache"); switch ($action) { /* Controls Localplay */ case 'localplay': - init_preferences(); $localplay = init_localplay(); $localplay->connect(); $function = scrub_in($_GET['cmd']); @@ -75,9 +74,6 @@ switch ($action) { break; /* For changing the current play type */ case 'change_play_type': - init_preferences(); - session_id(scrub_in($_REQUEST['sessid'])); - session_start(); $_SESSION['data']['old_play_type'] = conf('play_type'); $pref_id = get_preference_id('play_type'); $GLOBALS['user']->update_preference($pref_id,$_GET['type']); @@ -131,6 +127,27 @@ switch ($action) { $xml_doc = xml_from_array($results); echo $xml_doc; break; + /* This can be a positve (1) or negative (-1) vote */ + case 'vote': + if (!$GLOBALS['user']->has_access(25) || $GLOBALS['user']->prefs['play_type'] != 'democratic') { break; } + /* Get the playlist */ + $tmp_playlist = get_democratic_playlist(-1); + + if ($_REQUEST['vote'] == '1') { + $tmp_playlist->vote(array($_REQUEST['object_id'])); + } + else { + $tmp_playlist->remove_vote($_REQUEST['object_id']); + } + + ob_start(); + $songs = $tmp_playlist->get_items(); + require_once(conf('prefix') . '/templates/show_tv_playlist.inc.php'); + $results['tv_playlist'] = ob_get_contents(); + ob_end_clean(); + $xml_doc = xml_from_array($results); + echo $xml_doc; + break; default: echo "Default Action"; break; |