32
26
if (!defined('AJAX_INCLUDE')) { exit; }
34
28
switch ($_REQUEST['action']) {
36
// Create the object and remove the track
37
$playlist = new Playlist($_REQUEST['playlist_id']);
39
if ($playlist->has_access()) {
40
$playlist->delete_track($_REQUEST['track_id']);
43
$object_ids = $playlist->get_items();
45
$browse = new Browse();
46
$browse->set_type('playlist_song');
47
$browse->add_supplemental_object('playlist',$playlist->id);
48
$browse->save_objects($object_ids);
49
$browse->show_objects($object_ids);
51
$results['browse_content'] = ob_get_clean();
54
$playlist = new Playlist($_REQUEST['playlist_id']);
55
if (!$playlist->has_access()) {
56
$results['rfc3514'] = '0x1';
60
// They've got access, show the edit page
61
$track = $playlist->get_track($_REQUEST['track_id']);
62
$song = new Song($track['object_id']);
64
require_once Config::get('prefix') . '/templates/show_edit_playlist_song_row.inc.php';
65
$results['track_' . $track['id']] = ob_get_clean();
68
$playlist = new Playlist($_REQUEST['playlist_id']);
69
if (!$playlist->has_access()) {
70
$results['rfc3514'] = '0x1';
75
// They've got access, save this guy and re-display row
76
$playlist->update_track_number($_GET['track_id'],$_POST['track']);
77
$track = $playlist->get_track($_GET['track_id']);
78
$song = new Song($track['object_id']);
80
$playlist_track = $track['track'];
81
require Config::get('prefix') . '/templates/show_playlist_song_row.inc.php';
82
$results['track_' . $track['id']] = ob_get_clean();
85
if (!Access::check('interface','25')) {
86
debug_event('DENIED','Error:' . $GLOBALS['user']->username . ' does not have user access, unable to create playlist','1');
90
// Pull the current active playlist items
91
$objects = $GLOBALS['user']->playlist->get_items();
93
$name = $GLOBALS['user']->username . ' - ' . date("Y-m-d H:i:s",time());
95
// generate the new playlist
96
$playlist_id = Playlist::create($name,'public');
97
if (!$playlist_id) { break; }
98
$playlist = new Playlist($playlist_id);
100
// Itterate through and add them to our new playlist
101
foreach ($objects as $object_data) {
102
// For now only allow songs on here, we'll change this later
103
$type = array_shift($object_data);
104
if ($type == 'song') {
105
$songs[] = array_shift($object_data);
110
$playlist->add_songs($songs,'ORDERED');
112
$object_ids = $playlist->get_items();
114
require_once Config::get('prefix') . '/templates/show_playlist.inc.php';
115
$results['content'] = ob_get_clean();
118
// Pull the current active playlist items
119
$objects = $GLOBALS['user']->playlist->get_items();
121
// Create the playlist object
122
$playlist = new Playlist($_REQUEST['playlist_id']);
124
// We need to make sure that they have access
125
if (!$playlist->has_access()) {
131
// Itterate through and add them to our new playlist
132
foreach ($objects as $element) {
133
$type = array_shift($element);
136
$songs[] = array_shift($element);
141
// Override normal include procedure
142
Ajax::set_include_override(true);
145
$playlist->add_songs($songs,'ORDERED');
147
$object_ids = $playlist->get_items();
149
require_once Config::get('prefix') . '/templates/show_playlist.inc.php';
150
$results['content'] = ob_get_contents();
154
$results['rfc3514'] = '0x1';
30
// Create the object and remove the track
31
$playlist = new Playlist($_REQUEST['playlist_id']);
33
if ($playlist->has_access()) {
34
$playlist->delete_track($_REQUEST['track_id']);
37
$object_ids = $playlist->get_items();
39
$browse = new Browse();
40
$browse->set_type('playlist_song');
41
$browse->add_supplemental_object('playlist',$playlist->id);
42
$browse->save_objects($object_ids);
43
$browse->show_objects($object_ids);
45
$results['browse_content'] = ob_get_clean();
48
$playlist = new Playlist($_REQUEST['playlist_id']);
49
if (!$playlist->has_access()) {
50
$results['rfc3514'] = '0x1';
54
// They've got access, show the edit page
55
$track = $playlist->get_track($_REQUEST['track_id']);
56
$song = new Song($track['object_id']);
58
require_once Config::get('prefix') . '/templates/show_edit_playlist_song_row.inc.php';
59
$results['track_' . $track['id']] = ob_get_clean();
62
$playlist = new Playlist($_REQUEST['playlist_id']);
63
if (!$playlist->has_access()) {
64
$results['rfc3514'] = '0x1';
69
// They've got access, save this guy and re-display row
70
$playlist->update_track_number($_GET['track_id'],$_POST['track']);
71
$track = $playlist->get_track($_GET['track_id']);
72
$song = new Song($track['object_id']);
74
$playlist_track = $track['track'];
75
require Config::get('prefix') . '/templates/show_playlist_song_row.inc.php';
76
$results['track_' . $track['id']] = ob_get_clean();
79
if (!Access::check('interface','25')) {
80
debug_event('DENIED','Error:' . $GLOBALS['user']->username . ' does not have user access, unable to create playlist','1');
84
// Pull the current active playlist items
85
$objects = $GLOBALS['user']->playlist->get_items();
87
$name = $GLOBALS['user']->username . ' - ' . date("Y-m-d H:i:s",time());
89
// generate the new playlist
90
$playlist_id = Playlist::create($name,'public');
91
if (!$playlist_id) { break; }
92
$playlist = new Playlist($playlist_id);
94
// Iterate through and add them to our new playlist
95
foreach ($objects as $object_data) {
96
// For now only allow songs on here, we'll change this later
97
$type = array_shift($object_data);
98
if ($type == 'song') {
99
$songs[] = array_shift($object_data);
104
$playlist->add_songs($songs,'ORDERED');
106
$object_ids = $playlist->get_items();
108
require_once Config::get('prefix') . '/templates/show_playlist.inc.php';
109
$results['content'] = ob_get_clean();
112
// Pull the current active playlist items
113
$objects = $GLOBALS['user']->playlist->get_items();
115
// Create the playlist object
116
$playlist = new Playlist($_REQUEST['playlist_id']);
118
// We need to make sure that they have access
119
if (!$playlist->has_access()) {
125
// Iterate through and add them to our new playlist
126
foreach ($objects as $element) {
127
$type = array_shift($element);
130
$songs[] = array_shift($element);
135
// Override normal include procedure
136
Ajax::set_include_override(true);
139
$playlist->add_songs($songs,'ORDERED');
141
$object_ids = $playlist->get_items();
143
require_once Config::get('prefix') . '/templates/show_playlist.inc.php';
144
$results['content'] = ob_get_contents();
148
$results['rfc3514'] = '0x1';
156
150
} // switch on action;
158
152
// We always do this