示例#1
0
function menu()
{
    $site_path_array = explode("/", LINK_FILE);
    $menu = array(array("url" => LINK_ABS . $site_path_array[0] . "/index.php", "text" => "Library Overview", "icon" => "home"), array("url" => LINK_ABS . $site_path_array[0] . "/search", "text" => "Search Tracks", "icon" => "search"), array("url" => LINK_ABS . $site_path_array[0] . "/request", "text" => "Request Tracks", "icon" => "question-sign"), array("url" => LINK_ABS . $site_path_array[0] . "/censor", "text" => "Tag for Censorship", "icon" => "exclamation-sign"), array("url" => LINK_ABS . $site_path_array[0] . "/upload", "text" => "Upload Tracks", "icon" => "upload"));
    $requests = Requests::count();
    if ($requests > 0) {
        $menu[2]["badge"] = $requests;
    }
    $flagged = count(Tracks::get_flagged());
    if ($flagged > 0) {
        $menu[3]["badge"] = $flagged;
    }
    foreach ($menu as &$item) {
        if ($site_path_array[1] == array_pop(explode("/", $item["url"]))) {
            $item["active"] = true;
        }
    }
    return Bootstrap::list_group($menu);
}
示例#2
0
    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>";
    }
    echo "\n</table>";
} else {
    echo "<h4>No tracks currently flagged for censorship.</h4>";
}
$limit = isset($_REQUEST['n']) ? $_REQUEST['n'] : 10;
$page = isset($_REQUEST['p']) ? $_REQUEST['p'] : 1;
$num_of_censored = Tracks::count_censored();
if ($censored = Tracks::get_censored($limit, ($page - 1) * $limit)) {
    $pages = new Paginator();
    $pages->items_per_page = $limit;
    $pages->querystring = NULL;
示例#3
0
<?php

Output::set_title("Music Library");
echo "<script>\r\n\t\$(function () {\r\n\t\t\$('.track-info').popover({\r\n\t\t\t'html': true, \r\n\t\t\t'trigger': 'hover',\r\n\t\t\t'title': function() { \r\n\t\t\t\treturn(\$(this).parent().parent().find('.title').html())\r\n\t\t\t},\r\n\t\t\t'content': function() {\r\n\t\t\t\treturn(\$(this).parent().find('.hover-info').html());\r\n\t\t\t}\r\n\t\t});\r\n\r\n" . (Session::is_group_user("Playlist Editor") ? "\r\n\t\tvar item;\r\n\t\t\$('.playlist-add').click(function() {\r\n\t\t\titem = \$(this).parent().parent();\r\n\t\t\tplaylists = \$(this).attr('data-playlists-in').split(',');\r\n\t\t\t\$('.playlist-select').parent().removeClass('active');\r\n\t\t\t\$('.playlist-select').find('span').removeClass('glyphicon-minus').addClass('glyphicon-plus');\r\n\t\t\t\$('.playlist-select').each(function() {\r\n\t\t\t\tif(\$.inArray(\$(this).attr('data-playlist-id'),playlists) > -1) {\r\n\t\t\t\t\t\$(this).find('span').removeClass('icon-plus').addClass('glyphicon-minus');\r\n\t\t\t\t\t\$(this).parent().addClass('active');\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t});\r\n\r\n\t\t\$('.playlist-select').click(function() {\r\n\t\t\tobj = \$(this);\r\n\t\t\tif(\$(this).parent().hasClass('active')) {\r\n\t\t\t\t\$(this).find('span').removeClass('glyphicon-minus').addClass('glyphicon-refresh');\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: 'trackid='+item.attr('id')+'&playlistid='+obj.attr('data-playlist-id')+'&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\tobj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-minus');\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\tvalues = \$.parseJSON(data);\r\n\t\t\t\t\t\tobj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-plus');\r\n\t\t\t\t\t\tobj.parent().removeClass('active');\r\n\t\t\t\t\t\titem.find('.playlist-add').attr('data-playlists-in',values.playlists.join(','));\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t} else {\r\n\t\t\t\t\$(this).find('span').removeClass('glyphicon-plus').addClass('glyphicon-refresh');\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: 'trackid='+item.attr('id')+'&playlistid='+obj.attr('data-playlist-id')+'&action=add',\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\tobj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-plus');\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\tvalues = \$.parseJSON(data);\r\n\t\t\t\t\t\tobj.find('span').removeClass('glyphicon-refresh').addClass('glyphicon-minus');\r\n\t\t\t\t\t\tobj.parent().addClass('active');\r\n\t\t\t\t\t\titem.find('.playlist-add').attr('data-playlists-in',values.playlists.join(','));\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t\t\$(this).parent().addClass('active');\r\n\t\t\t\t\$(this).find('span').removeClass('glyphicon-plus').addClass('glyphicon-minus');\r\n\t\t\t}\r\n\t\t});\t\t\r\n" : "") . (Session::is_group_user("Librarian") ? "\r\n\t\tvar trackid;\r\n\t\t\$('.track-delete').click(function() {\r\n\t\t\t\$('.delete-track-title').html(\$(this).parent().parent().find('.title').html());\r\n\t\t\ttrackid = \$(this).attr('data-dps-id');\r\n\t\t});\r\n\r\n\t\t\$('.yes-definitely-delete').click(function() {\r\n\t\t\t\$.ajax({\r\n\t\t\t\turl: '" . LINK_ABS . "ajax/delete-track.php',\r\n\t\t\t\tdata: 'id='+trackid,\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" : "") . "\t});\r\n</script>";
MainTemplate::set_subtitle("Add and remove tracks, edit track details");
if (($flagged = Tracks::get_flagged()) && Session::is_group_user("Censor")) {
    echo Bootstrap::alert_message_basic("warning", "<a href=\"" . LINK_ABS . "music/censor\">Click here to view them.</a>", "Tracks have been flagged for censorship.");
}
echo "\r\n<div class=\"row\">\r\n\t<div class=\"col-sm-5\">\r\n\t<h3>Library Statistics</h3>\r\n\t\t<dl>\r\n\t\t\t<dt>Tracks Stored</dt>\r\n\t\t\t<dd>" . number_format(Tracks::get_total_tracks()) . "</dd>\r\n\t\t\t<dt>Length of Tracks</dt>\r\n\t\t\t<dd>" . Time::format_pretty(Tracks::get_total_length()) . "</dd>\r\n\t\t\t<dt>Playlisted Tracks</dt>\r\n\t\t\t<dd>" . count(Tracks::get_playlisted()) . "</dd>\r\n\t\t</dl>\r\n\t</div>\r\n\t<div class=\"col-sm-7\">\r\n\t\t<h3>Requested Tracks</h3>\r\n\t\t";
if ($requested = Requests::get_latest(3)) {
    echo "\r\n\t\t<table class=\"table table-striped table-condensed\" cellspacing=\"0\">\r\n\t\t\t<thead>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<th class=\"icon\"></th>\r\n\t\t\t\t\t<th class=\"artist\">Artist</th>\r\n\t\t\t\t\t<th class=\"title\">Title</th>" . (Session::is_group_user("Requests Admin") ? "\r\n\t\t\t\t\t<th class=\"icon\"></th>" : "") . "\r\n\t\t\t\t</tr>\r\n\t\t\t</thead>";
    foreach ($requested as $request) {
        echo "\r\n\t\t\t<tr id=\"" . $request->get_id() . "\">\r\n\t\t\t\t<td class=\"icon\">\r\n\t\t\t\t\t<a href=\"#\" class=\"track-info\">\r\n\t\t\t\t\t\t" . Bootstrap::glyphicon("info-sign") . "\r\n\t\t\t\t\t</a>\r\n\t\t\t\t\t<div class=\"hover-info\">\r\n\t\t\t\t\t\t<strong>Artist:</strong> " . $request->get_artist_name() . "<br />\r\n\t\t\t\t\t\t<strong>Title:</strong> " . $request->get_name() . "<br />\r\n\t\t\t\t\t\t<strong>Date Requested:</strong> " . date("d/m/Y H:i", $request->get_date()) . "<br />\r\n\t\t\t\t\t\t<strong>Requester:</strong> " . $request->get_user()->get_username() . "<br />\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</td>\r\n\t\t\t\t<td class=\"artist\">" . $request->get_artist_name() . "</td>\r\n\t\t\t\t<td class=\"title\">" . $request->get_name() . "</td>\r\n\t\t\t\t" . (Session::is_group_user("Requests Admin") ? "<td class=\"icon\"><a href=\"" . LINK_ABS . "music/request/delete?id=" . $request->get_id() . "\" class=\"request-delete\" title=\"Delete this request\" rel=\"twipsy\">" . Bootstrap::glyphicon("minus-sign") . "</td>" : "") . "\r\n\t\t\t</tr>";
    }
    echo "\r\n\t\t</table>";
    $total_requests = Requests::count();
    if ($total_requests <= count($requested)) {
        echo "<a href=\"" . LINK_ABS . "music/request\">&raquo; Go to requests</a>";
    } else {
        echo "<a href=\"" . LINK_ABS . "music/request\">&raquo; See " . ($total_requests - count($requested)) . " more requests</a>";
    }
} else {
    echo "\r\n\t\t<strong>No new requested tracks.</strong><br />\r\n\t\t<a href=\"" . LINK_ABS . "music/request\">&raquo; Go to requests</a>";
}
echo "\r\n\t</div>\r\n</div>\r\n<hr />\r\n";
$tracks = Tracks::get_newest();
if ($tracks) {
    echo "<h3>10 newest tracks</h3>";
    echo "<div class=\"table-responsive\"><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=\"date-added nowrap\">Date Added</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\t" . (Session::is_group_user("Librarian") ? "<th class=\"icon\"></th>" : "") . "\r\n\t\t</tr>\r\n\t</thead>";
    foreach ($tracks as $track) {
        $import_date = date("d/m/Y H:i", $track->get_import_date());