<?php if (Session::is_group_user('Sustainer Admin')) { $slots = SustainerSlots::get_all(); foreach ($slots as $slot) { $compareValue = "slot-" . $slot->get_day() . "-" . $slot->get_time(); if ($compareValue == $_REQUEST["updateid"]) { $prerecordText = "Currently this hour is scheduled with the <b>" . Playlists::get_by_id($slot->get_playlist_id())->get_name() . "</b> playlist"; if ($slot->get_audio_id() != NULL) { $prerecordText .= " <i>AND</i> the prerecord <b>" . Prerecs::get_by_id($slot->get_audio_id())->get_title() . "</b> is scheduled."; } else { $prerecordText .= " <b>AND</b> there is no prerecord scheduled."; } break; } } if (Errors::occured()) { http_response_code(400); exit(json_encode(array("error" => "Something went wrong. You may have discovered a bug!", "detail" => Errors::report("array")))); Errors::clear(); } else { exit(json_encode(array('response' => 'success', 'status' => $prerecordText))); } } else { http_response_code(403); exit(json_encode(array('error' => 'Permission denied.'))); }
<?php if (Session::is_group_user('Playlist Admin')) { if ($_REQUEST["id"]) { $playlist = Playlists::get_by_id($_REQUEST["id"]); $playlist->delete(); if (Errors::occured()) { http_response_code(400); exit(json_encode(array("error" => "Something went wrong. You may have discovered a bug!", "detail" => Errors::report("array")))); Errors::clear(); } else { exit(json_encode(array('response' => 'success'))); } } } else { http_response_code(403); exit(json_encode(array('error' => 'Permission denied.'))); }
Output::add_stylesheet(LINK_ABS . "css/select2.min.css"); Output::add_script(LINK_ABS . "js/select2.min.js"); Output::require_group("Sustainer Admin"); MainTemplate::set_subtitle("Change the schedule of the sustainer service"); echo "<style type=\"text/css\">\r\n\ttd.timeslot { text-align: center; }\r\n </style>\r\n\r\n\r\n\t<script type=\"text/javascript\">\r\n\$(function() {\r\n\r\n\t\t\$('#update-playlist').click(function() {\r\n\t\t\t\$.ajax({\r\n\t\t\t\turl: '" . LINK_ABS . "ajax/update-sustainer-slots.php',\r\n\t\t\t\tdata: { updateid: \$('.update-id').val(), playlistid: \$('#playlist-id').val() },\r\n\t\t\t\ttype: 'POST',\r\n\t\t\t\terror: function(xhr,text,error) {\r\n\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\r\n\t\t\t\t\talert(value.error);\r\n\t\t\t\t},\r\n\t\t\t\tsuccess: function(data,text,xhr) {\r\n\t\t\t\t\twindow.location.reload(true); \r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t});\r\n\r\n\t\t\$('#save-prerecord').click(function() {\r\n\t\t\t\$.ajax({\r\n\t\t\t\turl: '" . LINK_ABS . "ajax/add-update-prerecord.php',\r\n\t\t\t\tdata: { updateid: \$('.update-id').val(), prerecordid: \$('#prerecord-id').val() },\r\n\t\t\t\ttype: 'POST',\r\n\t\t\t\terror: function(xhr,text,error) {\r\n\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\r\n\t\t\t\t\talert(value.error);\r\n\t\t\t\t},\r\n\t\t\t\tsuccess: function(data,text,xhr) {\r\n\t\t\t\t\twindow.location.reload(true); \r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t});\r\n\r\n\t\t\$('#delete-prerecord').click(function() {\r\n\t\t\t\$.ajax({\r\n\t\t\t\turl: '" . LINK_ABS . "ajax/add-update-prerecord.php',\r\n\t\t\t\tdata: { updateid: \$('.update-id').val(), prerecordid: 0 },\r\n\t\t\t\ttype: 'POST',\r\n\t\t\t\terror: function(xhr,text,error) {\r\n\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\r\n\t\t\t\t\talert(value.error);\r\n\t\t\t\t},\r\n\t\t\t\tsuccess: function(data,text,xhr) {\r\n\t\t\t\t\twindow.location.reload(true); \r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t});\r\n\r\n\t\t\$('#prerecord-id').select2({\r\n\t\t ajax: {\r\n\t\t url: '" . LINK_ABS . "ajax/prerecord-search.php',\r\n\t\t dataType: 'json',\r\n\t\t delay: 250,\r\n\t\t data: function (params) {\r\n\t\t return {\r\n\t\t q: params.term\r\n\t\t };\r\n\t\t },\r\n\t\t processResults: function (data, page) {\r\n\t\t // parse the results into the format expected by Select2.\r\n\t\t // since we are using custom formatting functions we do not need to\r\n\t\t // alter the remote JSON data\r\n\t\t return {\r\n\t\t results: data.data\r\n\t\t };\r\n\t\t },\r\n\t\t cache: true\r\n\t\t },\r\n\t\t escapeMarkup: function (markup) { return markup; }, // let our custom formatter work\r\n\t\t minimumInputLength: 1,\r\n\t\t templateResult: formatRepo, // omitted for brevity, see the source of this page\r\n\t\t templateSelection: formatRepoSelection\r\n\t\t});\r\n\r\n\t\tfunction formatRepo (repo) {\r\n\t\t\tif (repo.loading) return repo.title;\r\n\t\t return repo.title + ' by <i>' + repo.by + '</i>';\r\n\t\t }\r\n\r\n\t function formatRepoSelection (repo) {\r\n\t \treturn repo.title;\r\n\t }\r\n\r\n\t \$('#playlist-id').select2()\r\n\r\n});\r\n</script>"; $colours = array('2ecc71', 'e67e22', '3498db', 'e74c3c', '9b59b6', '34495e', '1abc9c', 'f1c40f'); $timeslots = array('00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23'); $slots = SustainerSlots::get_all(); $i = 0; echo "<table class=\"table table-striped table-bordered\">\r\n\t<thead>\r\n\t<tr>\r\n\t<th></th>\r\n\t<th>Monday</th>\r\n\t<th>Tuesday</th>\r\n\t<th>Wednesday</th>\r\n\t<th>Thursday</th>\r\n\t<th>Friday</th>\r\n\t<th>Saturday</th>\r\n\t<th>Sunday</th>\r\n\t</tr>\r\n\t</thead>\r\n\t<tbody>"; $i = 0; foreach ($slots as $slot) { if ($i < 1) { echo "<tr>\r\n\t\t\t<td>" . $slot->get_time() . ":00</td>"; } $thisPlaylist = Playlists::get_by_id($slot->get_playlist_id()); $thisPlaylistColour = $thisPlaylist->get_colour() == "" ? 'FFFFFF' : $thisPlaylist->get_colour(); echo "<td class='timeslot' id='slot-" . $slot->get_day() . "-" . $slot->get_time() . "' style='background-color: #" . $thisPlaylistColour . ";'>"; echo $slot->get_audio_id() == NULL ? '' : "<span class=\"glyphicon glyphicon-time\" aria-hidden=\"true\"></span>"; echo "</td>"; $i++; if ($i > 6) { echo "</tr>"; $i = 0; } } echo "</tbody>\r\n\t</table>"; echo "<form>"; foreach ($slots as $slot) { echo "<input type=\"hidden\" class=\"field-slots\" id=\"field-slot-" . $slot->get_day() . "-" . $slot->get_time() . "\" name=\"field-slot-" . $slot->get_day() . "-" . $slot->get_time() . "\" value=\"" . $slot->get_playlist_id() . "\">"; }
<?php if (Session::is_group_user('Playlist Admin')) { foreach ($_POST["id"] as $key => $id) { $playlist = Playlists::get_by_id($id); $playlist->set_sortorder(++$key); $playlist->save(); } exit("success"); } else { exit("You do not have permission to modify this."); }
<?php Output::set_title("Playlist Detail"); $playlist = Playlists::get_by_id($_REQUEST['q']); $limit = isset($_GET['n']) ? $_REQUEST['n'] : 10; $page = isset($_REQUEST['p']) ? $_REQUEST['p'] : 1; MainTemplate::set_subtitle("List tracks on a playlist, remove tracks"); $tracks = $playlist->get_tracks($limit, ($page - 1) * $limit); if ($tracks) { $pages = new Paginator(); $pages->items_per_page = $limit; $pages->querystring = $playlist->get_id(); $pages->mid_range = 5; $pages->items_total = $playlist->count_tracks(); $pages->paginate(); $low = ($page - 1) * $limit + 1; $high = $low + $limit - 1 > $pages->items_total ? $pages->items_total : $low + $limit - 1; echo "<script>\r\n\t\t\$(function () {\r\n\t\t\t\$('.track-info').popover({\r\n\t\t\t\t'html': true, \r\n\t\t\t\t'trigger': 'hover',\r\n\t\t\t\t'title': function() { \r\n\t\t\t\t\treturn(\$(this).parent().parent().find('.title').html())\r\n\t\t\t\t},\r\n\t\t\t\t'content': function() {\r\n\t\t\t\t\treturn(\$(this).parent().find('.hover-info').html());\r\n\t\t\t\t}\r\n\t\t\t});\r\n" . (Session::is_group_user("Playlist Editor") ? "\r\n\t\t\t\$('.track-remove').click(function() {\r\n\t\t\t\ttrackid = \$(this).attr('data-dps-track-id');\r\n\t\t\t\tplaylistid = \$(this).attr('data-dps-playlist-id');\r\n\t\t\t\t\$.ajax({\r\n\t\t\t\t\turl: '" . LINK_ABS . "ajax/track-playlist-update.php',\r\n\t\t\t\t\tdata: 'playlistid='+playlistid+'&trackid='+trackid+'&action=del',\r\n\t\t\t\t\ttype: 'POST',\r\n\t\t\t\t\terror: function(xhr,text,error) {\r\n\t\t\t\t\t\tvalue = \$.parseJSON(xhr.responseText);\r\n\t\t\t\t\t\talert(value.error);\r\n\t\t\t\t\t},\r\n\t\t\t\t\tsuccess: function(data,text,xhr) {\r\n\t\t\t\t\t\twindow.location.reload(true); \r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t});\r\n" : "") . "\t\t});\r\n\t</script>"; echo "<h3>Tracks on playlist '" . $playlist->get_name() . "'</h3>"; echo "<div class=\"row\"><div class=\"col-lg-5\"><h5>Showing results " . $low . " to " . $high . "</h5></div><div class=\"pull-right\">" . $pages->display_jump_menu() . $pages->display_items_per_page() . "</div></div>"; echo "<table class=\"table table-striped\" cellspacing=\"0\">\r\n\t<thead>\r\n\t\t<tr>\r\n\t\t\t<th class=\"icon\"> </th>\r\n\t\t\t<th class=\"artist\">Artist</th>\r\n\t\t\t<th class=\"title\">Title</th>\r\n\t\t\t<th class=\"album\">Album</th>\r\n\t\t\t<th class=\"length nowrap\">Length</th> \r\n\t\t\t" . (Session::is_group_user("Playlist Editor") ? "<th class=\"icon\"></th>" : "") . "\r\n\t\t</tr>\r\n\t</thead>"; foreach ($tracks as $track) { echo "\r\n\t\t<tr id=\"" . $track->get_id() . "\">\r\n\t\t\t<td class=\"icon\">\r\n\t\t\t\t<a href=\"" . LINK_ABS . "music/detail/" . $track->get_id() . "\" class=\"track-info\">\r\n\t\t\t\t\t" . Bootstrap::glyphicon("info-sign") . "\r\n\t\t\t\t</a>\r\n\t\t\t\t<div class=\"hover-info\">\r\n\t\t\t\t\t<strong>Artist:</strong> " . $track->get_artists_str() . "<br />\r\n\t\t\t\t\t<strong>Album:</strong> " . $track->get_album()->get_name() . "<br />\r\n\t\t\t\t\t<strong>Year:</strong> " . $track->get_year() . "<br />\r\n\t\t\t\t\t<strong>Length:</strong> " . Time::format_succinct($track->get_length()) . "<br />\r\n\t\t\t\t\t<strong>Origin:</strong> " . $track->get_origin() . "<br />\r\n\t\t\t\t\t" . ($track->get_reclibid() ? "<strong>Reclib ID:</strong> " . $track->get_reclibid() . "<br />" : "") . "\r\n\t\t\t\t\t<strong>Censored:</strong> " . ($track->is_censored() ? "Yes" : "No") . "<br /> \r\n\t\t\t\t</div>\r\n\t\t\t</td>\r\n\t\t\t<td class=\"artist\">" . $track->get_artists_str() . "</td>\r\n\t\t\t<td class=\"title\">" . $track->get_title() . "</td>\r\n\t\t\t<td class=\"album\">" . $track->get_album()->get_name() . "</td>\r\n\t\t\t<td class=\"length nowrap\">" . Time::format_succinct($track->get_length()) . "</td>"; echo (Session::is_group_user("Playlist Editor") ? "<td class=\"icon\"><a href=\"#\" data-dps-track-id=\"" . $track->get_id() . "\" data-dps-playlist-id=\"" . $playlist->get_id() . "\" class=\"track-remove\" title=\"Remove this track\" rel=\"twipsy\">" . Bootstrap::glyphicon("remove-sign") . "</a></td>" : "") . "\r\n\t\t</tr>"; } echo "</table>"; echo $pages->return; } else { if ($playlist) { echo "<h3>Sorry, no tracks are on the playlist '" . $playlist->get_name() . "'</h3>"; if (Session::is_group_user("Playlist Editor")) {
<?php if (Session::is_group_user('Sustainer Admin')) { $slots = SustainerSlots::get_all(); foreach ($slots as $slot) { $compareValue = "slot-" . $slot->get_day() . "-" . $slot->get_time(); if ($compareValue == $_REQUEST["updateid"]) { if (!($playlist = Playlists::get_by_id((int) $_REQUEST["playlistid"]))) { exit(json_encode(array('error' => 'Invalid playlist ID.'))); } if ((int) $_REQUEST["playlistid"] != $slot->get_playlist_id()) { //var_dump((int) $_REQUEST["playlistid"]); $slot->set_playlist_id((int) $_REQUEST["playlistid"]); $slot->save(); } break; } } if (Errors::occured()) { http_response_code(400); exit(json_encode(array("error" => "Something went wrong. You may have discovered a bug!", "detail" => Errors::report("array")))); Errors::clear(); } else { exit(json_encode(array('response' => 'success', 'id' => $playlist->get_id()))); } } else { http_response_code(403); exit(json_encode(array('error' => 'Permission denied.'))); }
public static function get($id) { return Playlists::get_by_id($id); }
if (!is_null($_REQUEST['name'])) { $playlist = new Playlist(); $playlist->set_name($_REQUEST['name']); $playlist->save(); if (Errors::occured()) { http_response_code(400); exit(json_encode(array("error" => "Something went wrong. You may have discovered a bug!", "detail" => Errors::report("array")))); Errors::clear(); } else { exit(json_encode(array('response' => 'success', 'id' => $playlist->get_id()))); } } else { exit(json_encode(array('error' => 'No name specified for playlist.'))); } } else { if (!($playlist = Playlists::get_by_id($_REQUEST['id']))) { exit(json_encode(array('error' => 'Invalid playlist ID.'))); } $playlist->set_name($_REQUEST['name']); $playlist->save(); if (Errors::occured()) { http_response_code(400); exit(json_encode(array("error" => "Something went wrong. You may have discovered a bug!", "detail" => Errors::report("array")))); Errors::clear(); } else { exit(json_encode(array('response' => 'success', 'id' => $playlist->get_id()))); } } } else { http_response_code(403); exit(json_encode(array('error' => 'Permission denied.')));