<?php $track = Tracks::get_by_id($_REQUEST["id"]); if ($_REQUEST["flag"]) { if ($track->is_flagged()) { $track->set_flagged(false); $response = "unflagged"; } else { $track->set_flagged(true); $response = "flagged"; } } $result = $track->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")))); } exit(json_encode(array("response" => $response)));
public static function get_by_id($id) { $type = DigiplayDB::select("type FROM audio WHERE id = " . $id); if ($type) { if ($type == 1) { return Tracks::get_by_id($id); } else { if ($type == 2) { return Jingles::get_by_id($id); } else { if ($type == 3) { return Adverts::get_by_id($id); } else { if ($type == 4) { return Prerecs::get_by_id($id); } } } } } }
} else { $track = Tracks::get_by_id($_REQUEST["uncensor"]); if ($track) { $track->set_censored(false); $track->save(); echo Bootstrap::alert("success", "The track " . $track->get_title() . " by " . $track->get_artists_str() . " has been uncensored.", "Track uncensored!"); } else { trigger_error("The track you are trying to uncensor doesn't exist!"); } } } if (isset($_REQUEST["unflag"]) && is_numeric($_REQUEST["unflag"])) { if (!Session::is_group_user("Censor")) { echo Bootstrap::alert_message_basic("error", "You are trying to unflag a track, but you do not have the required privileges!", "Error!"); } else { $track = Tracks::get_by_id($_REQUEST["unflag"]); if ($track) { $track->set_flagged(false); $track->save(); echo Bootstrap::alert_message_basic("success", "The track " . $track->get_title() . " by " . $track->get_artists_str() . " has been unflagged.", "Track unflagged!"); } else { trigger_error("The track you are trying to unflag doesn't exist!"); } } } echo "<h3>Flagged for Censorship</h3>"; echo "<strong>To flag a track for censorship, search for it in the music library, click the " . Bootstrap::glyphicon("info-sign") . " and click the \"Flag for censorship\" button.</strong>"; if ($flagged = Tracks::get_flagged()) { echo "\n<table class=\"table table-striped\" cellspacing=\"0\">\n\t<thead>\n\t\t<tr>\n\t\t\t<th class=\"icon\"></th>\n\t\t\t<th class=\"artist\">Artist</th>\n\t\t\t<th class=\"title\">Title</th>\n\t\t\t" . (Session::is_group_user("Music Admin") ? "\n\t\t\t<th class=\"icon\"></th>" : "") . "\n\t\t</tr>\n\t</thead>"; foreach ($flagged as $flag) { echo "\n\t<tr id=\"" . $flag->get_id() . "\">\n\t\t<td class=\"icon\">\n\t\t\t<a href=\"" . LINK_ABS . "music/detail/" . $flag->get_id() . "\" class=\"track-info\">\n\t\t\t\t" . Bootstrap::glyphicon("info-sign") . "\n\t\t\t</a>\n\t\t\t<div class=\"hover-info\">\n\t\t\t\t<strong>Artist:</strong> " . $flag->get_artists_str() . "<br />\n\t\t\t\t<strong>Album:</strong> " . $flag->get_album()->get_name() . "<br />\n\t\t\t\t<strong>Year:</strong> " . $flag->get_year() . "<br />\n\t\t\t\t<strong>Length:</strong> " . Time::format_succinct($flag->get_length()) . "<br />\n\t\t\t\t<strong>Origin:</strong> " . $flag->get_origin() . "<br />\n\t\t\t\t" . ($flag->get_reclibid() ? "<strong>Reclib ID:</strong> " . $flag->get_reclibid() . "<br />" : "") . "\n\t\t\t</div>\n\t\t</td>\n\t\t<td class=\"artist\">" . $flag->get_artists_str() . "</td>\n\t\t<td class=\"title\">" . $flag->get_title() . "</td>\n\t\t" . (Session::is_group_user("Music Admin") ? "\n\t\t<td class=\"icon\"><a href=\"" . LINK_ABS . "music/censor/?censor=" . $flag->get_id() . "\" class=\"censor\" title=\"Approve censorship\" rel=\"twipsy\">" . Bootstrap::glyphicon("ok-sign") . "</td>\n\t\t<td class=\"icon\"><a href=\"" . LINK_ABS . "music/censor/?unflag=" . $flag->get_id() . "\" class=\"unflag\" title=\"Remove flag\" rel=\"twipsy\">" . Bootstrap::glyphicon("remove-sign") . "</td>" : "") . "\n\t</tr>";